diff --git a/pkg/cmd/push.go b/pkg/cmd/push.go index e759aa630..4118836cb 100644 --- a/pkg/cmd/push.go +++ b/pkg/cmd/push.go @@ -38,8 +38,8 @@ Remote target formats: - oci://REGISTRY/REPO/CHART:VERSION When CHART is omitted, the chart name is derived from the package. When VERSION is omitted, -it comes from Chart.yaml. Use --version as an optional verification. If set, it must match -Chart.yaml or the command fails. +it comes from Chart.yaml. Use --ensure-version as an optional verification. If set, it +must match Chart.yaml or the command fails. Note: OCI tags do not support "+". Helm replaces "+" with "_" in tags when pushing and restores "+" when pulling. @@ -47,7 +47,7 @@ Note: OCI tags do not support "+". Helm replaces "+" with "_" in tags when pushi Examples: $ helm push mychart-0.1.0.tgz oci://my-registry.io/helm/charts - $ helm push mychart-0.1.0.tgz oci://my-registry.io/helm/charts --version 0.1.0 + $ helm push mychart-0.1.0.tgz oci://my-registry.io/helm/charts --ensure-version 0.1.0 $ helm push mychart-0.1.0.tgz oci://my-registry.io/helm/charts/mychart:0.1.0 ` @@ -59,7 +59,7 @@ type registryPushOptions struct { plainHTTP bool password string username string - version string + ensureVersion string } func newPushCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { @@ -102,7 +102,7 @@ func newPushCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { action.WithTLSClientConfig(o.certFile, o.keyFile, o.caFile), action.WithInsecureSkipTLSVerify(o.insecureSkipTLSverify), action.WithPlainHTTP(o.plainHTTP), - action.WithExpectedVersion(o.version), + action.WithExpectedVersion(o.ensureVersion), action.WithPushOptWriter(out)) client.Settings = settings output, err := client.Run(chartRef, remote) @@ -122,7 +122,7 @@ func newPushCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f.BoolVar(&o.plainHTTP, "plain-http", false, "use insecure HTTP connections for the chart upload") f.StringVar(&o.username, "username", "", "chart repository username where to locate the requested chart") f.StringVar(&o.password, "password", "", "chart repository password where to locate the requested chart") - f.StringVar(&o.version, "version", "", "verify the chart version; must match Chart.yaml (optional check)") + f.StringVar(&o.ensureVersion, "ensure-version", "", "verify the chart version; must match Chart.yaml (optional check)") return cmd } diff --git a/pkg/pusher/ocipusher.go b/pkg/pusher/ocipusher.go index 18dbb3986..1c1d63c24 100644 --- a/pkg/pusher/ocipusher.go +++ b/pkg/pusher/ocipusher.go @@ -61,7 +61,7 @@ func (pusher *OCIPusher) push(chartRef, href string) error { // If an expected version is specified via --version, enforce it matches Chart.yaml if pusher.opts.expectedVersion != "" && pusher.opts.expectedVersion != meta.Metadata.Version { - return fmt.Errorf("specified --version %q does not match chart version %q", pusher.opts.expectedVersion, meta.Metadata.Version) + return fmt.Errorf("specified --ensure-version %q does not match chart version %q", pusher.opts.expectedVersion, meta.Metadata.Version) } ref, err := registry.BuildPushRef(href, meta.Metadata.Name, meta.Metadata.Version) diff --git a/pkg/pusher/ocipusher_test.go b/pkg/pusher/ocipusher_test.go index a812e3902..c561e0927 100644 --- a/pkg/pusher/ocipusher_test.go +++ b/pkg/pusher/ocipusher_test.go @@ -472,7 +472,7 @@ func TestOCIPusher_Push_ExpectedVersionMismatch(t *testing.T) { t.Fatal("Expected error when --version does not match chart version") } - if !strings.Contains(err.Error(), "specified --version") { + if !strings.Contains(err.Error(), "specified --ensure-version") { t.Errorf("Expected error to mention version mismatch check, got %q", err.Error()) } }