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

Support prompt for certain argocd cmd commands #19528

Closed
reggie-k opened this issue Aug 14, 2024 · 0 comments · Fixed by #19637
Closed

Support prompt for certain argocd cmd commands #19528

reggie-k opened this issue Aug 14, 2024 · 0 comments · Fixed by #19637
Labels
component:cli Affects the Argo CD CLI component:core Syncing, diffing, cluster state cache enhancement New feature or request type:enhancement

Comments

@reggie-k
Copy link
Member

reggie-k commented Aug 14, 2024

Summary

It would be beneficial for some admin commands to display an "Are you sure" prompt before proceeding, with some extra info about the expected result of the command.

Motivation

Example use cases:

  1. Upon importing apps with prune option, displaying the prompt with the number of the apps that are expected to be deleted.
    "argocd admin export" only exports ArgoCD apps from the same namespace as where ArgoCD is deployed #14596
  2. Confirm removal of repo credentials:
    feat: add prompting to confirm remove of repository credentials #11040
  3. Confirm removal of GPG keys
    feat: add prompting to confirm deletion of gpg public key #10415

Proposal

Enabling the prompt by default is a breaking change for CI pipelines/other automations running argocd cmd.
As a gradual non-breaking solution, a feature flag enable-argocd-cmd-prompt: false can be introduced, along with the supporting core functionality, and docs stating that enabling this feature would require a change in the CI/automation that runs the argocd cmd.
An additional "--auto-approve-prompt" flag should be also be introduced for usage in the CI/automation after enabling the feature flag.

In the future, if it would be desired for the default behavior to be with the prompt, enable-argocd-cmd-prompt: true can be introduced as the default, for v3, along with detailed docs.

@reggie-k reggie-k added the enhancement New feature or request label Aug 14, 2024
@alexmt alexmt added component:cli Affects the Argo CD CLI component:core Syncing, diffing, cluster state cache type:enhancement labels Aug 14, 2024
pasha-codefresh pushed a commit that referenced this issue Oct 25, 2024
…19528) (#19637)

* Add `Prompt`, with `prompts.enabled` setting in `argocd-cm`

Signed-off-by: David Wu <[email protected]>

* Make `SettingsOpts`, `SettingsOpts.ArgocdCMPath`, `SettingsOpts.CreateSettingsManager()`  and `commandContext.CreateSettingsManager()` exportable

Signed-off-by: David Wu <[email protected]>

* Add `prompt_test.go`

Signed-off-by: David Wu <[email protected]>

* Refactor `NewPrompt()` and move into new package `utils`

Signed-off-by: David Wu <[email protected]>

* Update `NewPrompt()` to use local config

Signed-off-by: David Wu <[email protected]>

* Add `NewConfigurationCommand()`

Signed-off-by: David Wu <[email protected]>

* Move `prompt_test.go`

Signed-off-by: David Wu <[email protected]>

* Remove `prompt_test.go` for now

Signed-off-by: David Wu <[email protected]>

* Add back and update `prompt_test.go`

Signed-off-by: David Wu <[email protected]>

* Add `configuration_test.go`

Signed-off-by: David Wu <[email protected]>

* Fix linting issues

Signed-off-by: David Wu <[email protected]>

* Fix linting issues

Signed-off-by: David Wu <[email protected]>

* Reverse early-termination logic in `Confirm()`

Signed-off-by: David Wu <[email protected]>

* Rename `ArgocdCMPath` to `argocdCMPath`

Signed-off-by: David Wu <[email protected]>

* Rename `SettingsOpts` to `settingsOpts`

Signed-off-by: David Wu <[email protected]>

* Rename `CreateSettingsManager()` to `createSettingsManager()`

Signed-off-by: David Wu <[email protected]>

* Rename `configuration` to `configure`

Signed-off-by: David Wu <[email protected]>

* Further rename `configuration` to `configure`

Signed-off-by: David Wu <[email protected]>

* Remove redundant Argo CD ConfigMap logic

Signed-off-by: David Wu <[email protected]>

* Fix terminal output spacing

Signed-off-by: David Wu <[email protected]>

* Make `argocd configure` use local config value as the default value for `--prompts-enabled`

Signed-off-by: David Wu <[email protected]>

* Add global CLI flag `--force-prompts-enabled`

Signed-off-by: David Wu <[email protected]>

* Update existing `prompt_test.go` test cases

Signed-off-by: David Wu <[email protected]>

* Add test case for `(p *Prompt).Confirm()`

Signed-off-by: David Wu <[email protected]>

* Add test cases for `GetBoolFlagWithFallback()` to `env_test.go`

Signed-off-by: David Wu <[email protected]>

* Format imports

Signed-off-by: David Wu <[email protected]>

* Further format imports and remove unused variable

Signed-off-by: David Wu <[email protected]>

* Again format imports

Signed-off-by: David Wu <[email protected]>

* Add fallback to `GetPromptsEnabled()`

Signed-off-by: David Wu <[email protected]>

* Fix bug in `GetPromptsEnabled()`

Signed-off-by: David Wu <[email protected]>

* Fix missing import

Signed-off-by: David Wu <[email protected]>

* Add auto-generated docs for `argocd configure`

Signed-off-by: David Wu <[email protected]>

* Add auto-generated docs for new global CLI flag `--force-prompts-enabled`

Signed-off-by: David Wu <[email protected]>

* Update `NewPrompt()` to receive a `bool` rather than `*apiclient.ClientOptions` arg

Signed-off-by: David Wu <[email protected]>

* Remove arg `fallback` from `GetPromptsEnabled()`

Signed-off-by: David Wu <[email protected]>

* Add arg `useCLIOpts bool` to `GetPromptsEnabled()`

Signed-off-by: David Wu <[email protected]>

* Make `config.LoadFlags()` exportable

Signed-off-by: David Wu <[email protected]>

* Add tests for `GetPromptsEnabled()`

Signed-off-by: David Wu <[email protected]>

* Fix linting errors in tests

Signed-off-by: David Wu <[email protected]>

* Run `make codegen-local`

Signed-off-by: David Wu <[email protected]>

---------

Signed-off-by: David Wu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:cli Affects the Argo CD CLI component:core Syncing, diffing, cluster state cache enhancement New feature or request type:enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants