Skip to content

Commit

Permalink
add sielnt flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Skarlso committed May 7, 2024
1 parent 8a4d919 commit 67580e4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmds/ocm/commands/controllercmds/common/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,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")
Expand Down
11 changes: 10 additions & 1 deletion cmds/ocm/commands/controllercmds/install/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Command struct {
DryRun bool
SkipPreFlightCheck bool
InstallPrerequisites bool
Silent bool
SM *ssa.ResourceManager
}

Expand Down Expand Up @@ -75,13 +76,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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/fluxcd/pkg/ssa"
"github.com/mandelsoft/filepath/pkg/filepath"

"github.com/open-component-model/ocm/cmds/ocm/commands/controllercmds/common"
"github.com/open-component-model/ocm/pkg/out"
)
Expand All @@ -23,6 +24,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 {
Expand Down
11 changes: 10 additions & 1 deletion cmds/ocm/commands/controllercmds/uninstall/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type Command struct {
CertManagerVersion string
SM *ssa.ResourceManager
UninstallPrerequisites bool
Silent bool
DryRun bool
}

Expand Down Expand Up @@ -69,13 +70,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 {
Expand Down

0 comments on commit 67580e4

Please sign in to comment.