Hello community, here is the log from the commit of package helmfile for openSUSE:Factory checked in at 2020-11-19 16:46:22 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/helmfile (Old) and /work/SRC/openSUSE:Factory/.helmfile.new.5913 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "helmfile" Thu Nov 19 16:46:22 2020 rev:13 rq:849359 version:0.135.0 Changes: -------- --- /work/SRC/openSUSE:Factory/helmfile/helmfile.changes 2020-11-11 20:46:21.819644812 +0100 +++ /work/SRC/openSUSE:Factory/.helmfile.new.5913/helmfile.changes 2020-11-23 10:30:18.001348763 +0100 @@ -1,0 +2,20 @@ +Thu Nov 19 09:42:48 UTC 2020 - Manfred Hollstein <[email protected]> + +- v0.135.0: Add support for Kustomize Transformers (#1592) + * b910591 (HEAD, tag: v0.135.0, origin/master, origin/HEAD, master) + Add support for Kustomize Transformers (#1592) + * d807510 Enable shell completion (#1559) + * 4e48521 Fix the logic of helmfile deps and add tests. (#1588) + * b0e0429 Fix incorrect help text of some CLI options. (#1587) + * f877de7 Fix openSUSE repo URL. (#1584) + * 655d593 Mention about helmBinary in readme (#1590) + +- v0.134.1: Fix `helmfile template --include-crds` not to break with + `chartify` (… + * f6bf885 (HEAD, tag: v0.134.1, origin/master, origin/HEAD, master) + Fix helmfile template --include-crds not to break with chartify (#1583) + * 2857382 fix: support arm binaries (#1580) + * 972667f Mention openSUSE packages for helmfile (#1581) + * 3c88145 Update readme stable/incubator URLs (#1582) + +------------------------------------------------------------------- Old: ---- helmfile-0.134.0.tar.gz New: ---- helmfile-0.135.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ helmfile.spec ++++++ --- /var/tmp/diff_new_pack.k9GkYL/_old 2020-11-23 10:30:18.993349851 +0100 +++ /var/tmp/diff_new_pack.k9GkYL/_new 2020-11-23 10:30:18.993349851 +0100 @@ -16,9 +16,9 @@ # Please submit bugfixes or comments via https://bugs.opensuse.org/ # -%define git_commit 709913b5eac85033effea3d4f05ad37c255f97bc +%define git_commit b910591e1d08973f9a73951f41c3e0b028d475a8 Name: helmfile -Version: 0.134.0 +Version: 0.135.0 Release: 0 Summary: Deploy Kubernetes Helm Charts License: MIT ++++++ _service ++++++ --- /var/tmp/diff_new_pack.k9GkYL/_old 2020-11-23 10:30:19.037349899 +0100 +++ /var/tmp/diff_new_pack.k9GkYL/_new 2020-11-23 10:30:19.041349904 +0100 @@ -5,7 +5,7 @@ <param name="exclude">.git</param> <param name="versionformat">@PARENT_TAG@</param> <param name="versionrewrite-pattern">v(.*)</param> - <param name="revision">v0.134.0</param> + <param name="revision">v0.135.0</param> <param name="changesgenerate">enable</param> </service> <service name="recompress" mode="disabled"> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.k9GkYL/_old 2020-11-23 10:30:19.061349926 +0100 +++ /var/tmp/diff_new_pack.k9GkYL/_new 2020-11-23 10:30:19.061349926 +0100 @@ -1,4 +1,4 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/roboll/helmfile.git</param> - <param name="changesrevision">709913b5eac85033effea3d4f05ad37c255f97bc</param></service></servicedata> + <param name="changesrevision">b910591e1d08973f9a73951f41c3e0b028d475a8</param></service></servicedata> ++++++ helmfile-0.134.0.tar.gz -> helmfile-0.135.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.134.0/Makefile new/helmfile-0.135.0/Makefile --- old/helmfile-0.134.0/Makefile 2020-11-09 00:50:00.000000000 +0100 +++ new/helmfile-0.135.0/Makefile 2020-11-19 01:33:05.000000000 +0100 @@ -30,7 +30,7 @@ .PHONY: integration cross: - env CGO_ENABLED=0 gox -os '!openbsd !freebsd !netbsd' -arch '!arm !mips !mipsle !mips64 !mips64le !s390x' -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}" -ldflags '-X github.com/roboll/helmfile/pkg/app/version.Version=${TAG}' ${TARGETS} + env CGO_ENABLED=0 gox -os '!openbsd !freebsd !netbsd' -arch '!mips !mipsle !mips64 !mips64le !s390x' -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}" -ldflags '-X github.com/roboll/helmfile/pkg/app/version.Version=${TAG}' ${TARGETS} .PHONY: cross static-linux: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.134.0/README.md new/helmfile-0.135.0/README.md --- old/helmfile-0.134.0/README.md 2020-11-09 00:50:00.000000000 +0100 +++ new/helmfile-0.135.0/README.md 2020-11-19 01:33:05.000000000 +0100 @@ -47,10 +47,10 @@ repositories: # To use official "stable" charts a.k.a https://github.com/helm/charts/tree/master/stable - name: stable - url: https://kubernetes-charts.storage.googleapis.com + url: https://charts.helm.sh/stable # To use official "incubator" charts a.k.a https://github.com/helm/charts/tree/master/incubator - name: incubator - url: https://kubernetes-charts-incubator.storage.googleapis.com + url: https://charts.helm.sh/incubator # helm-git powered repository: You can treat any Git repository as a charts repository - name: polaris url: git+https://github.com/reactiveops/polaris@deploy/helm?ref=master @@ -69,6 +69,9 @@ # context: kube-context # this directive is deprecated, please consider using helmDefaults.kubeContext +# Path to alternative helm binary (--helm-binary) +helmBinary: path/to/helm3 + # Default values to set for args along with dedicated keys that can be set by contributors, cli args take precedence over these. # In other words, unset values results in no flags passed to helm. # See the helm usage (helm SUBCOMMAND -h) for more info on default values when those flags aren't provided. @@ -363,7 +366,8 @@ - download one of [releases](https://github.com/roboll/helmfile/releases) or - run as a [container](https://quay.io/roboll/helmfile) or -- Archlinux: install via `pacman -S helmfile` or from [AUR](https://aur.archlinux.org/packages/kubernetes-helmfile-bin/) +- Archlinux: install via `pacman -S helmfile` or from [AUR](https://aur.archlinux.org/packages/kubernetes-helmfile-bin/) or +- openSUSE: install via `zypper in helmfile` assuming you are on Tumbleweed; if you are on Leap you must add the [kubic](https://download.opensuse.org/repositories/devel:/kubic/) repo for your distribution version once before that command, e.g. `zypper ar https://download.opensuse.org/repositories/devel:/kubic/openSUSE_Leap_\$releasever kubic`, or - Windows (using [scoop](https://scoop.sh/)): `scoop install helmfile` - macOS (using [homebrew](https://brew.sh/)): `brew install helmfile` @@ -1188,6 +1192,10 @@ If you want to enable all experimental features set the env var to `HELMFILE_EXPERIMENTAL=true` +## `bash` and `zsh` completion + +Copy `autocomplete/helmfile_bash_autocomplete` or `autocomplete/helmfile_zsh_autocomplete` (depending on your shell of choice) to directory where you keep other shell completion scripts to make sure it is sourced. + ## Examples For more examples, see the [examples/README.md](https://github.com/roboll/helmfile/blob/master/examples/README.md) or the [`helmfile`](https://github.com/cloudposse/helmfiles/tree/master/releases) distribution by [Cloud Posse](https://github.com/cloudposse/). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.134.0/autocomplete/helmfile_bash_autocomplete new/helmfile-0.135.0/autocomplete/helmfile_bash_autocomplete --- old/helmfile-0.134.0/autocomplete/helmfile_bash_autocomplete 1970-01-01 01:00:00.000000000 +0100 +++ new/helmfile-0.135.0/autocomplete/helmfile_bash_autocomplete 2020-11-19 01:33:05.000000000 +0100 @@ -0,0 +1,18 @@ +#! /bin/bash + +_helmfile_bash_autocomplete() { + if [[ "${COMP_WORDS[0]}" != "source" ]]; then + local cur opts base + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + if [[ "$cur" == "-"* ]]; then + opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion ) + else + opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) + fi + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + fi +} + +complete -o bashdefault -o default -o nospace -F _helmfile_bash_autocomplete helmfile diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.134.0/autocomplete/helmfile_zsh_autocomplete new/helmfile-0.135.0/autocomplete/helmfile_zsh_autocomplete --- old/helmfile-0.134.0/autocomplete/helmfile_zsh_autocomplete 1970-01-01 01:00:00.000000000 +0100 +++ new/helmfile-0.135.0/autocomplete/helmfile_zsh_autocomplete 2020-11-19 01:33:05.000000000 +0100 @@ -0,0 +1,23 @@ +#compdef helmfile + +_helmfile_zsh_autocomplete() { + + local -a opts + local cur + cur=${words[-1]} + if [[ "$cur" == "-"* ]]; then + opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}") + else + opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}") + fi + + if [[ "${opts[1]}" != "" ]]; then + _describe 'values' opts + else + _files + fi + + return +} + +compdef _helmfile_zsh_autocomplete helmfile diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.134.0/docs/advanced-features.md new/helmfile-0.135.0/docs/advanced-features.md --- old/helmfile-0.134.0/docs/advanced-features.md 2020-11-09 00:50:00.000000000 +0100 +++ new/helmfile-0.135.0/docs/advanced-features.md 2020-11-19 01:33:05.000000000 +0100 @@ -1,6 +1,8 @@ ## Advanced Features - [Import Configuration Parameters into Helmfile](#import-configuration-parameters-into-helmfile) +- [Deploy Kustomization with Helmfile](#deploy-kustomizations-with-helmfile) +- [Adhoc Kustomization of Helm Charts](#adhoc-kustomization-of-helm-charts) ### Import Configuration Parameters into Helmfile @@ -35,7 +37,7 @@ $ TMPKUSTOMIZATION=/tmp/sometmpdir2 $ somehow_generate_temp_kustomization_yaml ${TMPKUSTOMIZATION}/kustomization.yaml -$ kustomize build ${TMPKUSTOMIZATION}/kustomization.yaml > ${TMPCHART}/templates/all.yaml +$ kustomize build ${TMPKUSTOMIZATION}/kustomization.yaml > ${TMPCHART}/templates/all.yaml ``` Let's say you have a `helmfile.yaml` that looks like the below: @@ -57,7 +59,7 @@ Followed by the below steps: -- Running `kustomize edit set image $IMAGE` for every `$IMAGE` generated from your values.yaml +- Running `kustomize edit set image $IMAGE` for every `$IMAGE` generated from your values.yaml - Running `kustomize edit set nameprefix $NAMEPREFIX` with the nameprefix specified in your values.yaml - Running `kustomize edit set namesuffix $NAMESUFFIX` with the namesuffix specified in your values.yaml - Running `kustomize edit set namespace $NS` with the namespace specified in your values.yaml @@ -92,7 +94,17 @@ Please also see [test/advanced/helmfile.yaml](https://github.com/roboll/helmfile/tree/master/test/advanced/helmfile.yaml) for an example of kustomization support and more. -## Adhoc Customization of Helm charts +### Adhoc Kustomization of Helm charts + +With Helmfile's integration with Helmfile, not only deploying Kustomization as a Helm chart, you can kustomize charts before installation. + +Currently, Helmfile allows you to set the following fields for kustomizing the chart: + +- [`releases[].strategicMergePatches`](#strategicmergepatches) +- `releases[].jsonPatches` +- [`releases[].transformers`](#transformers) + +#### `strategicMergePatches` You can add/update any Kubernetes resource field rendered from a Helm chart by specifying `releases[].strategicMergePatches`: @@ -135,3 +147,65 @@ There's also `releases[].jsonPatches` that works similarly to `strategicMergePatches` but has additional capability to remove fields. Please also see [test/advanced/helmfile.yaml](https://github.com/roboll/helmfile/tree/master/test/advanced/helmfile.yaml) for an example of patching support and more. + +#### `transformers` + +You can set `transformers` to apply [Kustomize's transformers](https://github.com/kubernetes-sigs/kustomize/blob/master/examples/configureBuiltinPlugin.md#configuring-the-builtin-plugins-instead). + +Each item can be a path to a YAML or go template file, or an embedded transformer declaration as a YAML hash. + +It's often used to add common labels and annotations to your resources. + +In the below example. we add common annotations and labels every resource rendered from the `aws-load-balancer-controller` chart: + +```yaml +releases: +- name: "aws-load-balancer-controller" + namespace: "kube-system" + forceNamespace: "kube-system" + chart: "center/aws/aws-load-balancer-controller" + transformers: + - apiVersion: builtin + kind: AnnotationsTransformer + metadata: + name: notImportantHere + annotations: + area: 51 + greeting: take me to your leader + fieldSpecs: + - path: metadata/annotations + create: true + - apiVersion: builtin + kind: LabelTransformer + metadata: + name: notImportantHere + labels: + foo: bar + fieldSpecs: + - path: metadata/labels + create: true +``` + +As explained earlier, `transformers` can be not only a list of embedded transformers, but also YAML or go template files, or a mix of those three kinds. + +```yaml +transformers: +# Embedded transformer +- apiVersion: builtin + kind: AnnotationsTransformer + metadata: + name: notImportantHere + annotations: + area: 51 + greeting: take me to your leader + fieldSpecs: + - path: metadata/annotations + create: true +# YAML file +- path/to/transformer.yaml +# Go template +# The same set of template parameters as release values files templates is available. +- path/to/transformer.yaml.gotmpl +``` + +Please see https://github.com/kubernetes-sigs/kustomize/blob/master/examples/configureBuiltinPlugin.md#configuring-the-builtin-plugins-instead for more information on how to declare transformers. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.134.0/go.mod new/helmfile-0.135.0/go.mod --- old/helmfile-0.134.0/go.mod 2020-11-09 00:50:00.000000000 +0100 +++ new/helmfile-0.135.0/go.mod 2020-11-19 01:33:05.000000000 +0100 @@ -23,7 +23,7 @@ github.com/spf13/cobra v1.1.1 github.com/tatsushid/go-prettytable v0.0.0-20141013043238-ed2d14c29939 github.com/urfave/cli v1.22.5 - github.com/variantdev/chartify v0.4.8 + github.com/variantdev/chartify v0.5.0 github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363 github.com/variantdev/vals v0.11.0 go.uber.org/multierr v1.6.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.134.0/go.sum new/helmfile-0.135.0/go.sum --- old/helmfile-0.134.0/go.sum 2020-11-09 00:50:00.000000000 +0100 +++ new/helmfile-0.135.0/go.sum 2020-11-19 01:33:05.000000000 +0100 @@ -620,8 +620,10 @@ github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU= github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/variantdev/chartify v0.4.8 h1:bQAlp9N1qiyG29bn39r51g1bBuDJrYdT9zxT303PhbM= -github.com/variantdev/chartify v0.4.8/go.mod h1:Fr4oPNJ4b19knlovn0wBoU2+MZxQdBacmBs30wwgAFk= +github.com/variantdev/chartify v0.4.9 h1:06foIMnJj31q/l1JZ+54anDLwqtP8zAOv5qVEn2IQhM= +github.com/variantdev/chartify v0.4.9/go.mod h1:jqlUJIzcrIVSfg8FC4g+IoC5WB83TBl8rnVVEv6g8MQ= +github.com/variantdev/chartify v0.5.0 h1:I6T6oobjLfYmwZ4dUjRsO9AdGKPCMtfzt0CXR0ovl9k= +github.com/variantdev/chartify v0.5.0/go.mod h1:jqlUJIzcrIVSfg8FC4g+IoC5WB83TBl8rnVVEv6g8MQ= github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363 h1:KrfQBEUn+wEOQ/6UIfoqRDvn+Q/wZridQ7t0G1vQqKE= github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363/go.mod h1:pH1TQsNSLj2uxMo9NNl9zdGy01Wtn+/2MT96BrKmVyE= github.com/variantdev/vals v0.11.0 h1:818ztGk5yPTiixbUeE3LkkBGGATEAKtWq09n8q8PFqc= @@ -1007,8 +1009,6 @@ gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.134.0/main.go new/helmfile-0.135.0/main.go --- old/helmfile-0.134.0/main.go 2020-11-09 00:50:00.000000000 +0100 +++ new/helmfile-0.135.0/main.go 2020-11-19 01:33:05.000000000 +0100 @@ -42,6 +42,7 @@ cliApp.Name = "helmfile" cliApp.Usage = "" cliApp.Version = version.Version + cliApp.EnableBashCompletion = true cliApp.Flags = []cli.Flag{ cli.StringFlag{ Name: "helm-binary, b", @@ -54,7 +55,7 @@ }, cli.StringFlag{ Name: "environment, e", - Usage: "specify the environment name. defaults to `default`", + Usage: `specify the environment name. defaults to "default"`, }, cli.StringSliceFlag{ Name: "state-values-set", @@ -109,7 +110,7 @@ cliApp.Commands = []cli.Command{ { Name: "deps", - Usage: "update charts based on the contents of requirements.yaml", + Usage: "update charts based on their requirements", Flags: []cli.Flag{ cli.StringFlag{ Name: "args", @@ -118,7 +119,7 @@ }, cli.BoolFlag{ Name: "skip-repos", - Usage: "skip running `helm repo update` before running `helm dependency build`", + Usage: `skip running "helm repo update" before running "helm dependency build"`, }, }, Action: action(func(run *app.App, c configImpl) error { @@ -185,7 +186,7 @@ }, cli.BoolFlag{ Name: "skip-deps", - Usage: "skip running `helm repo update` and `helm dependency build`", + Usage: `skip running "helm repo update" and "helm dependency build"`, }, cli.BoolFlag{ Name: "detailed-exitcode", @@ -254,7 +255,7 @@ }, cli.BoolFlag{ Name: "skip-deps", - Usage: "skip running `helm repo update` and `helm dependency build`", + Usage: `skip running "helm repo update" and "helm dependency build"`, }, cli.BoolFlag{ Name: "skip-cleanup", @@ -288,7 +289,7 @@ }, cli.BoolFlag{ Name: "skip-deps", - Usage: "skip running `helm repo update` and `helm dependency build`", + Usage: `skip running "helm repo update" and "helm dependency build"`, }, }, Action: action(func(run *app.App, c configImpl) error { @@ -319,7 +320,7 @@ }, cli.BoolFlag{ Name: "skip-deps", - Usage: "skip running `helm repo update` and `helm dependency build`", + Usage: `skip running "helm repo update" and "helm dependency build"`, }, }, Action: action(func(run *app.App, c configImpl) error { @@ -350,7 +351,7 @@ }, cli.BoolFlag{ Name: "skip-deps", - Usage: "skip running `helm repo update` and `helm dependency build`", + Usage: `skip running "helm repo update" and "helm dependency build"`, }, }, Action: action(func(run *app.App, c configImpl) error { @@ -410,7 +411,7 @@ }, cli.BoolFlag{ Name: "skip-deps", - Usage: "skip running `helm repo update` and `helm dependency build`", + Usage: `skip running "helm repo update" and "helm dependency build"`, }, }, Action: action(func(run *app.App, c configImpl) error { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.134.0/pkg/app/app.go new/helmfile-0.135.0/pkg/app/app.go --- old/helmfile-0.134.0/pkg/app/app.go 2020-11-09 00:50:00.000000000 +0100 +++ new/helmfile-0.135.0/pkg/app/app.go 2020-11-19 01:33:05.000000000 +0100 @@ -105,6 +105,7 @@ return a.ForEachState(func(run *Run) (_ bool, errs []error) { prepErr := run.withPreparedCharts("deps", state.ChartPrepareOptions{ SkipRepos: c.SkipRepos(), + SkipDeps: true, SkipResolve: true, }, func() { errs = run.Deps(c) @@ -122,7 +123,10 @@ return a.ForEachState(func(run *Run) (_ bool, errs []error) { var reposErr error - err := run.withPreparedCharts("repos", state.ChartPrepareOptions{SkipRepos: true}, func() { + err := run.withPreparedCharts("repos", state.ChartPrepareOptions{ + SkipRepos: true, + SkipDeps: true, + }, func() { reposErr = run.Repos(c) }) @@ -140,7 +144,10 @@ func (a *App) DeprecatedSyncCharts(c DeprecatedChartsConfigProvider) error { return a.ForEachState(func(run *Run) (_ bool, errs []error) { - err := run.withPreparedCharts("charts", state.ChartPrepareOptions{SkipRepos: true}, func() { + err := run.withPreparedCharts("charts", state.ChartPrepareOptions{ + SkipRepos: true, + SkipDeps: true, + }, func() { errs = run.DeprecatedSyncCharts(c) }) @@ -166,7 +173,10 @@ var errs []error - prepErr := run.withPreparedCharts("diff", state.ChartPrepareOptions{SkipRepos: c.SkipDeps()}, func() { + prepErr := run.withPreparedCharts("diff", state.ChartPrepareOptions{ + SkipRepos: c.SkipDeps(), + SkipDeps: c.SkipDeps(), + }, func() { msg, matched, affected, errs = a.diff(run, c) }) @@ -227,6 +237,7 @@ prepErr := run.withPreparedCharts("template", state.ChartPrepareOptions{ ForceDownload: !run.helm.IsHelm3(), SkipRepos: c.SkipDeps(), + SkipDeps: c.SkipDeps(), }, func() { ok, errs = a.template(run, c) }) @@ -246,6 +257,7 @@ prepErr := run.withPreparedCharts("write-values", state.ChartPrepareOptions{ ForceDownload: !run.helm.IsHelm3(), SkipRepos: c.SkipDeps(), + SkipDeps: c.SkipDeps(), }, func() { ok, errs = a.writeValues(run, c) }) @@ -264,6 +276,7 @@ prepErr := run.withPreparedCharts("lint", state.ChartPrepareOptions{ ForceDownload: true, SkipRepos: c.SkipDeps(), + SkipDeps: c.SkipDeps(), }, func() { errs = run.Lint(c) }) @@ -280,6 +293,7 @@ return a.ForEachState(func(run *Run) (ok bool, errs []error) { prepErr := run.withPreparedCharts("sync", state.ChartPrepareOptions{ SkipRepos: c.SkipDeps(), + SkipDeps: c.SkipDeps(), }, func() { ok, errs = a.sync(run, c) }) @@ -304,6 +318,7 @@ err := a.ForEachState(func(run *Run) (ok bool, errs []error) { prepErr := run.withPreparedCharts("apply", state.ChartPrepareOptions{ SkipRepos: c.SkipDeps(), + SkipDeps: c.SkipDeps(), }, func() { matched, updated, es := a.apply(run, c) @@ -338,6 +353,7 @@ return a.ForEachState(func(run *Run) (_ bool, errs []error) { err := run.withPreparedCharts("status", state.ChartPrepareOptions{ SkipRepos: true, + SkipDeps: true, }, func() { errs = run.Status(c) }) @@ -354,6 +370,7 @@ return a.ForEachState(func(run *Run) (ok bool, errs []error) { err := run.withPreparedCharts("delete", state.ChartPrepareOptions{ SkipRepos: true, + SkipDeps: true, }, func() { ok, errs = a.delete(run, c.Purge(), c) }) @@ -370,6 +387,7 @@ return a.ForEachState(func(run *Run) (ok bool, errs []error) { err := run.withPreparedCharts("destroy", state.ChartPrepareOptions{ SkipRepos: true, + SkipDeps: true, }, func() { ok, errs = a.delete(run, true, c) }) @@ -392,6 +410,7 @@ err := run.withPreparedCharts("test", state.ChartPrepareOptions{ SkipRepos: true, + SkipDeps: true, }, func() { errs = a.test(run, c) }) @@ -408,6 +427,7 @@ return a.ForEachState(func(run *Run) (_ bool, errs []error) { err := run.withPreparedCharts("build", state.ChartPrepareOptions{ SkipRepos: true, + SkipDeps: true, }, func() { if c.EmbedValues() { for i := range run.state.Releases { @@ -456,6 +476,7 @@ err := a.ForEachState(func(run *Run) (_ bool, errs []error) { err := run.withPreparedCharts("list", state.ChartPrepareOptions{ SkipRepos: true, + SkipDeps: true, }, func() { //var releases m @@ -587,14 +608,15 @@ } ld := &desiredStateLoader{ - readFile: a.readFile, - deleteFile: a.deleteFile, - fileExists: a.fileExists, - env: a.Env, - namespace: a.Namespace, - logger: a.Logger, - abs: a.abs, - remote: a.remote, + readFile: a.readFile, + deleteFile: a.deleteFile, + fileExists: a.fileExists, + directoryExistsAt: a.directoryExistsAt, + env: a.Env, + namespace: a.Namespace, + logger: a.Logger, + abs: a.abs, + remote: a.remote, overrideKubeContext: a.OverrideKubeContext, overrideHelmBinary: a.OverrideHelmBinary, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.134.0/pkg/app/app_test.go new/helmfile-0.135.0/pkg/app/app_test.go --- old/helmfile-0.134.0/pkg/app/app_test.go 2020-11-09 00:50:00.000000000 +0100 +++ new/helmfile-0.135.0/pkg/app/app_test.go 2020-11-19 01:33:05.000000000 +0100 @@ -2380,6 +2380,18 @@ return a.retainValuesFiles } +type depsConfig struct { + skipRepos bool +} + +func (d depsConfig) SkipRepos() bool { + return d.skipRepos +} + +func (d depsConfig) Args() string { + return "" +} + // Mocking the command-line runner type mockRunner struct { @@ -3949,6 +3961,147 @@ } }() + if tc.log != "" { + actual := bs.String() + + diff, exists := testhelper.Diff(tc.log, actual, 3) + if exists { + t.Errorf("unexpected log for data defined %s:\nDIFF\n%s\nEOD", tc.loc, diff) + } + } + }) + } +} + +func TestDeps(t *testing.T) { + testcases := []struct { + name string + loc string + error string + files map[string]string + log string + charts []string + }{ + // + // complex test cases for smoke testing + // + { + name: "smoke", + loc: location(), + files: map[string]string{ + "/path/to/helmfile.yaml": ` +repositories: +- name: bitnami + url: https://charts.bitnami.com/bitnami/ +releases: +- name: example + chart: /path/to/charts/example +`, + "/path/to/charts/example/Chart.yaml": `foo: FOO`, + }, + log: `processing file "helmfile.yaml" in directory "." +first-pass rendering starting for "helmfile.yaml.part.0": inherited=&{default map[] map[]}, overrode=<nil> +first-pass uses: &{default map[] map[]} +first-pass rendering output of "helmfile.yaml.part.0": + 0: + 1: repositories: + 2: - name: bitnami + 3: url: https://charts.bitnami.com/bitnami/ + 4: releases: + 5: - name: example + 6: chart: /path/to/charts/example + 7: + +first-pass produced: &{default map[] map[]} +first-pass rendering result of "helmfile.yaml.part.0": {default map[] map[]} +vals: +map[] +defaultVals:[] +second-pass rendering result of "helmfile.yaml.part.0": + 0: + 1: repositories: + 2: - name: bitnami + 3: url: https://charts.bitnami.com/bitnami/ + 4: releases: + 5: - name: example + 6: chart: /path/to/charts/example + 7: + +merged environment: &{default map[] map[]} +There are no repositories defined in your helmfile.yaml. +This means helmfile cannot update your dependencies or create a lock file. +See https://github.com/roboll/helmfile/issues/878 for more information. +`, + charts: []string{"/path/to/charts/example"}, + }, + } + + for i := range testcases { + tc := testcases[i] + t.Run(tc.name, func(t *testing.T) { + + var helm = &exectest.Helm{ + DiffMutex: &sync.Mutex{}, + ChartsMutex: &sync.Mutex{}, + ReleasesMutex: &sync.Mutex{}, + } + + bs := &bytes.Buffer{} + + func() { + logReader, logWriter := io.Pipe() + + logFlushed := &sync.WaitGroup{} + // Ensure all the log is consumed into `bs` by calling `logWriter.Close()` followed by `logFlushed.Wait()` + logFlushed.Add(1) + go func() { + scanner := bufio.NewScanner(logReader) + for scanner.Scan() { + bs.Write(scanner.Bytes()) + bs.WriteString("\n") + } + logFlushed.Done() + }() + + defer func() { + // This is here to avoid data-trace on bytes buffer `bs` to capture logs + if err := logWriter.Close(); err != nil { + panic(err) + } + logFlushed.Wait() + }() + + logger := helmexec.NewLogger(logWriter, "debug") + + app := appWithFs(&App{ + OverrideHelmBinary: DefaultHelmBinary, + glob: filepath.Glob, + abs: filepath.Abs, + OverrideKubeContext: "default", + Env: "default", + Logger: logger, + helms: map[helmKey]helmexec.Interface{ + createHelmKey("helm", "default"): helm, + }, + }, tc.files) + + depsErr := app.Deps(depsConfig{ + skipRepos: false, + }) + + if tc.error == "" && depsErr != nil { + t.Fatalf("unexpected error for data defined at %s: %v", tc.loc, depsErr) + } else if tc.error != "" && depsErr == nil { + t.Fatalf("expected error did not occur for data defined at %s", tc.loc) + } else if tc.error != "" && depsErr != nil && tc.error != depsErr.Error() { + t.Fatalf("invalid error: expected %q, got %q", tc.error, depsErr.Error()) + } + + if !reflect.DeepEqual(helm.Charts, tc.charts) { + t.Fatalf("expected charts %v, got %v", helm.Charts, tc.charts) + } + }() + if tc.log != "" { actual := bs.String() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.134.0/pkg/app/desired_state_file_loader.go new/helmfile-0.135.0/pkg/app/desired_state_file_loader.go --- old/helmfile-0.134.0/pkg/app/desired_state_file_loader.go 2020-11-09 00:50:00.000000000 +0100 +++ new/helmfile-0.135.0/pkg/app/desired_state_file_loader.go 2020-11-19 01:33:05.000000000 +0100 @@ -4,6 +4,8 @@ "bytes" "errors" "fmt" + "path/filepath" + "github.com/imdario/mergo" "github.com/roboll/helmfile/pkg/environment" "github.com/roboll/helmfile/pkg/helmexec" @@ -11,7 +13,6 @@ "github.com/roboll/helmfile/pkg/state" "github.com/variantdev/vals" "go.uber.org/zap" - "path/filepath" ) const ( @@ -25,12 +26,13 @@ env string namespace string - readFile func(string) ([]byte, error) - deleteFile func(string) error - fileExists func(string) (bool, error) - abs func(string) (string, error) - glob func(string) ([]string, error) - getHelm func(*state.HelmState) helmexec.Interface + readFile func(string) ([]byte, error) + deleteFile func(string) error + fileExists func(string) (bool, error) + abs func(string) (string, error) + glob func(string) ([]string, error) + directoryExistsAt func(string) bool + getHelm func(*state.HelmState) helmexec.Interface remote *remote.Remote logger *zap.SugaredLogger @@ -144,7 +146,7 @@ } func (a *desiredStateLoader) underlying() *state.StateCreator { - c := state.NewCreator(a.logger, a.readFile, a.fileExists, a.abs, a.glob, a.valsRuntime, a.getHelm, a.overrideHelmBinary, a.remote) + c := state.NewCreator(a.logger, a.readFile, a.fileExists, a.abs, a.glob, a.directoryExistsAt, a.valsRuntime, a.getHelm, a.overrideHelmBinary, a.remote) c.DeleteFile = a.deleteFile c.LoadFile = a.loadFile return c diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.134.0/pkg/remote/remote_test.go new/helmfile-0.135.0/pkg/remote/remote_test.go --- old/helmfile-0.134.0/pkg/remote/remote_test.go 2020-11-09 00:50:00.000000000 +0100 +++ new/helmfile-0.135.0/pkg/remote/remote_test.go 2020-11-19 01:33:05.000000000 +0100 @@ -2,19 +2,20 @@ import ( "fmt" + "os" + "testing" + "github.com/google/go-cmp/cmp" "github.com/roboll/helmfile/pkg/helmexec" "github.com/roboll/helmfile/pkg/testhelper" - "os" - "testing" ) func TestRemote_HttpsGitHub(t *testing.T) { cleanfs := map[string]string{ - "path/to/home": "", + "/path/to/home": "", } cachefs := map[string]string{ - "path/to/home/.helmfile/cache/https_github_com_cloudposse_helmfiles_git.ref=0.40.0/releases/kiam.yaml": "foo: bar", + "/path/to/home/.helmfile/cache/https_github_com_cloudposse_helmfiles_git.ref=0.40.0/releases/kiam.yaml": "foo: bar", } type testcase struct { @@ -36,7 +37,7 @@ hit := true get := func(wd, src, dst string) error { - if wd != "path/to/home" { + if wd != "/path/to/home" { return fmt.Errorf("unexpected wd: %s", wd) } if src != "git::https://github.com/cloudposse/helmfiles.git?ref=0.40.0" { @@ -53,7 +54,7 @@ } remote := &Remote{ Logger: helmexec.NewLogger(os.Stderr, "debug"), - Home: "path/to/home", + Home: "/path/to/home", Getter: getter, ReadFile: testfs.ReadFile, FileExists: testfs.FileExistsAt, @@ -72,7 +73,7 @@ t.Fatalf("unexpected error: %v", err) } - if file != "path/to/home/.helmfile/cache/https_github_com_cloudposse_helmfiles_git.ref=0.40.0/releases/kiam.yaml" { + if file != "/path/to/home/.helmfile/cache/https_github_com_cloudposse_helmfiles_git.ref=0.40.0/releases/kiam.yaml" { t.Errorf("unexpected file located: %s", file) } @@ -88,10 +89,10 @@ func TestRemote_SShGitHub(t *testing.T) { cleanfs := map[string]string{ - "path/to/home": "", + "/path/to/home": "", } cachefs := map[string]string{ - "path/to/home/.helmfile/cache/ssh_github_com_cloudposse_helmfiles_git.ref=0.40.0/releases/kiam.yaml": "foo: bar", + "/path/to/home/.helmfile/cache/ssh_github_com_cloudposse_helmfiles_git.ref=0.40.0/releases/kiam.yaml": "foo: bar", } type testcase struct { @@ -113,7 +114,7 @@ hit := true get := func(wd, src, dst string) error { - if wd != "path/to/home" { + if wd != "/path/to/home" { return fmt.Errorf("unexpected wd: %s", wd) } if src != "git::ssh://[email protected]/cloudposse/helmfiles.git?ref=0.40.0" { @@ -130,7 +131,7 @@ } remote := &Remote{ Logger: helmexec.NewLogger(os.Stderr, "debug"), - Home: "path/to/home", + Home: "/path/to/home", Getter: getter, ReadFile: testfs.ReadFile, FileExists: testfs.FileExistsAt, @@ -143,7 +144,7 @@ t.Fatalf("unexpected error: %v", err) } - if file != "path/to/home/.helmfile/cache/ssh_github_com_cloudposse_helmfiles_git.ref=0.40.0/releases/kiam.yaml" { + if file != "/path/to/home/.helmfile/cache/ssh_github_com_cloudposse_helmfiles_git.ref=0.40.0/releases/kiam.yaml" { t.Errorf("unexpected file located: %s", file) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.134.0/pkg/state/create.go new/helmfile-0.135.0/pkg/state/create.go --- old/helmfile-0.134.0/pkg/state/create.go 2020-11-09 00:50:00.000000000 +0100 +++ new/helmfile-0.135.0/pkg/state/create.go 2020-11-19 01:33:05.000000000 +0100 @@ -4,11 +4,12 @@ "bytes" "errors" "fmt" - "github.com/roboll/helmfile/pkg/helmexec" - "github.com/roboll/helmfile/pkg/remote" "io" "os" + "github.com/roboll/helmfile/pkg/helmexec" + "github.com/roboll/helmfile/pkg/remote" + "github.com/imdario/mergo" "github.com/roboll/helmfile/pkg/environment" "github.com/roboll/helmfile/pkg/maputil" @@ -39,12 +40,15 @@ } type StateCreator struct { - logger *zap.SugaredLogger - readFile func(string) ([]byte, error) - fileExists func(string) (bool, error) - abs func(string) (string, error) - glob func(string) ([]string, error) - DeleteFile func(string) error + logger *zap.SugaredLogger + + readFile func(string) ([]byte, error) + fileExists func(string) (bool, error) + abs func(string) (string, error) + glob func(string) ([]string, error) + DeleteFile func(string) error + directoryExistsAt func(string) bool + valsRuntime vals.Evaluator Strict bool @@ -58,13 +62,16 @@ remote *remote.Remote } -func NewCreator(logger *zap.SugaredLogger, readFile func(string) ([]byte, error), fileExists func(string) (bool, error), abs func(string) (string, error), glob func(string) ([]string, error), valsRuntime vals.Evaluator, getHelm func(*HelmState) helmexec.Interface, overrideHelmBinary string, remote *remote.Remote) *StateCreator { +func NewCreator(logger *zap.SugaredLogger, readFile func(string) ([]byte, error), fileExists func(string) (bool, error), abs func(string) (string, error), glob func(string) ([]string, error), directoryExistsAt func(string) bool, valsRuntime vals.Evaluator, getHelm func(*HelmState) helmexec.Interface, overrideHelmBinary string, remote *remote.Remote) *StateCreator { return &StateCreator{ - logger: logger, - readFile: readFile, - fileExists: fileExists, - abs: abs, - glob: glob, + logger: logger, + + readFile: readFile, + fileExists: fileExists, + abs: abs, + glob: glob, + directoryExistsAt: directoryExistsAt, + Strict: true, valsRuntime: valsRuntime, getHelm: getHelm, @@ -131,6 +138,7 @@ state.removeFile = os.Remove state.fileExists = c.fileExists state.glob = c.glob + state.directoryExistsAt = c.directoryExistsAt state.valsRuntime = c.valsRuntime return &state, nil diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.134.0/pkg/state/create_test.go new/helmfile-0.135.0/pkg/state/create_test.go --- old/helmfile-0.134.0/pkg/state/create_test.go 2020-11-09 00:50:00.000000000 +0100 +++ new/helmfile-0.135.0/pkg/state/create_test.go 2020-11-19 01:33:05.000000000 +0100 @@ -1,13 +1,14 @@ package state import ( - "github.com/roboll/helmfile/pkg/remote" "io/ioutil" "os" "path/filepath" "reflect" "testing" + "github.com/roboll/helmfile/pkg/remote" + "github.com/roboll/helmfile/pkg/testhelper" "go.uber.org/zap" @@ -83,7 +84,7 @@ } r := remote.NewRemote(logger, testFs.Cwd, testFs.ReadFile, testFs.DirectoryExistsAt, testFs.FileExistsAt) - state, err := NewCreator(logger, testFs.ReadFile, testFs.FileExists, testFs.Abs, testFs.Glob, nil, nil, "", r). + state, err := NewCreator(logger, testFs.ReadFile, testFs.FileExists, testFs.Abs, testFs.Glob, testFs.DirectoryExistsAt, nil, nil, "", r). ParseAndLoad([]byte(yamlContent), filepath.Dir(file), file, envName, true, nil) if err != nil { t.Fatalf("unexpected error: %v", err) @@ -148,7 +149,7 @@ testFs.Cwd = "/example/path/to" r := remote.NewRemote(logger, testFs.Cwd, testFs.ReadFile, testFs.DirectoryExistsAt, testFs.FileExistsAt) - state, err := NewCreator(logger, testFs.ReadFile, testFs.FileExists, testFs.Abs, testFs.Glob, nil, nil, "", r). + state, err := NewCreator(logger, testFs.ReadFile, testFs.FileExists, testFs.Abs, testFs.Glob, testFs.DirectoryExistsAt, nil, nil, "", r). ParseAndLoad(yamlContent, filepath.Dir(yamlFile), yamlFile, "production", true, nil) if err != nil { t.Fatalf("unexpected error: %v", err) @@ -235,7 +236,7 @@ testFs.Cwd = "/example/path/to" r := remote.NewRemote(logger, testFs.Cwd, testFs.ReadFile, testFs.DirectoryExistsAt, testFs.FileExistsAt) - state, err := NewCreator(logger, testFs.ReadFile, testFs.FileExists, testFs.Abs, testFs.Glob, nil, nil, "", r). + state, err := NewCreator(logger, testFs.ReadFile, testFs.FileExists, testFs.Abs, testFs.Glob, testFs.DirectoryExistsAt, nil, nil, "", r). ParseAndLoad(yamlContent, filepath.Dir(yamlFile), yamlFile, "production", true, nil) if err != nil { t.Fatalf("unexpected error: %v", err) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.134.0/pkg/state/helmx.go new/helmfile-0.135.0/pkg/state/helmx.go --- old/helmfile-0.134.0/pkg/state/helmx.go 2020-11-09 00:50:00.000000000 +0100 +++ new/helmfile-0.135.0/pkg/state/helmx.go 2020-11-19 01:33:05.000000000 +0100 @@ -144,6 +144,22 @@ shouldRun = true } + transformers := release.Transformers + if len(transformers) > 0 { + generatedFiles, err := st.generateTemporaryReleaseValuesFiles(release, transformers, release.MissingFileHandler) + if err != nil { + return nil, clean, err + } + + for _, f := range generatedFiles { + chartify.Opts.Transformers = append(chartify.Opts.Transformers, f) + } + + filesNeedCleaning = append(filesNeedCleaning, generatedFiles...) + + shouldRun = true + } + if release.ForceNamespace != "" { chartify.Opts.OverrideNamespace = release.ForceNamespace diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.134.0/pkg/state/state.go new/helmfile-0.135.0/pkg/state/state.go --- old/helmfile-0.134.0/pkg/state/state.go 2020-11-09 00:50:00.000000000 +0100 +++ new/helmfile-0.135.0/pkg/state/state.go 2020-11-19 01:33:05.000000000 +0100 @@ -82,12 +82,12 @@ logger *zap.SugaredLogger - readFile func(string) ([]byte, error) - - removeFile func(string) error - fileExists func(string) (bool, error) - glob func(string) ([]string, error) - tempDir func(string, string) (string, error) + readFile func(string) ([]byte, error) + removeFile func(string) error + fileExists func(string) (bool, error) + glob func(string) ([]string, error) + tempDir func(string, string) (string, error) + directoryExistsAt func(string) bool runner helmexec.Runner valsRuntime vals.Evaluator @@ -256,7 +256,14 @@ Dependencies []Dependency `yaml:"dependencies,omitempty"` JSONPatches []interface{} `yaml:"jsonPatches,omitempty"` StrategicMergePatches []interface{} `yaml:"strategicMergePatches,omitempty"` - Adopt []string `yaml:"adopt,omitempty"` + + // Transformers is the list of Kustomize transformers + // + // Each item can be a path to a YAML or go template file, or an embedded transformer declaration as a YAML hash. + // It's often used to add common labels and annotations to your resources. + // See https://github.com/kubernetes-sigs/kustomize/blob/master/examples/configureBuiltinPlugin.md#configuring-the-builtin-plugins-instead for more information. + Transformers []interface{} `yaml:"transformers,omitempty"` + Adopt []string `yaml:"adopt,omitempty"` //version of the chart that has really been installed cause desired version may be fuzzy (~2.0.0) installedVersion string @@ -833,6 +840,7 @@ type ChartPrepareOptions struct { ForceDownload bool SkipRepos bool + SkipDeps bool SkipResolve bool } @@ -923,7 +931,7 @@ chartName := release.Chart - isLocal := pathExists(normalizeChart(st.basePath, chartName)) + isLocal := st.directoryExistsAt(normalizeChart(st.basePath, chartName)) chartPath, err := st.goGetterChart(chartName, release.Directory, release.ForceGoGetter) if err != nil { @@ -942,7 +950,7 @@ var buildDeps bool - skipDepsGlobal := opts.SkipRepos + skipDepsGlobal := opts.SkipDeps skipDepsRelease := release.SkipDeps != nil && *release.SkipDeps skipDepsDefault := release.SkipDeps == nil && st.HelmDefaults.SkipDeps skipDeps := !isLocal || skipDepsGlobal || skipDepsRelease || skipDepsDefault @@ -970,7 +978,7 @@ // Skip `helm dep build` and `helm dep up` altogether when the chart is from remote or the dep is // explicitly skipped. buildDeps = !skipDeps - } else if pathExists(normalizeChart(st.basePath, chartPath)) { + } else if normalizedChart := normalizeChart(st.basePath, chartPath); st.directoryExistsAt(normalizedChart) { // At this point, we are sure that chartPath is a local directory containing either: // - A remote chart fetched by go-getter or // - A local chart @@ -994,7 +1002,7 @@ // Given that, we always run `helm dep build` on the chart here, but tolerate any error caused by it // for a remote chart, so that the user can notice/fix the issue in a local chart while // a broken remote chart won't completely block their job. - chartPath = normalizeChart(st.basePath, chartPath) + chartPath = normalizedChart buildDeps = !skipDeps } else if !opts.ForceDownload { @@ -1929,10 +1937,12 @@ var errs []error for _, release := range st.Releases { - if isLocalChart(release.Chart) { - if err := helm.UpdateDeps(normalizeChart(st.basePath, release.Chart)); err != nil { + if st.directoryExistsAt(release.Chart) { + if err := helm.UpdateDeps(release.Chart); err != nil { errs = append(errs, err) } + } else { + st.logger.Debugf("skipped updating dependencies for remote chart %s", release.Chart) } } @@ -1953,11 +1963,6 @@ return nil } -func pathExists(chart string) bool { - _, err := os.Stat(chart) - return err == nil -} - func chartNameWithoutRepository(chart string) string { chartSplit := strings.Split(chart, "/") return chartSplit[len(chartSplit)-1] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.134.0/pkg/state/state_test.go new/helmfile-0.135.0/pkg/state/state_test.go --- old/helmfile-0.134.0/pkg/state/state_test.go 2020-11-09 00:50:00.000000000 +0100 +++ new/helmfile-0.135.0/pkg/state/state_test.go 2020-11-19 01:33:05.000000000 +0100 @@ -22,6 +22,7 @@ st.glob = fs.Glob st.readFile = fs.ReadFile st.fileExists = fs.FileExists + st.directoryExistsAt = fs.DirectoryExistsAt return st } @@ -786,15 +787,23 @@ { name: "construct local chart path", args: args{ - basePath: "/Users/jane/code/deploy/charts", + basePath: "/src", chart: "./app", }, - want: "/Users/jane/code/deploy/charts/app", + want: "/src/app", + }, + { + name: "construct local chart path, without leading dot", + args: args{ + basePath: "/src", + chart: "published", + }, + want: "/src/published", }, { name: "repo path", args: args{ - basePath: "/Users/jane/code/deploy/charts", + basePath: "/src", chart: "remote/app", }, want: "remote/app", @@ -802,18 +811,26 @@ { name: "chartcenter repo path", args: args{ - basePath: "/Users/jane/code/deploy/charts", + basePath: "/src", chart: "center/stable/myapp", }, want: "center/stable/myapp", }, { - name: "construct local chart path, parent dir", + name: "construct local chart path, sibling dir", args: args{ - basePath: "/Users/jane/code/deploy/charts", + basePath: "/src", chart: "../app", }, - want: "/Users/jane/code/deploy/app", + want: "/app", + }, + { + name: "construct local chart path, parent dir", + args: args{ + basePath: "/src", + chart: "./..", + }, + want: "/", }, { name: "too much parent levels", @@ -1752,22 +1769,17 @@ } logger := helmexec.NewLogger(os.Stderr, "debug") + basePath := "/src" state := &HelmState{ - basePath: "/src", + basePath: basePath, FilePath: "/src/helmfile.yaml", ReleaseSetSpec: ReleaseSetSpec{ Releases: []ReleaseSpec{ { - Chart: "./..", + Chart: "/example", }, { - Chart: "../examples", - }, - { - Chart: "../../helmfile", - }, - { - Chart: "published", + Chart: "./example", }, { Chart: "published/deeper", @@ -1792,25 +1804,32 @@ logger: logger, } + fs := testhelper.NewTestFs(map[string]string{ + "/example/Chart.yaml": `foo: FOO`, + "/src/example/Chart.yaml": `foo: FOO`, + }) + fs.Cwd = basePath + state = injectFs(state, fs) errs := state.UpdateDeps(helm) - want := []string{"/", "/examples", "/helmfile", "/src/published", generatedDir} + + want := []string{"/example", "./example", generatedDir} if !reflect.DeepEqual(helm.Charts, want) { t.Errorf("HelmState.UpdateDeps() = %v, want %v", helm.Charts, want) } if len(errs) != 0 { - t.Errorf("HelmState.UpdateDeps() - no errors, but got %d: %v", len(errs), errs) + t.Errorf("HelmState.UpdateDeps() - unexpected %d errors: %v", len(errs), errs) } resolved, err := state.ResolveDeps() if err != nil { - t.Errorf("unexpected error: %v", err) + t.Errorf("HelmState.ResolveDeps() - unexpected error: %v", err) } - if resolved.Releases[5].Version != "1.5.0" { - t.Errorf("unexpected version number: expected=1.5.0, got=%s", resolved.Releases[5].Version) + if resolved.Releases[3].Version != "1.5.0" { + t.Errorf("HelmState.ResolveDeps() - unexpected version number: expected=1.5.0, got=%s", resolved.Releases[5].Version) } - if resolved.Releases[6].Version != "1.4.0" { - t.Errorf("unexpected version number: expected=1.4.0, got=%s", resolved.Releases[6].Version) + if resolved.Releases[4].Version != "1.4.0" { + t.Errorf("HelmState.ResolveDeps() - unexpected version number: expected=1.4.0, got=%s", resolved.Releases[6].Version) } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.134.0/pkg/testhelper/testfs.go new/helmfile-0.135.0/pkg/testhelper/testfs.go --- old/helmfile-0.134.0/pkg/testhelper/testfs.go 2020-11-09 00:50:00.000000000 +0100 +++ new/helmfile-0.135.0/pkg/testhelper/testfs.go 2020-11-19 01:33:05.000000000 +0100 @@ -39,7 +39,7 @@ func (f *TestFs) FileExistsAt(path string) bool { var ok bool - if strings.Contains(path, "/") { + if strings.HasPrefix(path, "/") { _, ok = f.files[path] } else { _, ok = f.files[filepath.Join(f.Cwd, path)] @@ -53,7 +53,7 @@ func (f *TestFs) DirectoryExistsAt(path string) bool { var ok bool - if strings.Contains(path, "/") { + if strings.HasPrefix(path, "/") { _, ok = f.dirs[path] } else { _, ok = f.dirs[filepath.Join(f.Cwd, path)] @@ -64,7 +64,7 @@ func (f *TestFs) ReadFile(filename string) ([]byte, error) { var str string var ok bool - if filename[0] == '/' { + if strings.HasPrefix(filename, "/") { str, ok = f.files[filename] } else { str, ok = f.files[filepath.Join(f.Cwd, filename)] @@ -90,7 +90,7 @@ func (f *TestFs) Glob(relPattern string) ([]string, error) { var pattern string - if relPattern[0] == '/' { + if strings.HasPrefix(relPattern, "/") { pattern = relPattern } else { pattern = filepath.Join(f.Cwd, relPattern) @@ -116,7 +116,7 @@ func (f *TestFs) Abs(path string) (string, error) { var p string - if path[0] == '/' { + if strings.HasPrefix(path, "/") { p = path } else { p = filepath.Join(f.Cwd, path) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.134.0/test/integration/happypath.yaml new/helmfile-0.135.0/test/integration/happypath.yaml --- old/helmfile-0.134.0/test/integration/happypath.yaml 2020-11-09 00:50:00.000000000 +0100 +++ new/helmfile-0.135.0/test/integration/happypath.yaml 2020-11-19 01:33:05.000000000 +0100 @@ -4,8 +4,6 @@ - environment.values.yaml --- repositories: - - name: stable - url: https://kubernetes-charts.storage.googleapis.com/ - name: center url: https://repo.chartcenter.io @@ -30,6 +28,7 @@ - name: raw chart: center/incubator/raw + version: 0.2.3 values: - mysecret: {{ .Environment.Values.mysecret }} - values.yaml ++++++ vendor.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/github.com/variantdev/chartify/chartify.go new/vendor/github.com/variantdev/chartify/chartify.go --- old/vendor/github.com/variantdev/chartify/chartify.go 2020-11-10 16:26:16.000000000 +0100 +++ new/vendor/github.com/variantdev/chartify/chartify.go 2020-11-19 10:47:04.000000000 +0100 @@ -47,6 +47,10 @@ JsonPatches []string StrategicMergePatches []string + // Transformers is the list of YAML files each defines a Kustomize transformer + // See https://github.com/kubernetes-sigs/kustomize/blob/master/examples/configureBuiltinPlugin.md#configuring-the-builtin-plugins-instead for more information. + Transformers []string + // WorkaroundOutputDirIssue prevents chartify from using `helm template --output-dir` and let it use `helm template > some.yaml` instead to // workaround the potential helm issue // See https://github.com/roboll/helmfile/issues/1279#issuecomment-636839395 @@ -356,10 +360,11 @@ } } - if len(u.JsonPatches) > 0 || len(u.StrategicMergePatches) > 0 { + if len(u.JsonPatches) > 0 || len(u.StrategicMergePatches) > 0 || len(u.Transformers) > 0 { patchOpts := &PatchOpts{ JsonPatches: u.JsonPatches, StrategicMergePatches: u.StrategicMergePatches, + Transformers: u.Transformers, } if err := r.Patch(tempDir, generatedManifestFiles, patchOpts); err != nil { return "", err @@ -407,8 +412,21 @@ return filesDir, nil } +// RewriteChartToPreventDoubleRendering rewrites templates/*.yaml files with +// template files containing: +// {{ .Files.Get "path/to/the/yaml/file" }} +// So that re-running helm-template on chartify's final output doesn't result in double-rendering. +// Double-rendering accidentally renders e.g. go template expressions embedded in prometheus rules manifests, +// which is not what the user wants. func (r *Runner) RewriteChartToPreventDoubleRendering(tempDir, filesDir string) error { for _, d := range ContentDirs { + if d == "crds" { + // Do not rewrite crds/*.yaml, as `helm template --includec-crds` seem to + // render CRD yaml files as-is, without processing go template. + // Also see https://github.com/helm/helm/pull/7138/files + continue + } + srcDir := filepath.Join(tempDir, d) dstDir := filepath.Join(filesDir, d) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/github.com/variantdev/chartify/go.mod new/vendor/github.com/variantdev/chartify/go.mod --- old/vendor/github.com/variantdev/chartify/go.mod 2020-11-10 16:26:16.000000000 +0100 +++ new/vendor/github.com/variantdev/chartify/go.mod 2020-11-19 10:47:04.000000000 +0100 @@ -3,7 +3,7 @@ go 1.14 require ( - github.com/google/go-cmp v0.4.0 + github.com/google/go-cmp v0.5.2 github.com/otiai10/copy v1.1.1 - gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c + gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/github.com/variantdev/chartify/go.sum new/vendor/github.com/variantdev/chartify/go.sum --- old/vendor/github.com/variantdev/chartify/go.sum 2020-11-10 16:26:16.000000000 +0100 +++ new/vendor/github.com/variantdev/chartify/go.sum 2020-11-19 10:47:04.000000000 +0100 @@ -1,5 +1,5 @@ -github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/otiai10/copy v1.1.1 h1:PH7IFlRQ6Fv9vYmuXbDRLdgTHoP1w483kPNUP2bskpo= github.com/otiai10/copy v1.1.1/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= @@ -12,5 +12,5 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/github.com/variantdev/chartify/patch.go new/vendor/github.com/variantdev/chartify/patch.go --- old/vendor/github.com/variantdev/chartify/patch.go 2020-11-10 16:26:16.000000000 +0100 +++ new/vendor/github.com/variantdev/chartify/patch.go 2020-11-19 10:47:04.000000000 +0100 @@ -13,6 +13,8 @@ JsonPatches []string StrategicMergePatches []string + + Transformers []string } func (o *PatchOpts) SetPatchOption(opts *PatchOpts) error { @@ -120,6 +122,26 @@ abspath := filepath.Join(tempDir, path) if err := os.MkdirAll(filepath.Dir(abspath), 0755); err != nil { return err + } + if err := r.WriteFile(abspath, bytes, 0644); err != nil { + return err + } + kustomizationYamlContent += `- ` + path + "\n" + } + } + + if len(u.Transformers) > 0 { + kustomizationYamlContent += `transformers: +` + for i, f := range u.Transformers { + bytes, err := r.ReadFile(f) + if err != nil { + return err + } + path := filepath.Join("transformers", fmt.Sprintf("transformer.%d.yaml", i)) + abspath := filepath.Join(tempDir, path) + if err := os.MkdirAll(filepath.Dir(abspath), 0755); err != nil { + return err } if err := r.WriteFile(abspath, bytes, 0644); err != nil { return err diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/github.com/variantdev/chartify/replace.go new/vendor/github.com/variantdev/chartify/replace.go --- old/vendor/github.com/variantdev/chartify/replace.go 2020-11-10 16:26:17.000000000 +0100 +++ new/vendor/github.com/variantdev/chartify/replace.go 2020-11-19 10:47:04.000000000 +0100 @@ -71,7 +71,7 @@ // - Replace templates/**/*.yaml with rendered templates/**/*.yaml // - Replace charts/SUBCHART.tgz with rendered charts/SUBCHART/templates/*.yaml - // - REplace crds/*.yaml with rendered crds/*.yaml + // - Replace crds/*.yaml with rendered crds/*.yaml for _, d := range ContentDirs { origDir := filepath.Join(chartPath, d) if err := os.RemoveAll(origDir); err != nil { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/modules.txt new/vendor/modules.txt --- old/vendor/modules.txt 2020-11-10 16:26:18.000000000 +0100 +++ new/vendor/modules.txt 2020-11-19 10:47:06.000000000 +0100 @@ -284,7 +284,7 @@ # github.com/urfave/cli v1.22.5 ## explicit github.com/urfave/cli -# github.com/variantdev/chartify v0.4.8 +# github.com/variantdev/chartify v0.5.0 ## explicit github.com/variantdev/chartify # github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363 _______________________________________________ openSUSE Commits mailing list -- [email protected] To unsubscribe, email [email protected] List Netiquette: https://en.opensuse.org/openSUSE:Mailing_list_netiquette List Archives: https://lists.opensuse.org/archives/list/[email protected]
