documentation updates and tweaking workflows with env vars. It now throws errors if they're not set

This commit is contained in:
Nathan Vecchiarelli 2017-04-12 10:15:56 -04:00
parent 373e750642
commit bc8bbf8e01
3 changed files with 20 additions and 10 deletions

View File

@ -29,6 +29,9 @@ charts:
set: # values (--set) set: # values (--set)
- name: address - name: address
value: https://vault.example.com value: https://vault.example.com
env: # values (--set) but value will be pulled from environment variables. Will throw an error if the environment variable is not set.
- name: db.password
value: DB_PASSWORD # $DB_PASSOWRD needs to be set in the calling environment ex: export DB_PASSWORD='password1'
``` ```
@ -41,24 +44,24 @@ charts:
``` ```
NAME: NAME:
helmfile helmfile -
USAGE: USAGE:
helmfile [global options] command [command options] [arguments...] main [global options] command [command options] [arguments...]
VERSION: VERSION:
0.0.0 0.1.0
COMMANDS: COMMANDS:
repos sync repositories from state file (helm repo add && help repo update) repos sync repositories from state file (helm repo add && helm repo update)
charts sync charts from state file (helm repo upgrade --install) charts sync charts from state file (helm repo upgrade --install)
sync sync all resources from state file (repos && charts) sync sync all resources from state file (repos && charts)
delete delete charts from state file (helm delete) delete delete charts from state file (helm delete)
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS: GLOBAL OPTIONS:
--file FILE, -f FILE load config from FILE (default: "charts.yaml") --file FILE, -f FILE load config from FILE (default: "charts.yaml")
--quiet, -q silence output --quiet, -q silence output
--kube-context value Set kubectl context. Uses current context by default
--help, -h show help --help, -h show help
--version, -v print the version --version, -v print the version
``` ```

View File

@ -21,6 +21,7 @@ func main() {
app := cli.NewApp() app := cli.NewApp()
app.Name = "helmfile" app.Name = "helmfile"
app.Usage = "" app.Usage = ""
app.Version = "0.1.0"
app.Flags = []cli.Flag{ app.Flags = []cli.Flag{
cli.StringFlag{ cli.StringFlag{
Name: "file, f", Name: "file, f",
@ -33,7 +34,7 @@ func main() {
}, },
cli.StringFlag{ cli.StringFlag{
Name: "kube-context", Name: "kube-context",
Usage: "Set kubectl context", Usage: "Set kubectl context. Uses current context by default",
}, },
} }

View File

@ -7,6 +7,7 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"sync" "sync"
"errors"
"github.com/roboll/helmfile/helmexec" "github.com/roboll/helmfile/helmexec"
@ -164,7 +165,12 @@ func flagsForChart(chart *ChartSpec) ([]string, error) {
if len(chart.EnvValues) > 0 { if len(chart.EnvValues) > 0 {
val := []string{} val := []string{}
for _, set := range chart.EnvValues { for _, set := range chart.EnvValues {
val = append(val, fmt.Sprintf("%s=%s", set.Name, os.Getenv(set.Value))) value, isSet := os.LookupEnv(set.Value)
if isSet {
val = append(val, fmt.Sprintf("%s=%s", set.Name, value))
} else {
return nil, errors.New(fmt.Sprintf("Unset env var: %s", set.Name))
}
} }
flags = append(flags, "--set", strings.Join(val, ",")) flags = append(flags, "--set", strings.Join(val, ","))
} }