Skip to content

Commit

Permalink
Add dry-run flag to prevent pushing module template to registry
Browse files Browse the repository at this point in the history
  • Loading branch information
KacperMalachowski committed Nov 29, 2024
1 parent 2ee106b commit 7ea6490
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/kyma/alpha/create/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ Build a Kubebuilder module my-domain/modC in version 3.2.1 and push it to a loca
cmd.Flags().BoolVar(&o.KubebuilderProject, "kubebuilder-project", false,
"Specifies provided module is a Kubebuilder Project.")

cmd.Flags().BoolVar(&o.DryRun, "dry-run", false, "Prevents pushing the module to the registry, signing and generating the module template.")

configureLegacyFlags(cmd, o)

return cmd
Expand Down Expand Up @@ -389,6 +391,11 @@ func (cmd *command) Run(cobraCmd *cobra.Command) error {
return err
}

if cmd.opts.DryRun {
cmd.CurrentStep.Successf("Image not pushed to %q due to the dry-run flag", cmd.opts.RegistryURL)
return nil
}

if shouldPushArchive {
componentVersionAccess, err = remote.Push(repo, archive, cmd.opts.ArchiveVersionOverwrite)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/kyma/alpha/create/module/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Options struct {
ModuleConfigFile string
KubebuilderProject bool
Namespace string
DryRun bool
}

const (
Expand Down

0 comments on commit 7ea6490

Please sign in to comment.