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

flux uninstall should error on unrecognised args #4551

Closed
1 task done
Tracked by #4556
avila-m-6 opened this issue Jan 18, 2024 · 3 comments · Fixed by #4553
Closed
1 task done
Tracked by #4556

flux uninstall should error on unrecognised args #4551

avila-m-6 opened this issue Jan 18, 2024 · 3 comments · Fixed by #4553
Labels
good first issue Good for newcomers

Comments

@avila-m-6
Copy link

avila-m-6 commented Jan 18, 2024

Describe the bug

flux cli ignored my resource argument on flux uninstall, fully uninstalling flux instead of my specific intended resource.

Steps to reproduce

$ kubectl get helmrelease.helm.toolkit.fluxcd.io -n flux-ca-system my-resource
NAME             AGE   READY   STATUS
my-resource      23m   False   HelmChart 'flux-ca-system/flux-ca-system-my-resource' is not ready
$ flux --version
flux version 2.1.0
$ flux uninstall helmrelease.helm.toolkit.fluxcd.io -n flux-ca-system my-resource
Are you sure you want to delete Flux and its custom resource definitions: y
► deleting components in flux-ca-system namespace
✔ ServiceAccount/flux-ca-system/helm-controller deleted
✔ ServiceAccount/flux-ca-system/image-automation-controller deleted
[...] (59 other resources)
✔ Namespace/flux-ca-system deleted
✔ uninstall finished
$ 

Expected behavior

An error should be thrown like "my resource is not a recognized argument for flux uninstall".

Screenshots and recordings

No response

OS / Distro

Ubuntu 22.04 (wsl)

Flux version

v2.1.0

Flux check

N/A

Git provider

No response

Container Registry provider

No response

Additional context

I now know to remove the helmrelease with flux uninstall is a mistake, this caused an unintended removal. But that may've been caught by the cli exception.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@stefanprodan
Copy link
Member

Feel free to open a PR similar to #4404

@stefanprodan stefanprodan added the good first issue Good for newcomers label Jan 18, 2024
@twinguy
Copy link
Contributor

twinguy commented Jan 21, 2024

Hi everyone, first time contributor but regular user of Flux. Happy to help with this effort. For the uninstall command, I did some testing and it looks like adding Args: cobra.OnlyValidArgs and ValidArgs: []string{"keep-namespace", "dry-run", "silent"} gives the expected behavior.

@stefanprodan
Copy link
Member

Hey @twinguy the uninstall has no args but only flags, same as bootstrap, please see the PR I linked above.

@stefanprodan stefanprodan changed the title cli should error on unrecognized parameters flux uninstall should error on unrecognised args Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants