diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 0c21050b1..df9fbe655 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -41,6 +41,7 @@ import ( "k8s.io/helm/pkg/proto/hapi/release" "k8s.io/helm/pkg/repo" "k8s.io/helm/pkg/strvals" + "net/url" ) const installDesc = ` @@ -175,7 +176,7 @@ func newInstallCmd(c helm.Interface, out io.Writer) *cobra.Command { } f := cmd.Flags() - f.VarP(&inst.valueFiles, "values", "f", "specify values in a YAML file (can specify multiple)") + f.VarP(&inst.valueFiles, "values", "f", "specify values in a YAML file or a URL(can specify multiple)") f.StringVarP(&inst.name, "name", "n", "", "release name. If unspecified, it will autogenerate one for you") f.StringVar(&inst.namespace, "namespace", "", "namespace to install the release into. Defaults to the current kube config namespace.") f.BoolVar(&inst.dryRun, "dry-run", false, "simulate an install") @@ -316,8 +317,9 @@ func vals(valueFiles valueFiles, values []string) ([]byte, error) { if strings.TrimSpace(filePath) == "-" { bytes, err = ioutil.ReadAll(os.Stdin) } else { - bytes, err = ioutil.ReadFile(filePath) + bytes, err = readFile(filePath) } + if err != nil { return []byte{}, err } @@ -469,3 +471,23 @@ func checkDependencies(ch *chart.Chart, reqs *chartutil.Requirements) error { } return nil } + +//readFile load a file from the local directory or a remote file with a url. +func readFile(filePath string) ([]byte, error) { + u, _ := url.Parse(filePath) + p := getter.All(settings) + + // FIXME: maybe someone handle other protocols like ftp. + getterConstructor, err := p.ByScheme(u.Scheme) + + if err != nil { + return ioutil.ReadFile(filePath) + } else { + getter, err := getterConstructor(filePath, "", "", "") + if err != nil { + return []byte{}, err + } + data, err := getter.Get(filePath) + return data.Bytes(), err + } +} diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index 4b852198a..419d74cbc 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -111,7 +111,7 @@ func newUpgradeCmd(client helm.Interface, out io.Writer) *cobra.Command { } f := cmd.Flags() - f.VarP(&upgrade.valueFiles, "values", "f", "specify values in a YAML file (can specify multiple)") + f.VarP(&upgrade.valueFiles, "values", "f", "specify values in a YAML file or a URL(can specify multiple)") f.BoolVar(&upgrade.dryRun, "dry-run", false, "simulate an upgrade") 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") diff --git a/docs/helm/helm_install.md b/docs/helm/helm_install.md index a8f00e434..5fdc7927a 100644 --- a/docs/helm/helm_install.md +++ b/docs/helm/helm_install.md @@ -87,7 +87,7 @@ helm install [CHART] --tls-cert string path to TLS certificate file (default "$HELM_HOME/cert.pem") --tls-key string path to TLS key file (default "$HELM_HOME/key.pem") --tls-verify enable TLS for request and verify remote - -f, --values valueFiles specify values in a YAML file (can specify multiple) (default []) + -f, --values valueFiles specify values in a YAML file or a URL(can specify multiple) (default []) --verify verify the package before installing it --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 diff --git a/docs/helm/helm_upgrade.md b/docs/helm/helm_upgrade.md index fdf95854f..eb320156d 100644 --- a/docs/helm/helm_upgrade.md +++ b/docs/helm/helm_upgrade.md @@ -57,7 +57,7 @@ helm upgrade [RELEASE] [CHART] --tls-cert string path to TLS certificate file (default "$HELM_HOME/cert.pem") --tls-key string path to TLS key file (default "$HELM_HOME/key.pem") --tls-verify enable TLS for request and verify remote - -f, --values valueFiles specify values in a YAML file (can specify multiple) (default []) + -f, --values valueFiles specify values in a YAML file or a URL(can specify multiple) (default []) --verify verify the provenance of the chart before upgrading --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 diff --git a/docs/man/man1/helm_install.1 b/docs/man/man1/helm_install.1 index 98995d47a..a19b3adf4 100644 --- a/docs/man/man1/helm_install.1 +++ b/docs/man/man1/helm_install.1 @@ -192,7 +192,7 @@ charts in a repository, use 'helm search'. .PP \fB\-f\fP, \fB\-\-values\fP=[] - specify values in a YAML file (can specify multiple) + specify values in a YAML file or a URL(can specify multiple) .PP \fB\-\-verify\fP[=false] diff --git a/docs/man/man1/helm_upgrade.1 b/docs/man/man1/helm_upgrade.1 index 5d5e919f6..24bba7c85 100644 --- a/docs/man/man1/helm_upgrade.1 +++ b/docs/man/man1/helm_upgrade.1 @@ -143,7 +143,7 @@ $ helm upgrade \-\-set foo=bar \-\-set foo=newbar redis ./redis .PP \fB\-f\fP, \fB\-\-values\fP=[] - specify values in a YAML file (can specify multiple) + specify values in a YAML file or a URL(can specify multiple) .PP \fB\-\-verify\fP[=false]