Skip to content

Commit

Permalink
feat: 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 authored Dec 4, 2024
1 parent 2ee106b commit 817a55d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
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
1 change: 1 addition & 0 deletions docs/gen-docs/kyma_alpha_create_module.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Build a Kubebuilder module my-domain/modC in version 3.2.1 and push it to a loca
-c, --credentials string Basic authentication credentials for the given registry in the user:password format
--default-cr string File containing the default custom resource of the module. If the module is a kubebuilder project, the default CR is automatically detected.
--descriptor-version string Schema version to use for the generated OCM descriptor. One of ocm.software/v3alpha1,v2 (default "v2")
--dry-run Prevents pushing the module to the registry, signing and generating the module template.
--git-remote string Specifies the remote name of the wanted GitHub repository. For Example "origin" or "upstream" (default "origin")
--insecure Uses an insecure connection to access the registry.
--key string Specifies the path where a private key is used for signing.
Expand Down
2 changes: 1 addition & 1 deletion internal/resolve/resolve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func Test_GetFile(t *testing.T) {
assert.Equal(t, currFile, file, "Local files should not be copied to the dst-folder")
})
t.Run("Retrieve remote file", func(t *testing.T) {
file, err := File("https://raw.githubusercontent.com/kyma-project/cli/main/LICENCE", testDir)
file, err := File("https://raw.githubusercontent.com/kyma-project/cli/main/LICENSE", testDir)
assert.NoError(t, err)
assert.Equal(t, filepath.Join(testDir, "LICENCE"), file, "Remote files should be copied to the dst-folder")
})
Expand Down

0 comments on commit 817a55d

Please sign in to comment.