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 1 year ago
parent bdf9c09d6c
commit d084625a00
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 - oci://REGISTRY/REPO/CHART:VERSION
When CHART is omitted, the chart name is derived from the package. When VERSION is omitted, 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 it comes from Chart.yaml. Use --ensure-version as an optional verification. If set, it
Chart.yaml or the command fails. must match Chart.yaml or the command fails.
Note: OCI tags do not support "+". Helm replaces "+" with "_" in tags when pushing and restores Note: OCI tags do not support "+". Helm replaces "+" with "_" in tags when pushing and restores
"+" when pulling. "+" when pulling.
@ -47,7 +47,7 @@ Note: OCI tags do not support "+". Helm replaces "+" with "_" in tags when pushi
Examples: 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
$ 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 $ 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 plainHTTP bool
password string password string
username string username string
version string ensureVersion string
} }
func newPushCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { 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.WithTLSClientConfig(o.certFile, o.keyFile, o.caFile),
action.WithInsecureSkipTLSVerify(o.insecureSkipTLSVerify), action.WithInsecureSkipTLSVerify(o.insecureSkipTLSVerify),
action.WithPlainHTTP(o.plainHTTP), action.WithPlainHTTP(o.plainHTTP),
action.WithExpectedVersion(o.version), action.WithExpectedVersion(o.ensureVersion),
action.WithPushOptWriter(out)) action.WithPushOptWriter(out))
client.Settings = settings client.Settings = settings
output, err := client.Run(chartRef, remote) 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.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.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.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 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 an expected version is specified via --version, enforce it matches Chart.yaml
if pusher.opts.expectedVersion != "" && pusher.opts.expectedVersion != meta.Metadata.Version { 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) 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") 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()) t.Errorf("Expected error to mention version mismatch check, got %q", err.Error())
} }
} }

Loading…
Cancel
Save