fix(*): change TOML to YAML

pull/793/head
Matt Butcher 9 years ago
parent 7aa4ffa4d4
commit 9ca8c27e16

@ -16,7 +16,7 @@ option go_package = "services";
// config. At any given time a release has one // config. At any given time a release has one
// chart and one config. // chart and one config.
// //
// Config: A config is a TOML file that supplies values // Config: A config is a YAML file that supplies values
// to the parametrizable templates of a chart. // to the parametrizable templates of a chart.
// //
// Chart: A chart is a helm package that contains // Chart: A chart is a helm package that contains
@ -150,7 +150,7 @@ message UpdateReleaseResponse {
message InstallReleaseRequest { message InstallReleaseRequest {
// Chart is the protobuf representation of a chart. // Chart is the protobuf representation of a chart.
hapi.chart.Chart chart = 1; hapi.chart.Chart chart = 1;
// Values is a string containing (unparsed) TOML values. // Values is a string containing (unparsed) YAML values.
hapi.chart.Config values = 2; hapi.chart.Config values = 2;
// DryRun, if true, will run through the release logic, but neither create // DryRun, if true, will run through the release logic, but neither create
// a release object nor deploy to Kubernetes. The release object returned // a release object nor deploy to Kubernetes. The release object returned

@ -19,7 +19,7 @@ something like this:
foo/ foo/
|- Chart.yaml # Information about your chart |- Chart.yaml # Information about your chart
| |
|- values.toml # The default values for your templates |- values.yaml # The default values for your templates
| |
|- charts/ # Charts that this chart depends on |- charts/ # Charts that this chart depends on
| |

@ -42,7 +42,7 @@ var installCmd = &cobra.Command{
func init() { func init() {
f := installCmd.Flags() f := installCmd.Flags()
f.StringVarP(&installValues, "values", "f", "", "path to a values TOML file") f.StringVarP(&installValues, "values", "f", "", "path to a values YAML file")
f.StringVarP(&installRelName, "name", "n", "", "the release name. If unspecified, it will autogenerate one for you.") f.StringVarP(&installRelName, "name", "n", "", "the release name. If unspecified, it will autogenerate one for you.")
f.BoolVar(&installDryRun, "dry-run", false, "simulate an install") f.BoolVar(&installDryRun, "dry-run", false, "simulate an install")

@ -25,7 +25,7 @@ wordpress/
Chart.yaml # A YAML file containing information about the chart Chart.yaml # A YAML file containing information about the chart
LICENSE # OPTIONAL: A plain text file containing the license for the chart LICENSE # OPTIONAL: A plain text file containing the license for the chart
README.md # OPTIONAL: A human-readable README file README.md # OPTIONAL: A human-readable README file
values.toml # The default configuration values for this chart values.yaml # The default configuration values for this chart
charts/ # A directory containing any charts upon which this chart depends. charts/ # A directory containing any charts upon which this chart depends.
templates/ # A directory of templates that, when combined with values, templates/ # A directory of templates that, when combined with values,
# will generate valid Kubernetes manifest files. # will generate valid Kubernetes manifest files.
@ -133,13 +133,13 @@ Helm renders the charts, it will pass every file in that directory
through the template engine. through the template engine.
Values for the templates are supplied two ways: Values for the templates are supplied two ways:
- Chart developers may supply a file called `values.toml` inside of a - Chart developers may supply a file called `values.yaml` inside of a
chart. This file can contain default values. chart. This file can contain default values.
- Chart users may supply a TOML file that contains values. This can be - Chart users may supply a YAML file that contains values. This can be
provided on the command line with `helm install`. provided on the command line with `helm install`.
When a user supplies custom values, these values will override the When a user supplies custom values, these values will override the
values in the chart's `values.toml` file. values in the chart's `values.yaml` file.
### Template Files ### Template Files
Template files follow the standard conventions for writing Go templates. Template files follow the standard conventions for writing Go templates.
@ -207,36 +207,36 @@ used to pass arbitrarily structured data into the template.
### Values files ### Values files
Considering the template in the previous section, a `values.toml` file Considering the template in the previous section, a `values.yaml` file
that supplies the necessary values would look like this: that supplies the necessary values would look like this:
```toml ```yaml
imageRegistry = "quay.io/deis" imageRegistry = "quay.io/deis"
dockerTag = "latest" dockerTag = "latest"
pullPolicy = "alwaysPull" pullPolicy = "alwaysPull"
storage = "s3" storage = "s3"
``` ```
A values file is formatted in TOML. A chart may include a default A values file is formatted in YAML. A chart may include a default
`values.toml` file. The Helm install command allows a user to override `values.yaml` file. The Helm install command allows a user to override
values by supplying additional TOML values: values by supplying additional YAML values:
```console ```console
$ helm install --values=myvals.toml wordpress $ helm install --values=myvals.yaml wordpress
``` ```
When values are passed in this way, they will be merged into the default When values are passed in this way, they will be merged into the default
values file. For example, consider a `myvals.toml` file that looks like values file. For example, consider a `myvals.yaml` file that looks like
this: this:
```toml ```yaml
storage = "gcs" storage = "gcs"
``` ```
When this is merged with the `values.toml` in the chart, the resulting When this is merged with the `values.yaml` in the chart, the resulting
generated content will be: generated content will be:
```toml ```yaml
imageRegistry = "quay.io/deis" imageRegistry = "quay.io/deis"
dockerTag = "latest" dockerTag = "latest"
pullPolicy = "alwaysPull" pullPolicy = "alwaysPull"
@ -246,7 +246,7 @@ storage = "gcs"
Note that only the last field was overridden. Note that only the last field was overridden.
**NOTE:** The default values file included inside of a chart _must_ be named **NOTE:** The default values file included inside of a chart _must_ be named
`values.toml`. But files specified on the command line can be named `values.yaml`. But files specified on the command line can be named
anything. anything.
### Scope, Dependencies, and Values ### Scope, Dependencies, and Values
@ -259,7 +259,7 @@ demonstration Wordpress chart above has both `mysql` and `apache` as
dependencies. The values file could supply values to all of these dependencies. The values file could supply values to all of these
components: components:
```toml ```yaml
title = "My Wordpress Site" # Sent to the Wordpress template title = "My Wordpress Site" # Sent to the Wordpress template
[mysql] [mysql]
@ -289,7 +289,7 @@ standard references that will help you out.
- [Go templates](https://godoc.org/text/template) - [Go templates](https://godoc.org/text/template)
- [Extra template functions](https://godoc.org/github.com/Masterminds/sprig) - [Extra template functions](https://godoc.org/github.com/Masterminds/sprig)
- [The TOML format](https://github.com/toml-lang/toml) - [The YAML format]()
## Using Helm to Manage Charts ## Using Helm to Manage Charts

@ -3,7 +3,7 @@ This example was generated using the command `helm create alpine`.
The `templates/` directory contains a very simple pod resource with a The `templates/` directory contains a very simple pod resource with a
couple of parameters. couple of parameters.
The `values.toml` file contains the default values for the The `values.yaml` file contains the default values for the
`alpine-pod.yaml` template. `alpine-pod.yaml` template.
You can install this example using `helm install docs/examples/alpine`. You can install this example using `helm install docs/examples/alpine`.

@ -1,2 +0,0 @@
# The pod name
name = "my-alpine"

@ -0,0 +1,2 @@
# The pod name
name: my-alpine

@ -93,7 +93,9 @@ func loadFiles(files []*afile) (*chart.Chart, error) {
return c, err return c, err
} }
c.Metadata = m c.Metadata = m
} else if f.name == "values.toml" || f.name == "values.yaml" { } else if f.name == "values.toml" {
return c, errors.New("values.toml is illegal as of 2.0.0-alpha.2")
} else if f.name == "values.yaml" {
c.Values = &chart.Config{Raw: string(f.data)} c.Values = &chart.Config{Raw: string(f.data)}
} else if strings.HasPrefix(f.name, "templates/") { } else if strings.HasPrefix(f.name, "templates/") {
c.Templates = append(c.Templates, &chart.Template{Name: f.name, Data: f.data}) c.Templates = append(c.Templates, &chart.Template{Name: f.name, Data: f.data})

Binary file not shown.

@ -1,4 +1,4 @@
# Default values for mast1. # Default values for mast1.
# This is a TOML-formatted file. https://github.com/toml-lang/toml # This is a YAML-formatted file.
# Declare name/value pairs to be passed into your templates. # Declare name/value pairs to be passed into your templates.
# name = "value" # name = "value"

@ -7,8 +7,7 @@ import (
"text/template" "text/template"
"github.com/Masterminds/sprig" "github.com/Masterminds/sprig"
"k8s.io/helm/pkg/chartutil"
chartutil "k8s.io/helm/pkg/chart"
"k8s.io/helm/pkg/proto/hapi/chart" "k8s.io/helm/pkg/proto/hapi/chart"
) )
@ -177,7 +176,7 @@ func coalesceValues(c *chart.Chart, v chartutil.Values) chartutil.Values {
nv, err := chartutil.ReadValues([]byte(c.Values.Raw)) nv, err := chartutil.ReadValues([]byte(c.Values.Raw))
if err != nil { if err != nil {
// On error, we return just the overridden values. // On error, we return just the overridden values.
// FIXME: We should log this error. It indicates that the TOML data // FIXME: We should log this error. It indicates that the YAML data
// did not parse. // did not parse.
log.Printf("error reading default values: %s", err) log.Printf("error reading default values: %s", err)
return v return v
@ -226,7 +225,7 @@ func coalesceTables(dst, src map[string]interface{}) {
} }
} }
// istable is a special-purpose function to see if the present thing matches the definition of a TOML table. // istable is a special-purpose function to see if the present thing matches the definition of a YAML table.
func istable(v interface{}) bool { func istable(v interface{}) bool {
_, ok := v.(map[string]interface{}) _, ok := v.(map[string]interface{})
return ok return ok

@ -5,7 +5,7 @@ import (
"sync" "sync"
"testing" "testing"
chartutil "k8s.io/helm/pkg/chart" "k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/proto/hapi/chart" "k8s.io/helm/pkg/proto/hapi/chart"
) )
@ -31,13 +31,12 @@ func TestRender(t *testing.T) {
{Name: "test1", Data: []byte("{{.outer | title }} {{.inner | title}}")}, {Name: "test1", Data: []byte("{{.outer | title }} {{.inner | title}}")},
}, },
Values: &chart.Config{ Values: &chart.Config{
Raw: `outer = "DEFAULT"\ninner= "DEFAULT"\n`, Raw: "outer: DEFAULT\ninner: DEFAULT",
}, },
} }
vals := &chart.Config{ vals := &chart.Config{
Raw: `outer = "BAD" Raw: "outer: BAD\ninner: inn",
inner= "inn"`,
} }
overrides := map[string]interface{}{ overrides := map[string]interface{}{
@ -207,18 +206,20 @@ func TestRenderNestedValues(t *testing.T) {
{Name: outerpath, Data: []byte(`Gather ye {{.what}} while ye may`)}, {Name: outerpath, Data: []byte(`Gather ye {{.what}} while ye may`)},
}, },
Values: &chart.Config{ Values: &chart.Config{
Raw: `what = "stinkweed" Raw: `
[herrick] what: stinkweed
who = "time" herrick:
`}, who: time`,
},
Dependencies: []*chart.Chart{inner}, Dependencies: []*chart.Chart{inner},
} }
inject := chart.Config{ inject := chart.Config{
Raw: ` Raw: `
what = "rosebuds" what: rosebuds
[herrick.deepest] herrick:
what = "flower"`, deepest:
what: flower`,
} }
out, err := e.Render(outer, &inject, map[string]interface{}{}) out, err := e.Render(outer, &inject, map[string]interface{}{})

@ -9,7 +9,7 @@ const (
ErrMissingTpls = Error("missing chart templates") ErrMissingTpls = Error("missing chart templates")
// ErrMissingChart indicates that the Chart.yaml data is missing. // ErrMissingChart indicates that the Chart.yaml data is missing.
ErrMissingChart = Error("missing chart metadata") ErrMissingChart = Error("missing chart metadata")
// ErrMissingValues indicates that the config values.toml data is missing. // ErrMissingValues indicates that the config values.yaml data is missing.
ErrMissingValues = Error("missing chart values") ErrMissingValues = Error("missing chart values")
) )

@ -53,8 +53,8 @@ func TestBadValues(t *testing.T) {
if len(m) != 1 { if len(m) != 1 {
t.Errorf("All didn't fail with expected errors, got %#v", m) t.Errorf("All didn't fail with expected errors, got %#v", m)
} }
if !strings.Contains(m[0].Text, "Bare keys cannot contain ':'") { if !strings.Contains(m[0].Text, "cannot unmarshal") {
t.Errorf("All didn't have the error for invalid key format") t.Errorf("All didn't have the error for invalid key format: %s", m[0].Text)
} }
} }

@ -8,7 +8,7 @@ type Severity int
const ( const (
// UnknownSev indicates that the severity of the error is unknown, and should not stop processing. // UnknownSev indicates that the severity of the error is unknown, and should not stop processing.
UnknownSev = iota UnknownSev = iota
// InfoSev indicates information, for example missing values.toml file // InfoSev indicates information, for example missing values.yaml file
InfoSev InfoSev
// WarningSev indicates that something does not meet code standards, but will likely function. // WarningSev indicates that something does not meet code standards, but will likely function.
WarningSev WarningSev

@ -1 +0,0 @@
name = "mariner"

@ -0,0 +1 @@
name: "mariner"

@ -1,4 +0,0 @@
# Default values for badchartfile.
# This is a TOML-formatted file. https://github.com/toml-lang/toml
# Declare name/value pairs to be passed into your templates.
# name = "value"

@ -0,0 +1 @@
# Default values for badchartfile.

@ -1,2 +1,2 @@
# Invalid value for badvaluesfile for testing lint fails with invalid toml format # Invalid value for badvaluesfile for testing lint fails with invalid yaml format
name: "value" name= "value"

@ -1 +0,0 @@
name = "goodone here"

@ -0,0 +1 @@
name: "goodone here"

@ -4,18 +4,18 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"k8s.io/helm/pkg/chart" "k8s.io/helm/pkg/chartutil"
) )
// Values lints a chart's values.toml file. // Values lints a chart's values.yaml file.
func Values(basepath string) (messages []Message) { func Values(basepath string) (messages []Message) {
vf := filepath.Join(basepath, "values.toml") vf := filepath.Join(basepath, "values.yaml")
messages = []Message{} messages = []Message{}
if _, err := os.Stat(vf); err != nil { if _, err := os.Stat(vf); err != nil {
messages = append(messages, Message{Severity: InfoSev, Text: "No values.toml file"}) messages = append(messages, Message{Severity: InfoSev, Text: "No values.yaml file"})
return return
} }
_, err := chart.ReadValuesFile(vf) _, err := chartutil.ReadValuesFile(vf)
if err != nil { if err != nil {
messages = append(messages, Message{Severity: ErrorSev, Text: err.Error()}) messages = append(messages, Message{Severity: ErrorSev, Text: err.Error()})
} }

@ -238,7 +238,7 @@ func (*UpdateReleaseResponse) Descriptor() ([]byte, []int) { return fileDescript
type InstallReleaseRequest struct { type InstallReleaseRequest struct {
// Chart is the protobuf representation of a chart. // Chart is the protobuf representation of a chart.
Chart *hapi_chart3.Chart `protobuf:"bytes,1,opt,name=chart" json:"chart,omitempty"` Chart *hapi_chart3.Chart `protobuf:"bytes,1,opt,name=chart" json:"chart,omitempty"`
// Values is a string containing (unparsed) TOML values. // Values is a string containing (unparsed) YAML values.
Values *hapi_chart.Config `protobuf:"bytes,2,opt,name=values" json:"values,omitempty"` Values *hapi_chart.Config `protobuf:"bytes,2,opt,name=values" json:"values,omitempty"`
// DryRun, if true, will run through the release logic, but neither create // DryRun, if true, will run through the release logic, but neither create
// a release object nor deploy to Kubernetes. The release object returned // a release object nor deploy to Kubernetes. The release object returned

Loading…
Cancel
Save