Commit cad1936f authored by Matt Butcher's avatar Matt Butcher Committed by GitHub

Merge pull request #842 from technosophos/feat/get-all-values

feat(helm): add 'helm get values --all' for all values
parents e36647d1 f30ff915
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/helm" "k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/timeconv" "k8s.io/helm/pkg/timeconv"
) )
...@@ -44,6 +45,8 @@ charts, those resources will also be included in the manifest. ...@@ -44,6 +45,8 @@ charts, those resources will also be included in the manifest.
// If it is blank, output is sent to os.Stdout. // If it is blank, output is sent to os.Stdout.
var getOut = "" var getOut = ""
var allValues = false
var errReleaseRequired = errors.New("release name is required") var errReleaseRequired = errors.New("release name is required")
var getCommand = &cobra.Command{ var getCommand = &cobra.Command{
...@@ -69,7 +72,12 @@ var getManifestCommand = &cobra.Command{ ...@@ -69,7 +72,12 @@ var getManifestCommand = &cobra.Command{
} }
func init() { func init() {
// 'get' command flags.
getCommand.PersistentFlags().StringVarP(&getOut, "file", "f", "", "output file") getCommand.PersistentFlags().StringVarP(&getOut, "file", "f", "", "output file")
// 'get values' flags.
getValuesCommand.PersistentFlags().BoolVarP(&allValues, "all", "a", false, "dump all (computed) values")
getCommand.AddCommand(getValuesCommand) getCommand.AddCommand(getValuesCommand)
getCommand.AddCommand(getManifestCommand) getCommand.AddCommand(getManifestCommand)
RootCommand.AddCommand(getCommand) RootCommand.AddCommand(getCommand)
...@@ -86,10 +94,21 @@ func getCmd(cmd *cobra.Command, args []string) error { ...@@ -86,10 +94,21 @@ func getCmd(cmd *cobra.Command, args []string) error {
return prettyError(err) return prettyError(err)
} }
cfg, err := chartutil.CoalesceValues(res.Release.Chart, res.Release.Config, nil)
if err != nil {
return err
}
cfgStr, err := cfg.YAML()
if err != nil {
return err
}
fmt.Printf("CHART: %s-%s\n", res.Release.Chart.Metadata.Name, res.Release.Chart.Metadata.Version) fmt.Printf("CHART: %s-%s\n", res.Release.Chart.Metadata.Name, res.Release.Chart.Metadata.Version)
fmt.Printf("RELEASED: %s\n", timeconv.Format(res.Release.Info.LastDeployed, time.ANSIC)) fmt.Printf("RELEASED: %s\n", timeconv.Format(res.Release.Info.LastDeployed, time.ANSIC))
fmt.Println("CONFIG:") fmt.Println("USER-SUPPLIED VALUES:")
fmt.Println(res.Release.Config.Raw) fmt.Println(res.Release.Config.Raw)
fmt.Println("COMPUTED VALUES:")
fmt.Println(cfgStr)
fmt.Println("MANIFEST:") fmt.Println("MANIFEST:")
fmt.Println(res.Release.Manifest) fmt.Println(res.Release.Manifest)
return nil return nil
...@@ -105,7 +124,21 @@ func getValues(cmd *cobra.Command, args []string) error { ...@@ -105,7 +124,21 @@ func getValues(cmd *cobra.Command, args []string) error {
if err != nil { if err != nil {
return prettyError(err) return prettyError(err)
} }
return getToFile(res.Release.Config)
// If the user wants all values, compute the values and return.
if allValues {
cfg, err := chartutil.CoalesceValues(res.Release.Chart, res.Release.Config, nil)
if err != nil {
return err
}
cfgStr, err := cfg.YAML()
if err != nil {
return err
}
return getToFile(cfgStr)
}
return getToFile(res.Release.Config.Raw)
} }
// getManifest implements 'helm get manifest' // getManifest implements 'helm get manifest'
......
...@@ -20,6 +20,12 @@ const GlobalKey = "global" ...@@ -20,6 +20,12 @@ const GlobalKey = "global"
// Values represents a collection of chart values. // Values represents a collection of chart values.
type Values map[string]interface{} type Values map[string]interface{}
// YAML encodes the Values into a YAML string.
func (v Values) YAML() (string, error) {
b, err := yaml.Marshal(v)
return string(b), err
}
// Table gets a table (YAML subsection) from a Values object. // Table gets a table (YAML subsection) from a Values object.
// //
// The table is returned as a Values. // The table is returned as a Values.
...@@ -113,7 +119,6 @@ func CoalesceValues(chrt *chart.Chart, vals *chart.Config, overrides map[string] ...@@ -113,7 +119,6 @@ func CoalesceValues(chrt *chart.Chart, vals *chart.Config, overrides map[string]
// Parse values if not nil. We merge these at the top level because // Parse values if not nil. We merge these at the top level because
// the passed-in values are in the same namespace as the parent chart. // the passed-in values are in the same namespace as the parent chart.
if vals != nil { if vals != nil {
log.Printf("Merging overrides into config.")
evals, err := ReadValues([]byte(vals.Raw)) evals, err := ReadValues([]byte(vals.Raw))
if err != nil { if err != nil {
return cvals, err return cvals, err
......
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