rename --version to --ensure-version to better reflect its purpose

Good suggestion from Scott today during dev meeting

https://docs.google.com/document/d/1d-6xJEx0C78csIYSPKJzRPeWaHG_8W1Hjl72OJggwdc/edit?pli=1&tab=t.0
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
pull/31347/head
Benoit Tigeot 4 months ago
parent 73746cc438
commit b9cbeef96e
No known key found for this signature in database
GPG Key ID: 8E6D4FC8AEBDA62C

@ -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
}

@ -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)

@ -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())
}
}

Loading…
Cancel
Save