fix: Support for kustomization as chart

A kustomization has not been properly chartified when a kustomization is specified on `releases[].chart` but there were no `releases[].strategicMergePatches` and `jsonPatches` specified.
This fixes that.
This commit is contained in:
Yusuke Kuoka 2020-05-27 21:34:44 +09:00
parent 68432b1848
commit 29fdb57add
6 changed files with 76 additions and 0 deletions

View File

@ -3,6 +3,8 @@ package state
import ( import (
"github.com/roboll/helmfile/pkg/helmexec" "github.com/roboll/helmfile/pkg/helmexec"
"github.com/variantdev/chartify" "github.com/variantdev/chartify"
"os"
"path/filepath"
"strings" "strings"
) )
@ -29,6 +31,13 @@ func (st *HelmState) PrepareChartify(helm helmexec.Interface, release *ReleaseSp
opts.ChartVersion = release.Version opts.ChartVersion = release.Version
dir := filepath.Join(st.basePath, release.Chart)
if stat, _ := os.Stat(dir); stat != nil && stat.IsDir() {
if exists, err := st.fileExists(filepath.Join(dir, "Chart.yaml")); err == nil && !exists {
shouldRun = true
}
}
for _, d := range release.Dependencies { for _, d := range release.Dependencies {
var dep string var dep string

View File

@ -0,0 +1,49 @@
repositories:
- name: incubator
url: https://kubernetes-charts-incubator.storage.googleapis.com
releases:
- name: kustomapp
chart: ./kustomapp
values:
- namePrefix: kustomapp-
- name: raw1
chart: incubator/raw
values:
- resources:
- apiVersion: v1
kind: ConfigMap
metadata:
name: raw1
namespace: default
data:
foo: FOO
strategicMergePatches:
- apiVersion: v1
kind: ConfigMap
metadata:
name: raw1
namespace: default
data:
bar: BAR
- name: raw2
chart: incubator/raw
values:
- resources:
- apiVersion: v1
kind: ConfigMap
metadata:
name: raw2
namespace: default
data:
foo: FOO
jsonPatches:
- target:
version: v1
kind: ConfigMap
name: raw2
namespace: default
patch:
- op: replace
path: /data/baz
value: "BAZ"

View File

@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: kustomapp
namespace: default
data:
kustomappfoo: FOO

View File

@ -0,0 +1,2 @@
resources:
- all.yaml

View File

@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: kustomapp2
namespace: default
data:
kustomappfoo: FOO

View File

@ -0,0 +1,2 @@
resources:
- all.yaml