diff --git a/README.md b/README.md index d10a4ca4..e571cac8 100644 --- a/README.md +++ b/README.md @@ -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 +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 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 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 -`.sops.yaml` file to configure the method of encryption (this can be in the same directory as your helmfile or +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 in the sub-directory containing your secrets files). Then suppose you have a a foo.bar secret defined in `environments/production/secrets.yaml`: diff --git a/state/state.go b/state/state.go index d00b3d3f..6697f572 100644 --- a/state/state.go +++ b/state/state.go @@ -3,7 +3,6 @@ package state import ( "errors" "fmt" - "github.com/roboll/helmfile/helmexec" "io/ioutil" "os" "path" @@ -12,6 +11,8 @@ import ( "strconv" "strings" + "github.com/roboll/helmfile/helmexec" + "regexp" "os/exec" @@ -747,8 +748,12 @@ func (st *HelmState) FilterReleases(labels []string) error { if r.Labels == nil { 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["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 { if r.Labels == nil { r.Labels = map[string]string{}