Commit a615f80c authored by Arturo Contreras's avatar Arturo Contreras

Adding --set-string flag to force string values.

parent b6335b7d
...@@ -50,7 +50,8 @@ The install argument must be a chart reference, a path to a packaged chart, ...@@ -50,7 +50,8 @@ The install argument must be a chart reference, a path to a packaged chart,
a path to an unpacked chart directory or a URL. a path to an unpacked chart directory or a URL.
To override values in a chart, use either the '--values' flag and pass in a file To override values in a chart, use either the '--values' flag and pass in a file
or use the '--set' flag and pass configuration from the command line. or use the '--set' flag and pass configuration from the command line, to force
a string value use '--set-string'.
$ helm install -f myvalues.yaml ./redis $ helm install -f myvalues.yaml ./redis
...@@ -58,6 +59,10 @@ or ...@@ -58,6 +59,10 @@ or
$ helm install --set name=prod ./redis $ helm install --set name=prod ./redis
or
$ helm install --set-string long_int=1234567890 ./redis
You can specify the '--values'/'-f' flag multiple times. The priority will be given to the You can specify the '--values'/'-f' flag multiple times. The priority will be given to the
last (right-most) file specified. For example, if both myvalues.yaml and override.yaml last (right-most) file specified. For example, if both myvalues.yaml and override.yaml
contained a key called 'Test', the value set in override.yaml would take precedence: contained a key called 'Test', the value set in override.yaml would take precedence:
...@@ -113,6 +118,7 @@ type installCmd struct { ...@@ -113,6 +118,7 @@ type installCmd struct {
out io.Writer out io.Writer
client helm.Interface client helm.Interface
values []string values []string
stringValues []string
nameTemplate string nameTemplate string
version string version string
timeout int64 timeout int64
...@@ -186,6 +192,7 @@ func newInstallCmd(c helm.Interface, out io.Writer) *cobra.Command { ...@@ -186,6 +192,7 @@ func newInstallCmd(c helm.Interface, out io.Writer) *cobra.Command {
f.BoolVar(&inst.disableHooks, "no-hooks", false, "prevent hooks from running during install") f.BoolVar(&inst.disableHooks, "no-hooks", false, "prevent hooks from running during install")
f.BoolVar(&inst.replace, "replace", false, "re-use the given name, even if that name is already used. This is unsafe in production") f.BoolVar(&inst.replace, "replace", false, "re-use the given name, even if that name is already used. This is unsafe in production")
f.StringArrayVar(&inst.values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") f.StringArrayVar(&inst.values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
f.StringArrayVar(&inst.stringValues, "set-string", []string{}, "set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
f.StringVar(&inst.nameTemplate, "name-template", "", "specify template used to name the release") f.StringVar(&inst.nameTemplate, "name-template", "", "specify template used to name the release")
f.BoolVar(&inst.verify, "verify", false, "verify the package before installing it") f.BoolVar(&inst.verify, "verify", false, "verify the package before installing it")
f.StringVar(&inst.keyring, "keyring", defaultKeyring(), "location of public keys used for verification") f.StringVar(&inst.keyring, "keyring", defaultKeyring(), "location of public keys used for verification")
...@@ -211,7 +218,7 @@ func (i *installCmd) run() error { ...@@ -211,7 +218,7 @@ func (i *installCmd) run() error {
i.namespace = defaultNamespace() i.namespace = defaultNamespace()
} }
rawVals, err := vals(i.valueFiles, i.values) rawVals, err := vals(i.valueFiles, i.values, i.stringValues)
if err != nil { if err != nil {
return err return err
} }
...@@ -325,8 +332,8 @@ func mergeValues(dest map[string]interface{}, src map[string]interface{}) map[st ...@@ -325,8 +332,8 @@ func mergeValues(dest map[string]interface{}, src map[string]interface{}) map[st
} }
// vals merges values from files specified via -f/--values and // vals merges values from files specified via -f/--values and
// directly via --set, marshaling them to YAML // directly via --set or --set-string, marshaling them to YAML
func vals(valueFiles valueFiles, values []string) ([]byte, error) { func vals(valueFiles valueFiles, values []string, stringValues []string) ([]byte, error) {
base := map[string]interface{}{} base := map[string]interface{}{}
// User specified a values files via -f/--values // User specified a values files via -f/--values
...@@ -359,6 +366,13 @@ func vals(valueFiles valueFiles, values []string) ([]byte, error) { ...@@ -359,6 +366,13 @@ func vals(valueFiles valueFiles, values []string) ([]byte, error) {
} }
} }
// User specified a value via --set-string
for _, value := range stringValues {
if err := strvals.ParseIntoString(value, base); err != nil {
return []byte{}, fmt.Errorf("failed parsing --set-string data: %s", err)
}
}
return yaml.Marshal(base) return yaml.Marshal(base)
} }
......
...@@ -46,6 +46,7 @@ or recommendation, it will emit [WARNING] messages. ...@@ -46,6 +46,7 @@ or recommendation, it will emit [WARNING] messages.
type lintCmd struct { type lintCmd struct {
valueFiles valueFiles valueFiles valueFiles
values []string values []string
sValues []string
namespace string namespace string
strict bool strict bool
paths []string paths []string
...@@ -71,6 +72,7 @@ func newLintCmd(out io.Writer) *cobra.Command { ...@@ -71,6 +72,7 @@ func newLintCmd(out io.Writer) *cobra.Command {
cmd.Flags().VarP(&l.valueFiles, "values", "f", "specify values in a YAML file (can specify multiple)") cmd.Flags().VarP(&l.valueFiles, "values", "f", "specify values in a YAML file (can specify multiple)")
cmd.Flags().StringArrayVar(&l.values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") cmd.Flags().StringArrayVar(&l.values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
cmd.Flags().StringArrayVar(&l.sValues, "set-string", []string{}, "set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
cmd.Flags().StringVar(&l.namespace, "namespace", "default", "namespace to install the release into (only used if --install is set)") cmd.Flags().StringVar(&l.namespace, "namespace", "default", "namespace to install the release into (only used if --install is set)")
cmd.Flags().BoolVar(&l.strict, "strict", false, "fail on lint warnings") cmd.Flags().BoolVar(&l.strict, "strict", false, "fail on lint warnings")
...@@ -192,5 +194,12 @@ func (l *lintCmd) vals() ([]byte, error) { ...@@ -192,5 +194,12 @@ func (l *lintCmd) vals() ([]byte, error) {
} }
} }
// User specified a value via --set-string
for _, value := range l.sValues {
if err := strvals.ParseIntoString(value, base); err != nil {
return []byte{}, fmt.Errorf("failed parsing --set-string data: %s", err)
}
}
return yaml.Marshal(base) return yaml.Marshal(base)
} }
...@@ -68,6 +68,7 @@ type templateCmd struct { ...@@ -68,6 +68,7 @@ type templateCmd struct {
chartPath string chartPath string
out io.Writer out io.Writer
values []string values []string
stringValues []string
nameTemplate string nameTemplate string
showNotes bool showNotes bool
releaseName string releaseName string
...@@ -96,6 +97,7 @@ func newTemplateCmd(out io.Writer) *cobra.Command { ...@@ -96,6 +97,7 @@ func newTemplateCmd(out io.Writer) *cobra.Command {
f.VarP(&t.valueFiles, "values", "f", "specify values in a YAML file (can specify multiple)") f.VarP(&t.valueFiles, "values", "f", "specify values in a YAML file (can specify multiple)")
f.StringVar(&t.namespace, "namespace", "", "namespace to install the release into") f.StringVar(&t.namespace, "namespace", "", "namespace to install the release into")
f.StringArrayVar(&t.values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") f.StringArrayVar(&t.values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
f.StringArrayVar(&t.stringValues, "set-string", []string{}, "set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
f.StringVar(&t.nameTemplate, "name-template", "", "specify template used to name the release") f.StringVar(&t.nameTemplate, "name-template", "", "specify template used to name the release")
f.StringVar(&t.kubeVersion, "kube-version", defaultKubeVersion, "kubernetes version used as Capabilities.KubeVersion.Major/Minor") f.StringVar(&t.kubeVersion, "kube-version", defaultKubeVersion, "kubernetes version used as Capabilities.KubeVersion.Major/Minor")
f.StringVar(&t.outputDir, "output-dir", "", "writes the executed templates to files in output-dir instead of stdout") f.StringVar(&t.outputDir, "output-dir", "", "writes the executed templates to files in output-dir instead of stdout")
...@@ -149,7 +151,7 @@ func (t *templateCmd) run(cmd *cobra.Command, args []string) error { ...@@ -149,7 +151,7 @@ func (t *templateCmd) run(cmd *cobra.Command, args []string) error {
t.namespace = defaultNamespace() t.namespace = defaultNamespace()
} }
// get combined values and create config // get combined values and create config
rawVals, err := vals(t.valueFiles, t.values) rawVals, err := vals(t.valueFiles, t.values, t.stringValues)
if err != nil { if err != nil {
return err return err
} }
......
...@@ -37,7 +37,8 @@ a packaged chart, or a fully qualified URL. For chart references, the latest ...@@ -37,7 +37,8 @@ a packaged chart, or a fully qualified URL. For chart references, the latest
version will be specified unless the '--version' flag is set. version will be specified unless the '--version' flag is set.
To override values in a chart, use either the '--values' flag and pass in a file To override values in a chart, use either the '--values' flag and pass in a file
or use the '--set' flag and pass configuration from the command line. or use the '--set' flag and pass configuration from the command line, to force string
values, use '--set-string'.
You can specify the '--values'/'-f' flag multiple times. The priority will be given to the You can specify the '--values'/'-f' flag multiple times. The priority will be given to the
last (right-most) file specified. For example, if both myvalues.yaml and override.yaml last (right-most) file specified. For example, if both myvalues.yaml and override.yaml
...@@ -63,6 +64,7 @@ type upgradeCmd struct { ...@@ -63,6 +64,7 @@ type upgradeCmd struct {
disableHooks bool disableHooks bool
valueFiles valueFiles valueFiles valueFiles
values []string values []string
stringValues []string
verify bool verify bool
keyring string keyring string
install bool install bool
...@@ -118,6 +120,7 @@ func newUpgradeCmd(client helm.Interface, out io.Writer) *cobra.Command { ...@@ -118,6 +120,7 @@ func newUpgradeCmd(client helm.Interface, out io.Writer) *cobra.Command {
f.BoolVar(&upgrade.recreate, "recreate-pods", false, "performs pods restart for the resource if applicable") f.BoolVar(&upgrade.recreate, "recreate-pods", false, "performs pods restart for the resource if applicable")
f.BoolVar(&upgrade.force, "force", false, "force resource update through delete/recreate if needed") f.BoolVar(&upgrade.force, "force", false, "force resource update through delete/recreate if needed")
f.StringArrayVar(&upgrade.values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") f.StringArrayVar(&upgrade.values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
f.StringArrayVar(&upgrade.stringValues, "set-string", []string{}, "set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
f.BoolVar(&upgrade.disableHooks, "disable-hooks", false, "disable pre/post upgrade hooks. DEPRECATED. Use no-hooks") f.BoolVar(&upgrade.disableHooks, "disable-hooks", false, "disable pre/post upgrade hooks. DEPRECATED. Use no-hooks")
f.BoolVar(&upgrade.disableHooks, "no-hooks", false, "disable pre/post upgrade hooks") f.BoolVar(&upgrade.disableHooks, "no-hooks", false, "disable pre/post upgrade hooks")
f.BoolVar(&upgrade.verify, "verify", false, "verify the provenance of the chart before upgrading") f.BoolVar(&upgrade.verify, "verify", false, "verify the provenance of the chart before upgrading")
...@@ -183,6 +186,7 @@ func (u *upgradeCmd) run() error { ...@@ -183,6 +186,7 @@ func (u *upgradeCmd) run() error {
disableHooks: u.disableHooks, disableHooks: u.disableHooks,
keyring: u.keyring, keyring: u.keyring,
values: u.values, values: u.values,
stringValues: u.stringValues,
namespace: u.namespace, namespace: u.namespace,
timeout: u.timeout, timeout: u.timeout,
wait: u.wait, wait: u.wait,
...@@ -191,7 +195,7 @@ func (u *upgradeCmd) run() error { ...@@ -191,7 +195,7 @@ func (u *upgradeCmd) run() error {
} }
} }
rawVals, err := vals(u.valueFiles, u.values) rawVals, err := vals(u.valueFiles, u.values, u.stringValues)
if err != nil { if err != nil {
return err return err
} }
......
...@@ -92,7 +92,7 @@ There are three potential sources of values: ...@@ -92,7 +92,7 @@ There are three potential sources of values:
- A chart's `values.yaml` file - A chart's `values.yaml` file
- A values file supplied by `helm install -f` or `helm upgrade -f` - A values file supplied by `helm install -f` or `helm upgrade -f`
- The values passed to a `--set` flag on `helm install` or `helm upgrade` - The values passed to a `--set` or `--set-string` flag on `helm install` or `helm upgrade`
When designing the structure of your values, keep in mind that users of your When designing the structure of your values, keep in mind that users of your
chart may want to override them via either the `-f` flag or with the `--set` chart may want to override them via either the `-f` flag or with the `--set`
......
...@@ -12,7 +12,8 @@ The install argument must be a chart reference, a path to a packaged chart, ...@@ -12,7 +12,8 @@ The install argument must be a chart reference, a path to a packaged chart,
a path to an unpacked chart directory or a URL. a path to an unpacked chart directory or a URL.
To override values in a chart, use either the '--values' flag and pass in a file To override values in a chart, use either the '--values' flag and pass in a file
or use the '--set' flag and pass configuration from the command line. or use the '--set' flag and pass configuration from the command line, to force
a string value use '--set-string'.
$ helm install -f myvalues.yaml ./redis $ helm install -f myvalues.yaml ./redis
...@@ -20,6 +21,10 @@ or ...@@ -20,6 +21,10 @@ or
$ helm install --set name=prod ./redis $ helm install --set name=prod ./redis
or
$ helm install --set-string long_int=1234567890 ./redis
You can specify the '--values'/'-f' flag multiple times. The priority will be given to the You can specify the '--values'/'-f' flag multiple times. The priority will be given to the
last (right-most) file specified. For example, if both myvalues.yaml and override.yaml last (right-most) file specified. For example, if both myvalues.yaml and override.yaml
contained a key called 'Test', the value set in override.yaml would take precedence: contained a key called 'Test', the value set in override.yaml would take precedence:
...@@ -69,32 +74,33 @@ helm install [CHART] ...@@ -69,32 +74,33 @@ helm install [CHART]
### Options ### Options
``` ```
--ca-file string verify certificates of HTTPS-enabled servers using this CA bundle --ca-file string verify certificates of HTTPS-enabled servers using this CA bundle
--cert-file string identify HTTPS client using this SSL certificate file --cert-file string identify HTTPS client using this SSL certificate file
--dep-up run helm dependency update before installing the chart --dep-up run helm dependency update before installing the chart
--devel use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored. --devel use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.
--dry-run simulate an install --dry-run simulate an install
--key-file string identify HTTPS client using this SSL key file --key-file string identify HTTPS client using this SSL key file
--keyring string location of public keys used for verification (default "~/.gnupg/pubring.gpg") --keyring string location of public keys used for verification (default "~/.gnupg/pubring.gpg")
-n, --name string release name. If unspecified, it will autogenerate one for you -n, --name string release name. If unspecified, it will autogenerate one for you
--name-template string specify template used to name the release --name-template string specify template used to name the release
--namespace string namespace to install the release into. Defaults to the current kube config namespace. --namespace string namespace to install the release into. Defaults to the current kube config namespace.
--no-hooks prevent hooks from running during install --no-hooks prevent hooks from running during install
--password string chart repository password where to locate the requested chart --password string chart repository password where to locate the requested chart
--replace re-use the given name, even if that name is already used. This is unsafe in production --replace re-use the given name, even if that name is already used. This is unsafe in production
--repo string chart repository url where to locate the requested chart --repo string chart repository url where to locate the requested chart
--set stringArray set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2) --set stringArray set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
--timeout int time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks) (default 300) --set-string stringArray set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
--tls enable TLS for request --timeout int time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks) (default 300)
--tls-ca-cert string path to TLS CA certificate file (default "$HELM_HOME/ca.pem") --tls enable TLS for request
--tls-cert string path to TLS certificate file (default "$HELM_HOME/cert.pem") --tls-ca-cert string path to TLS CA certificate file (default "$HELM_HOME/ca.pem")
--tls-key string path to TLS key file (default "$HELM_HOME/key.pem") --tls-cert string path to TLS certificate file (default "$HELM_HOME/cert.pem")
--tls-verify enable TLS for request and verify remote --tls-key string path to TLS key file (default "$HELM_HOME/key.pem")
--username string chart repository username where to locate the requested chart --tls-verify enable TLS for request and verify remote
-f, --values valueFiles specify values in a YAML file or a URL(can specify multiple) (default []) --username string chart repository username where to locate the requested chart
--verify verify the package before installing it -f, --values valueFiles specify values in a YAML file or a URL(can specify multiple) (default [])
--version string specify the exact chart version to install. If this is not specified, the latest version is installed --verify verify the package before installing it
--wait if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful. It will wait for as long as --timeout --version string specify the exact chart version to install. If this is not specified, the latest version is installed
--wait if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful. It will wait for as long as --timeout
``` ```
### Options inherited from parent commands ### Options inherited from parent commands
...@@ -111,4 +117,4 @@ helm install [CHART] ...@@ -111,4 +117,4 @@ helm install [CHART]
### SEE ALSO ### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes. * [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 8-Mar-2018 ###### Auto generated by spf13/cobra on 20-Mar-2018
...@@ -21,10 +21,11 @@ helm lint [flags] PATH ...@@ -21,10 +21,11 @@ helm lint [flags] PATH
### Options ### Options
``` ```
--namespace string namespace to install the release into (only used if --install is set) (default "default") --namespace string namespace to install the release into (only used if --install is set) (default "default")
--set stringArray set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2) --set stringArray set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
--strict fail on lint warnings --set-string stringArray set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
-f, --values valueFiles specify values in a YAML file (can specify multiple) (default []) --strict fail on lint warnings
-f, --values valueFiles specify values in a YAML file (can specify multiple) (default [])
``` ```
### Options inherited from parent commands ### Options inherited from parent commands
...@@ -41,4 +42,4 @@ helm lint [flags] PATH ...@@ -41,4 +42,4 @@ helm lint [flags] PATH
### SEE ALSO ### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes. * [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 8-Mar-2018 ###### Auto generated by spf13/cobra on 9-Mar-2018
...@@ -25,15 +25,16 @@ helm template [flags] CHART ...@@ -25,15 +25,16 @@ helm template [flags] CHART
### Options ### Options
``` ```
-x, --execute stringArray only execute the given templates -x, --execute stringArray only execute the given templates
--kube-version string kubernetes version used as Capabilities.KubeVersion.Major/Minor (default "1.9") --kube-version string kubernetes version used as Capabilities.KubeVersion.Major/Minor (default "1.9")
-n, --name string release name (default "RELEASE-NAME") -n, --name string release name (default "RELEASE-NAME")
--name-template string specify template used to name the release --name-template string specify template used to name the release
--namespace string namespace to install the release into --namespace string namespace to install the release into
--notes show the computed NOTES.txt file as well --notes show the computed NOTES.txt file as well
--output-dir string writes the executed templates to files in output-dir instead of stdout --output-dir string writes the executed templates to files in output-dir instead of stdout
--set stringArray set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2) --set stringArray set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
-f, --values valueFiles specify values in a YAML file (can specify multiple) (default []) --set-string stringArray set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
-f, --values valueFiles specify values in a YAML file (can specify multiple) (default [])
``` ```
### Options inherited from parent commands ### Options inherited from parent commands
...@@ -50,4 +51,4 @@ helm template [flags] CHART ...@@ -50,4 +51,4 @@ helm template [flags] CHART
### SEE ALSO ### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes. * [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 8-Mar-2018 ###### Auto generated by spf13/cobra on 9-Mar-2018
...@@ -14,7 +14,8 @@ a packaged chart, or a fully qualified URL. For chart references, the latest ...@@ -14,7 +14,8 @@ a packaged chart, or a fully qualified URL. For chart references, the latest
version will be specified unless the '--version' flag is set. version will be specified unless the '--version' flag is set.
To override values in a chart, use either the '--values' flag and pass in a file To override values in a chart, use either the '--values' flag and pass in a file
or use the '--set' flag and pass configuration from the command line. or use the '--set' flag and pass configuration from the command line, to force string
values, use '--set-string'.
You can specify the '--values'/'-f' flag multiple times. The priority will be given to the You can specify the '--values'/'-f' flag multiple times. The priority will be given to the
last (right-most) file specified. For example, if both myvalues.yaml and override.yaml last (right-most) file specified. For example, if both myvalues.yaml and override.yaml
...@@ -36,33 +37,34 @@ helm upgrade [RELEASE] [CHART] ...@@ -36,33 +37,34 @@ helm upgrade [RELEASE] [CHART]
### Options ### Options
``` ```
--ca-file string verify certificates of HTTPS-enabled servers using this CA bundle --ca-file string verify certificates of HTTPS-enabled servers using this CA bundle
--cert-file string identify HTTPS client using this SSL certificate file --cert-file string identify HTTPS client using this SSL certificate file
--devel use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored. --devel use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.
--dry-run simulate an upgrade --dry-run simulate an upgrade
--force force resource update through delete/recreate if needed --force force resource update through delete/recreate if needed
-i, --install if a release by this name doesn't already exist, run an install -i, --install if a release by this name doesn't already exist, run an install
--key-file string identify HTTPS client using this SSL key file --key-file string identify HTTPS client using this SSL key file
--keyring string path to the keyring that contains public signing keys (default "~/.gnupg/pubring.gpg") --keyring string path to the keyring that contains public signing keys (default "~/.gnupg/pubring.gpg")
--namespace string namespace to install the release into (only used if --install is set). Defaults to the current kube config namespace --namespace string namespace to install the release into (only used if --install is set). Defaults to the current kube config namespace
--no-hooks disable pre/post upgrade hooks --no-hooks disable pre/post upgrade hooks
--password string chart repository password where to locate the requested chart --password string chart repository password where to locate the requested chart
--recreate-pods performs pods restart for the resource if applicable --recreate-pods performs pods restart for the resource if applicable
--repo string chart repository url where to locate the requested chart --repo string chart repository url where to locate the requested chart
--reset-values when upgrading, reset the values to the ones built into the chart --reset-values when upgrading, reset the values to the ones built into the chart
--reuse-values when upgrading, reuse the last release's values, and merge in any new values. If '--reset-values' is specified, this is ignored. --reuse-values when upgrading, reuse the last release's values, and merge in any new values. If '--reset-values' is specified, this is ignored.
--set stringArray set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2) --set stringArray set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
--timeout int time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks) (default 300) --set-string stringArray set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
--tls enable TLS for request --timeout int time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks) (default 300)
--tls-ca-cert string path to TLS CA certificate file (default "$HELM_HOME/ca.pem") --tls enable TLS for request
--tls-cert string path to TLS certificate file (default "$HELM_HOME/cert.pem") --tls-ca-cert string path to TLS CA certificate file (default "$HELM_HOME/ca.pem")
--tls-key string path to TLS key file (default "$HELM_HOME/key.pem") --tls-cert string path to TLS certificate file (default "$HELM_HOME/cert.pem")
--tls-verify enable TLS for request and verify remote --tls-key string path to TLS key file (default "$HELM_HOME/key.pem")
--username string chart repository username where to locate the requested chart --tls-verify enable TLS for request and verify remote
-f, --values valueFiles specify values in a YAML file or a URL(can specify multiple) (default []) --username string chart repository username where to locate the requested chart
--verify verify the provenance of the chart before upgrading -f, --values valueFiles specify values in a YAML file or a URL(can specify multiple) (default [])
--version string specify the exact chart version to use. If this is not specified, the latest version is used --verify verify the provenance of the chart before upgrading
--wait if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful. It will wait for as long as --timeout --version string specify the exact chart version to use. If this is not specified, the latest version is used
--wait if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful. It will wait for as long as --timeout
``` ```
### Options inherited from parent commands ### Options inherited from parent commands
...@@ -79,4 +81,4 @@ helm upgrade [RELEASE] [CHART] ...@@ -79,4 +81,4 @@ helm upgrade [RELEASE] [CHART]
### SEE ALSO ### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes. * [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 8-Mar-2018 ###### Auto generated by spf13/cobra on 20-Mar-2018
...@@ -45,18 +45,38 @@ func ToYAML(s string) (string, error) { ...@@ -45,18 +45,38 @@ func ToYAML(s string) (string, error) {
func Parse(s string) (map[string]interface{}, error) { func Parse(s string) (map[string]interface{}, error) {
vals := map[string]interface{}{} vals := map[string]interface{}{}
scanner := bytes.NewBufferString(s) scanner := bytes.NewBufferString(s)
t := newParser(scanner, vals) t := newParser(scanner, vals, false)
err := t.parse() err := t.parse()
return vals, err return vals, err
} }
//ParseInto parses a strvals line and merges the result into dest. // Parse parses a set line and forces a string value.
//
// A set line is of the form name1=value1,name2=value2
func ParseString(s string) (map[string]interface{}, error) {
vals := map[string]interface{}{}
scanner := bytes.NewBufferString(s)
t := newParser(scanner, vals, true)
err := t.parse()
return vals, err
}
// ParseInto parses a strvals line and merges the result into dest.
// //
// If the strval string has a key that exists in dest, it overwrites the // If the strval string has a key that exists in dest, it overwrites the
// dest version. // dest version.
func ParseInto(s string, dest map[string]interface{}) error { func ParseInto(s string, dest map[string]interface{}) error {
scanner := bytes.NewBufferString(s) scanner := bytes.NewBufferString(s)
t := newParser(scanner, dest) t := newParser(scanner, dest, false)
return t.parse()
}
// ParseIntoString parses a strvals line nad merges the result into dest.
//
// This method always returns a string as the value.
func ParseIntoString(s string, dest map[string]interface{}) error {
scanner := bytes.NewBufferString(s)
t := newParser(scanner, dest, true)
return t.parse() return t.parse()
} }
...@@ -65,10 +85,11 @@ func ParseInto(s string, dest map[string]interface{}) error { ...@@ -65,10 +85,11 @@ func ParseInto(s string, dest map[string]interface{}) error {
type parser struct { type parser struct {
sc *bytes.Buffer sc *bytes.Buffer
data map[string]interface{} data map[string]interface{}
st bool
} }
func newParser(sc *bytes.Buffer, data map[string]interface{}) *parser { func newParser(sc *bytes.Buffer, data map[string]interface{}, stringBool bool) *parser {
return &parser{sc: sc, data: data} return &parser{sc: sc, data: data, st: stringBool}
} }
func (t *parser) parse() error { func (t *parser) parse() error {
...@@ -133,7 +154,7 @@ func (t *parser) key(data map[string]interface{}) error { ...@@ -133,7 +154,7 @@ func (t *parser) key(data map[string]interface{}) error {
return e return e
case ErrNotList: case ErrNotList:
v, e := t.val() v, e := t.val()
set(data, string(k), typedVal(v)) set(data, string(k), typedVal(v, t.st))
return e return e
default: default:
return e return e
...@@ -206,7 +227,7 @@ func (t *parser) listItem(list []interface{}, i int) ([]interface{}, error) { ...@@ -206,7 +227,7 @@ func (t *parser) listItem(list []interface{}, i int) ([]interface{}, error) {
return setIndex(list, i, ""), err return setIndex(list, i, ""), err
case ErrNotList: case ErrNotList:
v, e := t.val() v, e := t.val()
return setIndex(list, i, typedVal(v)), e return setIndex(list, i, typedVal(v, t.st)), e
default: default:
return list, e return list, e
} }
...@@ -265,10 +286,10 @@ func (t *parser) valList() ([]interface{}, error) { ...@@ -265,10 +286,10 @@ func (t *parser) valList() ([]interface{}, error) {
if r, _, e := t.sc.ReadRune(); e == nil && r != ',' { if r, _, e := t.sc.ReadRune(); e == nil && r != ',' {
t.sc.UnreadRune() t.sc.UnreadRune()
} }
list = append(list, typedVal(v)) list = append(list, typedVal(v, t.st))
return list, nil return list, nil
case last == ',': case last == ',':
list = append(list, typedVal(v)) list = append(list, typedVal(v, t.st))
} }
} }
} }
...@@ -298,7 +319,7 @@ func inMap(k rune, m map[rune]bool) bool { ...@@ -298,7 +319,7 @@ func inMap(k rune, m map[rune]bool) bool {
return ok return ok
} }
func typedVal(v []rune) interface{} { func typedVal(v []rune, st bool) interface{} {
val := string(v) val := string(v)
if strings.EqualFold(val, "true") { if strings.EqualFold(val, "true") {
return true return true
...@@ -308,8 +329,8 @@ func typedVal(v []rune) interface{} { ...@@ -308,8 +329,8 @@ func typedVal(v []rune) interface{} {
return false return false
} }
// If this value does not start with zero, try parsing it to an int // If this value does not start with zero, and not returnString, try parsing it to an int
if len(val) != 0 && val[0] != '0' { if !st && len(val) != 0 && val[0] != '0' {
if iv, err := strconv.ParseInt(val, 10, 64); err == nil { if iv, err := strconv.ParseInt(val, 10, 64); err == nil {
return iv return iv
} }
......
...@@ -65,6 +65,17 @@ func TestSetIndex(t *testing.T) { ...@@ -65,6 +65,17 @@ func TestSetIndex(t *testing.T) {
} }
func TestParseSet(t *testing.T) { func TestParseSet(t *testing.T) {
testsString := []struct {
str string
expect map[string]interface{}
err bool
}{
{
str: "long_int_string=1234567890",
expect: map[string]interface{}{"long_int_string": "1234567890"},
err: false,
},
}
tests := []struct { tests := []struct {
str string str string
expect map[string]interface{} expect map[string]interface{}
...@@ -97,6 +108,10 @@ func TestParseSet(t *testing.T) { ...@@ -97,6 +108,10 @@ func TestParseSet(t *testing.T) {
str: "leading_zeros=00009", str: "leading_zeros=00009",
expect: map[string]interface{}{"leading_zeros": "00009"}, expect: map[string]interface{}{"leading_zeros": "00009"},
}, },
{
str: "long_int=1234567890",
expect: map[string]interface{}{"long_int": 1234567890},
},
{ {
str: "name1,name2=", str: "name1,name2=",
err: true, err: true,
...@@ -278,6 +293,31 @@ func TestParseSet(t *testing.T) { ...@@ -278,6 +293,31 @@ func TestParseSet(t *testing.T) {
t.Fatalf("Error serializing parsed value: %s", err) t.Fatalf("Error serializing parsed value: %s", err)
} }
if string(y1) != string(y2) {
t.Errorf("%s: Expected:\n%s\nGot:\n%s", tt.str, y1, y2)
}
}
for _, tt := range testsString {
got, err := ParseString(tt.str)
if err != nil {
if tt.err {
continue
}
t.Fatalf("%s: %s", tt.str, err)
}
if tt.err {
t.Errorf("%s: Expected error. Got nil", tt.str)
}
y1, err := yaml.Marshal(tt.expect)
if err != nil {
t.Fatal(err)
}
y2, err := yaml.Marshal(got)
if err != nil {
t.Fatalf("Error serializing parsed value: %s", err)
}
if string(y1) != string(y2) { if string(y1) != string(y2) {
t.Errorf("%s: Expected:\n%s\nGot:\n%s", tt.str, y1, y2) t.Errorf("%s: Expected:\n%s\nGot:\n%s", tt.str, y1, y2)
} }
......
...@@ -830,6 +830,8 @@ _helm_install() ...@@ -830,6 +830,8 @@ _helm_install()
local_nonpersistent_flags+=("--repo=") local_nonpersistent_flags+=("--repo=")
flags+=("--set=") flags+=("--set=")
local_nonpersistent_flags+=("--set=") local_nonpersistent_flags+=("--set=")
flags+=("--set-string=")
local_nonpersistent_flags+=("--set-string=")
flags+=("--timeout=") flags+=("--timeout=")
local_nonpersistent_flags+=("--timeout=") local_nonpersistent_flags+=("--timeout=")
flags+=("--tls") flags+=("--tls")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment