diff --git a/cmds/ocm/commands/controllercmds/common/manifests.go b/cmds/ocm/commands/controllercmds/common/manifests.go index 2f827f0180..9e603e67ff 100644 --- a/cmds/ocm/commands/controllercmds/common/manifests.go +++ b/cmds/ocm/commands/controllercmds/common/manifests.go @@ -98,6 +98,7 @@ func fetchObjects(ctx context.Context, octx clictx.Context, releaseURL, baseURL, } out.Outf(octx, string(content)) + return nil, nil } out.Outf(octx, "► applying to cluster...\n") diff --git a/cmds/ocm/commands/controllercmds/install/cmd.go b/cmds/ocm/commands/controllercmds/install/cmd.go index cec957dcbd..873786f0ea 100644 --- a/cmds/ocm/commands/controllercmds/install/cmd.go +++ b/cmds/ocm/commands/controllercmds/install/cmd.go @@ -41,6 +41,7 @@ type Command struct { DryRun bool SkipPreFlightCheck bool InstallPrerequisites bool + Silent bool SM *ssa.ResourceManager } @@ -71,13 +72,21 @@ func (o *Command) AddFlags(set *pflag.FlagSet) { set.BoolVarP(&o.DryRun, "dry-run", "d", false, "if enabled, prints the downloaded manifest file") set.BoolVarP(&o.SkipPreFlightCheck, "skip-pre-flight-check", "s", false, "skip the pre-flight check for clusters") set.BoolVarP(&o.InstallPrerequisites, "install-prerequisites", "i", true, "install prerequisites required by ocm-controller") + set.BoolVarP(&o.Silent, "silent", "l", false, "don't fail on error") } func (o *Command) Complete(args []string) error { return nil } -func (o *Command) Run() error { +func (o *Command) Run() (err error) { + defer func() { + // don't return any errors + if o.Silent { + err = nil + } + }() + kubeconfigArgs := genericclioptions.NewConfigFlags(false) sm, err := NewResourceManager(kubeconfigArgs) if err != nil { diff --git a/cmds/ocm/commands/controllercmds/install/install_cert_manager.go b/cmds/ocm/commands/controllercmds/install/install_cert_manager.go index 4b6be219fd..8fe2a325a1 100644 --- a/cmds/ocm/commands/controllercmds/install/install_cert_manager.go +++ b/cmds/ocm/commands/controllercmds/install/install_cert_manager.go @@ -25,6 +25,11 @@ func (o *Command) installPrerequisites(ctx context.Context) error { } out.Outf(o.Context, "✔ cert-manager successfully installed\n") + + if o.DryRun { + return nil + } + out.Outf(o.Context, "► creating certificate for internal registry\n") if err := o.createRegistryCertificate(); err != nil { diff --git a/cmds/ocm/commands/controllercmds/uninstall/cmd.go b/cmds/ocm/commands/controllercmds/uninstall/cmd.go index 699070651e..3c1e497462 100644 --- a/cmds/ocm/commands/controllercmds/uninstall/cmd.go +++ b/cmds/ocm/commands/controllercmds/uninstall/cmd.go @@ -35,6 +35,7 @@ type Command struct { CertManagerVersion string SM *ssa.ResourceManager UninstallPrerequisites bool + Silent bool DryRun bool } @@ -65,13 +66,21 @@ func (o *Command) AddFlags(set *pflag.FlagSet) { set.DurationVarP(&o.Timeout, "timeout", "t", 1*time.Minute, "maximum time to wait for deployment to be ready") set.BoolVarP(&o.UninstallPrerequisites, "uninstall-prerequisites", "p", false, "uninstall prerequisites required by ocm-controller") set.BoolVarP(&o.DryRun, "dry-run", "d", false, "if enabled, prints the downloaded manifest file") + set.BoolVarP(&o.Silent, "silent", "l", false, "don't fail on error") } func (o *Command) Complete(args []string) error { return nil } -func (o *Command) Run() error { +func (o *Command) Run() (err error) { + defer func() { + // don't return any errors + if o.Silent { + err = nil + } + }() + kubeconfigArgs := genericclioptions.NewConfigFlags(false) sm, err := NewResourceManager(kubeconfigArgs) if err != nil {