Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): configure for non interactive environments #3659

Merged
merged 2 commits into from Feb 16, 2024
Merged

Conversation

schoren
Copy link
Collaborator

@schoren schoren commented Feb 16, 2024

This PR fixes an issue on the CLI preventing the configure command to work on automated environments. The command was asking for user input (asking for server) even when the --token flag was passed. This flag allows us to infer a non interactive environment so we can use a reasonable fallback (cloud url or previously configured value from config file) if no --server-url is provided.

On top of this, there was some incorrect handling of the flags within the configurator. Flags were saved as an instance variable by value instead of reference, so when one method modifies a flag value, the change is lost at the end of the function scope (see comments on PR)

Changes

Fixes

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

Loom video

Add your loom video here if your work can be visualized

Copy link

vercel bot commented Feb 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tracetest ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 16, 2024 10:54pm

c.finalServerURL = serverURL
if err != nil {
return err
c.flags = &flags
Copy link
Collaborator Author

@schoren schoren Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the original flags value was passed around in functions call, on top of being saved to the instance. this was confusing to follow and created 2 different copies of the same value, so modifications were almost impossible to track

All references to flags where replaced by c.flags and that in turn was converted to a pointer to allow modifications

@@ -17,12 +17,12 @@ type Entry struct {
func (c Configurator) organizationSelector(ctx context.Context, cfg Config, prev *Config) (string, error) {
resource, err := c.resources.Get("organization")
if err != nil {
return "", err
return "", fmt.Errorf("cannot create organizations client: %w", err)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some extra error info helped me debug the issue

@schoren schoren merged commit 909841d into main Feb 16, 2024
39 checks passed
@schoren schoren deleted the fix-token-config branch February 16, 2024 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants