Skip to content
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

feat: Add dry-run flag to prevent pushing module template to registry #2267

Merged
merged 4 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading