Support values for install command

pull/8330/head
Anirudh M 5 years ago
parent b818548c1b
commit 929c64261b

@ -17,6 +17,7 @@ limitations under the License.
package values package values
import ( import (
"fmt"
"io/ioutil" "io/ioutil"
"net/url" "net/url"
"os" "os"
@ -39,7 +40,7 @@ type Options struct {
// MergeValues merges values from files specified via -f/--values and directly // MergeValues merges values from files specified via -f/--values and directly
// via --set, --set-string, or --set-file, marshaling them to YAML // via --set, --set-string, or --set-file, marshaling them to YAML
func (opts *Options) MergeValues(p getter.Providers) (map[string]interface{}, error) { func (opts *Options) MergeValues(p getter.Providers) (map[string]interface{}, error) {
fmt.Println("%+v", opts)
base := map[string]interface{}{} base := map[string]interface{}{}
// User specified a values files via -f/--values // User specified a values files via -f/--values

@ -5,6 +5,7 @@ type InstallRequest struct {
ReleaseName string ReleaseName string
ReleaseNamespace string ReleaseNamespace string
ChartPath string ChartPath string
Values string
} }
type InstallResponse struct { type InstallResponse struct {

@ -31,7 +31,10 @@ func Handler() http.Handler {
request.ReleaseName = req.Header.Get("Release-Name") request.ReleaseName = req.Header.Get("Release-Name")
request.ReleaseNamespace = req.Header.Get("Release-Namespace") request.ReleaseNamespace = req.Header.Get("Release-Namespace")
request.ChartPath = req.Header.Get("Chart-Path") request.ChartPath = req.Header.Get("Chart-Path")
request.Values = req.Header.Get("Values")
valueOpts := &values.Options{} valueOpts := &values.Options{}
valueOpts.Values = append(valueOpts.Values, request.Values)
status, releaseStatus, err := InstallChart(request.ReleaseName, request.ReleaseNamespace, request.ChartPath, valueOpts) status, releaseStatus, err := InstallChart(request.ReleaseName, request.ReleaseNamespace, request.ChartPath, valueOpts)
if err != nil { if err != nil {
@ -54,15 +57,15 @@ func InstallChart(releaseName, releaseNamespace, chartPath string, valueOpts *va
install := action.NewInstall(servercontext.App().ActionConfig) install := action.NewInstall(servercontext.App().ActionConfig)
install.ReleaseName = releaseName install.ReleaseName = releaseName
install.Namespace = releaseNamespace 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 { if err != nil {
fmt.Printf("error in locating chart: %v", err)
return false, "", err return false, "", err
} }
cp, err := install.ChartPathOptions.LocateChart(chartPath, servercontext.App().Config)
if err != nil { if err != nil {
fmt.Printf("error in locating chart: %v", err)
return false, "", err return false, "", err
} }

@ -5,12 +5,12 @@ import (
"fmt" "fmt"
"net/http" "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/action"
"helm.sh/helm/v3/pkg/chart/loader" "helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/cli/values" "helm.sh/helm/v3/pkg/cli/values"
"helm.sh/helm/v3/pkg/getter" "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" "helm.sh/helm/v3/pkg/storage/driver"
) )

Loading…
Cancel
Save