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
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:

View File

@ -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{}