-
Notifications
You must be signed in to change notification settings - Fork 8
Add opt-in --crd flag to install and uninstall commands #470
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,10 +31,11 @@ func newInstallCommand(cfg *ClientConfig) *cobra.Command { | |
| var dryRun bool | ||
| var flagVersion string | ||
| var imagePullPolicy string | ||
| var crd bool | ||
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "install", | ||
| Short: "Install kelos CRDs and controller into the cluster", | ||
| Short: "Install kelos controller into the cluster", | ||
| Args: cobra.NoArgs, | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| if flagVersion != "" { | ||
|
|
@@ -46,10 +47,12 @@ func newInstallCommand(cfg *ClientConfig) *cobra.Command { | |
| } | ||
|
|
||
| if dryRun { | ||
| if _, err := os.Stdout.Write(manifests.InstallCRD); err != nil { | ||
| return err | ||
| if crd { | ||
| if _, err := os.Stdout.Write(manifests.InstallCRD); err != nil { | ||
| return err | ||
| } | ||
| fmt.Fprintln(os.Stdout, "---") | ||
| } | ||
| fmt.Fprintln(os.Stdout, "---") | ||
| _, err := os.Stdout.Write(controllerManifest) | ||
| return err | ||
| } | ||
|
|
@@ -70,9 +73,11 @@ func newInstallCommand(cfg *ClientConfig) *cobra.Command { | |
|
|
||
| ctx := cmd.Context() | ||
|
|
||
| fmt.Fprintf(os.Stdout, "Installing kelos CRDs\n") | ||
| if err := applyManifests(ctx, dc, dyn, manifests.InstallCRD); err != nil { | ||
| return fmt.Errorf("installing CRDs: %w", err) | ||
| if crd { | ||
| fmt.Fprintf(os.Stdout, "Installing kelos CRDs\n") | ||
| if err := applyManifests(ctx, dc, dyn, manifests.InstallCRD); err != nil { | ||
| return fmt.Errorf("installing CRDs: %w", err) | ||
| } | ||
| } | ||
|
|
||
| fmt.Fprintf(os.Stdout, "Installing kelos controller (version: %s)\n", version.Version) | ||
|
|
@@ -88,6 +93,7 @@ func newInstallCommand(cfg *ClientConfig) *cobra.Command { | |
| cmd.Flags().BoolVar(&dryRun, "dry-run", false, "print the manifests that would be applied without installing") | ||
| cmd.Flags().StringVar(&flagVersion, "version", "", "override the version used for image tags (defaults to the binary version)") | ||
| cmd.Flags().StringVar(&imagePullPolicy, "image-pull-policy", "", "set imagePullPolicy on controller containers (e.g. Always, IfNotPresent, Never)") | ||
| cmd.Flags().BoolVar(&crd, "crd", false, "install CRDs along with the controller") | ||
|
|
||
| return cmd | ||
| } | ||
|
|
@@ -134,9 +140,11 @@ func withImagePullPolicy(data []byte, policy string) []byte { | |
| } | ||
|
|
||
| func newUninstallCommand(cfg *ClientConfig) *cobra.Command { | ||
| var crd bool | ||
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "uninstall", | ||
| Short: "Uninstall kelos controller and CRDs from the cluster", | ||
| Short: "Uninstall kelos controller from the cluster", | ||
| Args: cobra.NoArgs, | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| restConfig, _, err := cfg.resolveConfig() | ||
|
|
@@ -160,16 +168,20 @@ func newUninstallCommand(cfg *ClientConfig) *cobra.Command { | |
| return fmt.Errorf("removing controller: %w", err) | ||
| } | ||
|
|
||
| fmt.Fprintf(os.Stdout, "Removing kelos CRDs\n") | ||
| if err := deleteManifests(ctx, dc, dyn, manifests.InstallCRD); err != nil { | ||
| return fmt.Errorf("removing CRDs: %w", err) | ||
| if crd { | ||
| fmt.Fprintf(os.Stdout, "Removing kelos CRDs\n") | ||
| if err := deleteManifests(ctx, dc, dyn, manifests.InstallCRD); err != nil { | ||
| return fmt.Errorf("removing CRDs: %w", err) | ||
| } | ||
| } | ||
|
|
||
| fmt.Fprintf(os.Stdout, "Kelos uninstalled successfully\n") | ||
| return nil | ||
| }, | ||
| } | ||
|
|
||
| cmd.Flags().BoolVar(&crd, "crd", false, "remove CRDs along with the controller") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The Prompt for AI agents |
||
|
|
||
| return cmd | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
P0: The
--crdflag default is changed fromtruetofalse, which is a breaking change that contradicts the PR description (which says default istrue) and the README Quick Start guide (which sayskelos installinstalls CRDs). Users runningkelos installwill silently skip CRD installation. If the intent is trulydefault=false, the README must be updated; if not, this default should betrue.(Based on your team's feedback about keeping documentation and config updated with changes.)
View Feedback
Prompt for AI agents