Fix set flag are ignored when used in conjunction with jsonPatches (#867)
* Fix set flag are ignored when used in conjunction with jsonPatches Signed-off-by: xiaomudk <xiaomudk@gmail.com>
This commit is contained in:
parent
8b3ad5b793
commit
c498af3f52
|
|
@ -251,6 +251,7 @@ func (a *App) Template(c TemplateConfigProvider) error {
|
|||
Validate: c.Validate(),
|
||||
Concurrency: c.Concurrency(),
|
||||
IncludeTransitiveNeeds: c.IncludeNeeds(),
|
||||
Set: c.Set(),
|
||||
}, func() {
|
||||
ok, errs = a.template(run, c)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1052,6 +1052,7 @@ type ChartPrepareOptions struct {
|
|||
IncludeTransitiveNeeds bool
|
||||
Concurrency int
|
||||
KubeVersion string
|
||||
Set []string
|
||||
}
|
||||
|
||||
type chartPrepareResult struct {
|
||||
|
|
@ -1225,6 +1226,11 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre
|
|||
|
||||
chartifyOpts.KubeVersion = release.KubeVersion
|
||||
chartifyOpts.ApiVersions = release.ApiVersions
|
||||
var flags []string
|
||||
for _, s := range opts.Set {
|
||||
flags = append(flags, "--set", s)
|
||||
}
|
||||
chartifyOpts.SetFlags = flags
|
||||
|
||||
out, err := c.Chartify(release.Name, chartPath, chartify.WithChartifyOpts(chartifyOpts))
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ ${kubectl} create namespace ${test_ns} || fail "Could not create namespace ${tes
|
|||
. ${dir}/test-cases/yaml-overwrite.sh
|
||||
. ${dir}/test-cases/chart-needs.sh
|
||||
. ${dir}/test-cases/postrender.sh
|
||||
. ${dir}/test-cases/chartify.sh
|
||||
|
||||
# ALL DONE -----------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
chartify_case_input_dir="${cases_dir}/chartify/input"
|
||||
chartify_case_output_dir="${cases_dir}/chartify/output"
|
||||
|
||||
config_file="helmfile.yaml"
|
||||
if [[ ${HELMFILE_V1MODE} = true ]]; then
|
||||
pushd "${chartify_case_input_dir}"
|
||||
mv "${config_file}" "${config_file}.gotmpl"
|
||||
config_file="${config_file}.gotmpl"
|
||||
popd
|
||||
fi
|
||||
|
||||
chartify_tmp=$(mktemp -d)
|
||||
chartify_template_reverse=${chartify_tmp}/chartify.template.log
|
||||
|
||||
|
||||
test_start "helmfile template with chartify"
|
||||
|
||||
info "Comparing template/chartify"
|
||||
${helmfile} -f ${chartify_case_input_dir}/${config_file} template > ${chartify_template_reverse} || fail "\"helmfile template\" shouldn't fail"
|
||||
./dyff between -bs ${chartify_case_output_dir}/template ${chartify_template_reverse} || fail "\"helmfile template\" should be consistent"
|
||||
|
||||
info "Comparing template/chartify with set"
|
||||
${helmfile} -f ${chartify_case_input_dir}/${config_file} template --set image.tag=v2 > ${chartify_template_reverse} || fail "\"helmfile template\" shouldn't fail"
|
||||
./dyff between -bs ${chartify_case_output_dir}/template-set ${chartify_template_reverse} || fail "\"helmfile template\" should be consistent"
|
||||
|
||||
|
||||
test_pass "helmfile template with chartify"
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
releases:
|
||||
- name: httpbin
|
||||
chart: ../../../charts/httpbin
|
||||
jsonPatches:
|
||||
- target:
|
||||
group: apps
|
||||
version: v1
|
||||
kind: Deployment
|
||||
name: httpbin-httpbin
|
||||
patch:
|
||||
- path: "/spec/strategy/type"
|
||||
op: replace
|
||||
value: Recreate
|
||||
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
---
|
||||
# Source: httpbin/templates/patched_resources.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: httpbin
|
||||
chart: httpbin-0.1.0
|
||||
heritage: Helm
|
||||
release: httpbin
|
||||
name: httpbin-httpbin
|
||||
spec:
|
||||
ports:
|
||||
- name: httpbin
|
||||
port: 8000
|
||||
protocol: TCP
|
||||
targetPort: 8000
|
||||
selector:
|
||||
app: httpbin
|
||||
release: httpbin
|
||||
type: LoadBalancer
|
||||
---
|
||||
# Source: httpbin/templates/patched_resources.yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: httpbin
|
||||
chart: httpbin-0.1.0
|
||||
heritage: Helm
|
||||
release: httpbin
|
||||
name: httpbin-httpbin
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: httpbin
|
||||
strategy:
|
||||
type: Recreate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: httpbin
|
||||
release: httpbin
|
||||
spec:
|
||||
containers:
|
||||
- image: docker.io/citizenstig/httpbin:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8000
|
||||
name: httpbin
|
||||
ports:
|
||||
- containerPort: 8000
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8000
|
||||
resources: {}
|
||||
status: {}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
---
|
||||
# Source: httpbin/templates/patched_resources.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: httpbin
|
||||
chart: httpbin-0.1.0
|
||||
heritage: Helm
|
||||
release: httpbin
|
||||
name: httpbin-httpbin
|
||||
spec:
|
||||
ports:
|
||||
- name: httpbin
|
||||
port: 8000
|
||||
protocol: TCP
|
||||
targetPort: 8000
|
||||
selector:
|
||||
app: httpbin
|
||||
release: httpbin
|
||||
type: LoadBalancer
|
||||
---
|
||||
# Source: httpbin/templates/patched_resources.yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: httpbin
|
||||
chart: httpbin-0.1.0
|
||||
heritage: Helm
|
||||
release: httpbin
|
||||
name: httpbin-httpbin
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: httpbin
|
||||
strategy:
|
||||
type: Recreate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: httpbin
|
||||
release: httpbin
|
||||
spec:
|
||||
containers:
|
||||
- image: docker.io/citizenstig/httpbin:v2
|
||||
imagePullPolicy: IfNotPresent
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8000
|
||||
name: httpbin
|
||||
ports:
|
||||
- containerPort: 8000
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8000
|
||||
resources: {}
|
||||
status: {}
|
||||
Loading…
Reference in New Issue