mirror of
https://github.com/helm/helm.git
synced 2026-05-28 04:35:48 -04:00
commit
3fdb7cac01
17 changed files with 137 additions and 1 deletions
|
|
@ -268,7 +268,7 @@ func processImportValues(c *chart.Chart) error {
|
|||
}
|
||||
|
||||
// set the new values
|
||||
c.Values = CoalesceTables(b, cvals)
|
||||
c.Values = CoalesceTables(cvals, b)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -239,6 +239,37 @@ func TestProcessDependencyImportValues(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestProcessDependencyImportValuesMultiLevelPrecedence(t *testing.T) {
|
||||
c := loadChart(t, "testdata/three-level-dependent-chart/umbrella")
|
||||
|
||||
e := make(map[string]string)
|
||||
|
||||
e["app1.service.port"] = "3456"
|
||||
e["app2.service.port"] = "8080"
|
||||
|
||||
if err := processDependencyImportValues(c); err != nil {
|
||||
t.Fatalf("processing import values dependencies %v", err)
|
||||
}
|
||||
cc := Values(c.Values)
|
||||
for kk, vv := range e {
|
||||
pv, err := cc.PathValue(kk)
|
||||
if err != nil {
|
||||
t.Fatalf("retrieving import values table %v %v", kk, err)
|
||||
}
|
||||
|
||||
switch pv := pv.(type) {
|
||||
case float64:
|
||||
if s := strconv.FormatFloat(pv, 'f', -1, 64); s != vv {
|
||||
t.Errorf("failed to match imported float value %v with expected %v", s, vv)
|
||||
}
|
||||
default:
|
||||
if pv != vv {
|
||||
t.Errorf("failed to match imported string value %q with expected %q", pv, vv)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestProcessDependencyImportValuesForEnabledCharts(t *testing.T) {
|
||||
c := loadChart(t, "testdata/import-values-from-enabled-subchart/parent-chart")
|
||||
nameOverride := "parent-chart-prod"
|
||||
|
|
|
|||
16
pkg/chartutil/testdata/three-level-dependent-chart/README.md
vendored
Normal file
16
pkg/chartutil/testdata/three-level-dependent-chart/README.md
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# Three Level Dependent Chart
|
||||
|
||||
This chart is for testing the processing of multi-level dependencies.
|
||||
|
||||
Consists of the following charts:
|
||||
|
||||
- Library Chart
|
||||
- App Chart (Uses Library Chart as dependecy, 2x: app1/app2)
|
||||
- Umbrella Chart (Has all the app charts as dependencies)
|
||||
|
||||
The precendence is as follows: `library < app < umbrella`
|
||||
|
||||
Catches two use-cases:
|
||||
|
||||
- app overwriting library (app2)
|
||||
- umbrella overwriting app and library (app1)
|
||||
13
pkg/chartutil/testdata/three-level-dependent-chart/umbrella/Chart.yaml
vendored
Normal file
13
pkg/chartutil/testdata/three-level-dependent-chart/umbrella/Chart.yaml
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
apiVersion: v2
|
||||
name: umbrella
|
||||
description: A Helm chart for Kubernetes
|
||||
type: application
|
||||
version: 0.1.0
|
||||
|
||||
dependencies:
|
||||
- name: app1
|
||||
version: 0.1.0
|
||||
condition: app1.enabled
|
||||
- name: app2
|
||||
version: 0.1.0
|
||||
condition: app2.enabled
|
||||
11
pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app1/Chart.yaml
vendored
Normal file
11
pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app1/Chart.yaml
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
apiVersion: v2
|
||||
name: app1
|
||||
description: A Helm chart for Kubernetes
|
||||
type: application
|
||||
version: 0.1.0
|
||||
|
||||
dependencies:
|
||||
- name: library
|
||||
version: 0.1.0
|
||||
import-values:
|
||||
- defaults
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
apiVersion: v2
|
||||
name: library
|
||||
description: A Helm chart for Kubernetes
|
||||
type: library
|
||||
version: 0.1.0
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
name: http
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
exports:
|
||||
defaults:
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 9090
|
||||
|
|
@ -0,0 +1 @@
|
|||
{{- include "library.service" . }}
|
||||
3
pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app1/values.yaml
vendored
Normal file
3
pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app1/values.yaml
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
service:
|
||||
type: ClusterIP
|
||||
port: 1234
|
||||
11
pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app2/Chart.yaml
vendored
Normal file
11
pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app2/Chart.yaml
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
apiVersion: v2
|
||||
name: app2
|
||||
description: A Helm chart for Kubernetes
|
||||
type: application
|
||||
version: 0.1.0
|
||||
|
||||
dependencies:
|
||||
- name: library
|
||||
version: 0.1.0
|
||||
import-values:
|
||||
- defaults
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
apiVersion: v2
|
||||
name: library
|
||||
description: A Helm chart for Kubernetes
|
||||
type: library
|
||||
version: 0.1.0
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
name: http
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
exports:
|
||||
defaults:
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 9090
|
||||
|
|
@ -0,0 +1 @@
|
|||
{{- include "library.service" . }}
|
||||
3
pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app2/values.yaml
vendored
Normal file
3
pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app2/values.yaml
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
service:
|
||||
type: ClusterIP
|
||||
port: 8080
|
||||
8
pkg/chartutil/testdata/three-level-dependent-chart/umbrella/values.yaml
vendored
Normal file
8
pkg/chartutil/testdata/three-level-dependent-chart/umbrella/values.yaml
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
app1:
|
||||
enabled: true
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 3456
|
||||
|
||||
app2:
|
||||
enabled: true
|
||||
Loading…
Reference in a new issue