support labels for namespace and chart (#459)

This commit is contained in:
Shane Starcher 2019-01-30 18:25:29 -08:00 committed by KUOKA Yusuke
parent abeccc5e8e
commit fb256b0161
2 changed files with 11 additions and 4 deletions

View File

@ -295,6 +295,8 @@ The `selector` parameter can be specified multiple times. Each parameter is reso
`--selector tier=frontend --selector tier=backend` will select all the charts `--selector tier=frontend --selector tier=backend` will select all the charts
In addition to user supplied labels the name, namespace, and chart are available to be used as selectors. The chart will just be the chart name excluding the repository (Example `stable/filebeat` would be selected using `--selector chart=filebeat`).
## Templates ## Templates
You can use go's text/template expressions in `helmfile.yaml` and `values.yaml.gotmpl` (templated helm values files). `values.yaml` references will be used verbatim. In other words: You can use go's text/template expressions in `helmfile.yaml` and `values.yaml.gotmpl` (templated helm values files). `values.yaml` references will be used verbatim. In other words:
@ -493,8 +495,8 @@ Environment Secrets (not to be confused with Kubernetes Secrets) are encrypted v
You can list any number of `secrets.yaml` files created using `helm secrets` or `sops`, so that You can list any number of `secrets.yaml` files created using `helm secrets` or `sops`, so that
Helmfile could automatically decrypt and merge the secrets into the environment values. Helmfile could automatically decrypt and merge the secrets into the environment values.
First you must have the [helm-secrets](https://github.com/futuresimple/helm-secrets) plugin installed along with a First you must have the [helm-secrets](https://github.com/futuresimple/helm-secrets) plugin installed along with a
`.sops.yaml` file to configure the method of encryption (this can be in the same directory as your helmfile or `.sops.yaml` file to configure the method of encryption (this can be in the same directory as your helmfile or
in the sub-directory containing your secrets files). in the sub-directory containing your secrets files).
Then suppose you have a a foo.bar secret defined in `environments/production/secrets.yaml`: Then suppose you have a a foo.bar secret defined in `environments/production/secrets.yaml`:

View File

@ -3,7 +3,6 @@ package state
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/roboll/helmfile/helmexec"
"io/ioutil" "io/ioutil"
"os" "os"
"path" "path"
@ -12,6 +11,8 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/roboll/helmfile/helmexec"
"regexp" "regexp"
"os/exec" "os/exec"
@ -747,8 +748,12 @@ func (st *HelmState) FilterReleases(labels []string) error {
if r.Labels == nil { if r.Labels == nil {
r.Labels = map[string]string{} r.Labels = map[string]string{}
} }
// Let the release name be used as a tag // Let the release name, namespace, and chart be used as a tag
r.Labels["name"] = r.Name r.Labels["name"] = r.Name
r.Labels["namespace"] = r.Namespace
// Strip off just the last portion for the name stable/newrelic would give newrelic
chartSplit := strings.Split(r.Chart, "/")
r.Labels["chart"] = chartSplit[len(chartSplit)-1]
for _, f := range filters { for _, f := range filters {
if r.Labels == nil { if r.Labels == nil {
r.Labels = map[string]string{} r.Labels = map[string]string{}