-
Couldn't load subscription status.
- Fork 7.3k
Support "prompt" config setting #1639
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
Conversation
This comment has been minimized.
This comment has been minimized.
a132a0f to
89faec5
Compare
55a1198 to
c0fc31f
Compare
the behavior for nontty vs. prompts disabled is pretty different so i opted for a new test, here
|
One nit: the values of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! This looks good; I've pointed out some minor things that I see as regressions in non-interactive mode.
The only overall direction I would change is avoiding saying “when prompts are disabled” in error messages when CanPrompt() returns false, because those messages will also be shown in CI/CD environments and scripts where prompts might have not been disabled per se, but are not available due to lack of terminal. So maybe a better message would be to say “when running non-interactively” or something similar?
| return fmt.Errorf("failed to write config, authentication configuration not updated: %w", err) | ||
| } | ||
|
|
||
| isTTY := opts.IO.IsStdinTTY() && opts.IO.IsStdoutTTY() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could also name these tty checks something more descriptive that declares intent, like opts.IO.ShouldShowConfirmation() (ideally with a better name). Perhaps in a separate changeset!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of an IO.ShowConfirmations()! i'll open an issue for it.
pkg/cmd/repo/create/create.go
Outdated
| return &cmdutil.FlagError{Err: errors.New("must pass name argument when prompts disabled")} | ||
| } | ||
| if !opts.Internal && !opts.Private && !opts.Public { | ||
| opts.Public = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I strongly feel that we should either default to --private or error out in non-interactive mode when repo visibility wasn't explicitly declared.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaulting to private feels right to me, but didn't we get multiple issues complaining about not defaulting to public for repo creation? or am I misremembering?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I set it to error now, happy to update to something else later. I figured the annoyance of getting an error is better than the annoyance of having to go to the browser and toggle the repo visibility if the default isn't what you wanted.
This PR adds support for a new configuration setting,
prompt, with supported valuesautoandnever.I tried to track down all the commands that prompt and updated:
I didn't add new tests for the most part since I was just tweaking the code paths already in place for non-tty support.
It's also worth noting that this cannot be configured per-host, something I call out in the default config comments.
Closes #1587