From 929c64261b46096a433f0c2f0c7318f8eef9903d Mon Sep 17 00:00:00 2001 From: Anirudh M Date: Fri, 19 Jun 2020 11:25:41 +0530 Subject: [PATCH] Support values for install command --- pkg/cli/values/options.go | 3 ++- pkg/http/api/install/installcontract.go | 1 + pkg/http/api/install/installhandler.go | 9 ++++++--- pkg/http/api/upgrade/upgradehandler.go | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pkg/cli/values/options.go b/pkg/cli/values/options.go index ebb74ae4e..3cf584cd0 100644 --- a/pkg/cli/values/options.go +++ b/pkg/cli/values/options.go @@ -17,6 +17,7 @@ limitations under the License. package values import ( + "fmt" "io/ioutil" "net/url" "os" @@ -39,7 +40,7 @@ type Options struct { // MergeValues merges values from files specified via -f/--values and directly // via --set, --set-string, or --set-file, marshaling them to YAML func (opts *Options) MergeValues(p getter.Providers) (map[string]interface{}, error) { - + fmt.Println("%+v", opts) base := map[string]interface{}{} // User specified a values files via -f/--values diff --git a/pkg/http/api/install/installcontract.go b/pkg/http/api/install/installcontract.go index c943d4520..bf6c6bb4f 100644 --- a/pkg/http/api/install/installcontract.go +++ b/pkg/http/api/install/installcontract.go @@ -5,6 +5,7 @@ type InstallRequest struct { ReleaseName string ReleaseNamespace string ChartPath string + Values string } type InstallResponse struct { diff --git a/pkg/http/api/install/installhandler.go b/pkg/http/api/install/installhandler.go index 2f4d90bc5..3dbcbdef3 100644 --- a/pkg/http/api/install/installhandler.go +++ b/pkg/http/api/install/installhandler.go @@ -31,7 +31,10 @@ func Handler() http.Handler { request.ReleaseName = req.Header.Get("Release-Name") request.ReleaseNamespace = req.Header.Get("Release-Namespace") request.ChartPath = req.Header.Get("Chart-Path") + request.Values = req.Header.Get("Values") + valueOpts := &values.Options{} + valueOpts.Values = append(valueOpts.Values, request.Values) status, releaseStatus, err := InstallChart(request.ReleaseName, request.ReleaseNamespace, request.ChartPath, valueOpts) if err != nil { @@ -54,15 +57,15 @@ func InstallChart(releaseName, releaseNamespace, chartPath string, valueOpts *va install := action.NewInstall(servercontext.App().ActionConfig) install.ReleaseName = releaseName install.Namespace = releaseNamespace - vals, err := valueOpts.MergeValues(getter.All(servercontext.App().Config)) - cp, err := install.ChartPathOptions.LocateChart(chartPath, servercontext.App().Config) + vals, err := valueOpts.MergeValues(getter.All(servercontext.App().Config)) if err != nil { - fmt.Printf("error in locating chart: %v", err) return false, "", err } + cp, err := install.ChartPathOptions.LocateChart(chartPath, servercontext.App().Config) if err != nil { + fmt.Printf("error in locating chart: %v", err) return false, "", err } diff --git a/pkg/http/api/upgrade/upgradehandler.go b/pkg/http/api/upgrade/upgradehandler.go index c5e3d3a92..5949459eb 100644 --- a/pkg/http/api/upgrade/upgradehandler.go +++ b/pkg/http/api/upgrade/upgradehandler.go @@ -5,12 +5,12 @@ import ( "fmt" "net/http" - "helm.sh/helm/v3/cmd/endpoints/install" - "helm.sh/helm/v3/cmd/servercontext" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/chart/loader" "helm.sh/helm/v3/pkg/cli/values" "helm.sh/helm/v3/pkg/getter" + "helm.sh/helm/v3/pkg/http/api/install" + "helm.sh/helm/v3/pkg/servercontext" "helm.sh/helm/v3/pkg/storage/driver" )