Skip to content

Commit fa29075

Browse files
committed
NVSHAS-8597: Treat non-semantic versioning as post 5.3
1 parent d488ccd commit fa29075

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

charts/core/templates/controller-deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
{{- $pre530 := false -}}
2+
{{- if regexMatch "^[0-9]+\\.[0-9]+\\.[0-9]+" .Values.tag }}
13
{{- $pre530 := (semverCompare "<5.2.10" .Values.tag) -}}
4+
{{- end }}
25
{{- if .Values.controller.enabled -}}
36
{{- if (semverCompare ">=1.9-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
47
apiVersion: apps/v1

charts/core/templates/enforcer-daemonset.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
{{- $pre530 := false -}}
2+
{{- if regexMatch "^[0-9]+\\.[0-9]+\\.[0-9]+" .Values.tag }}
13
{{- $pre530 := (semverCompare "<5.2.10" .Values.tag) -}}
4+
{{- end }}
25
{{- if .Values.enforcer.enabled -}}
36
{{- if (semverCompare ">=1.9-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
47
apiVersion: apps/v1

test/daemonset_test.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ func TestEnforcerDaemonset(t *testing.T) {
1414
SetValues: map[string]string{},
1515
}
1616

17-
// Test ingress
1817
out := helm.RenderTemplate(t, options, helmChartPath, nvRel, []string{"templates/enforcer-daemonset.yaml"})
1918
outs := splitYaml(out)
2019

@@ -23,6 +22,29 @@ func TestEnforcerDaemonset(t *testing.T) {
2322
}
2423
}
2524

25+
func TestEnforcerDaemonsetPost53(t *testing.T) {
26+
helmChartPath := "../charts/core"
27+
28+
options := &helm.Options{
29+
SetValues: map[string]string{
30+
"tag": "latest",
31+
},
32+
}
33+
34+
out := helm.RenderTemplate(t, options, helmChartPath, nvRel, []string{"templates/enforcer-daemonset.yaml"})
35+
outs := splitYaml(out)
36+
37+
if len(outs) != 1 {
38+
t.Errorf("Resource count is wrong. count=%v\n", len(outs))
39+
}
40+
41+
var ds appsv1.DaemonSet
42+
helm.UnmarshalK8SYaml(t, outs[0], &ds)
43+
if ds.Spec.Template.Spec.Containers[0].VolumeMounts[0].Name != "modules-vol" {
44+
t.Errorf("VolumeMounts[0] is wrong, %v\n", ds.Spec.Template.Spec.Containers[0].VolumeMounts[0])
45+
}
46+
}
47+
2648
func TestEnforcerDaemonsetRuntime(t *testing.T) {
2749
helmChartPath := "../charts/core"
2850

@@ -33,7 +55,6 @@ func TestEnforcerDaemonsetRuntime(t *testing.T) {
3355
},
3456
}
3557

36-
// Test ingress
3758
out := helm.RenderTemplate(t, options, helmChartPath, nvRel, []string{"templates/enforcer-daemonset.yaml"})
3859
outs := splitYaml(out)
3960

@@ -75,7 +96,6 @@ func TestEnforcerDaemonsetLeastPrivilege(t *testing.T) {
7596
},
7697
}
7798

78-
// Test ingress
7999
out := helm.RenderTemplate(t, options, helmChartPath, nvRel, []string{"templates/enforcer-daemonset.yaml"})
80100
outs := splitYaml(out)
81101

test/deployment_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ func TestControllerDeployment(t *testing.T) {
2121
},
2222
}
2323

24-
// Test ingress
2524
out := helm.RenderTemplate(t, options, helmChartPath, nvRel, []string{"templates/controller-deployment.yaml"})
2625
outs := splitYaml(out)
2726

@@ -39,7 +38,6 @@ func TestControllerDeploymentPre53(t *testing.T) {
3938
},
4039
}
4140

42-
// Test ingress
4341
out := helm.RenderTemplate(t, options, helmChartPath, nvRel, []string{"templates/controller-deployment.yaml"})
4442
outs := splitYaml(out)
4543

@@ -66,7 +64,6 @@ func TestControllerDeploymentPost53(t *testing.T) {
6664
},
6765
}
6866

69-
// Test ingress
7067
out := helm.RenderTemplate(t, options, helmChartPath, nvRel, []string{"templates/controller-deployment.yaml"})
7168
outs := splitYaml(out)
7269

@@ -97,7 +94,6 @@ func TestControllerDeploymentRegistry(t *testing.T) {
9794
},
9895
}
9996

100-
// Test ingress
10197
out := helm.RenderTemplate(t, options, helmChartPath, nvRel, []string{"templates/controller-deployment.yaml"})
10298
outs := splitYaml(out)
10399

@@ -124,7 +120,6 @@ func TestControllerDeploymentOEM(t *testing.T) {
124120
},
125121
}
126122

127-
// Test ingress
128123
out := helm.RenderTemplate(t, options, helmChartPath, nvRel, []string{"templates/controller-deployment.yaml"})
129124
outs := splitYaml(out)
130125

@@ -149,7 +144,6 @@ func TestControllerDeploymentCert(t *testing.T) {
149144
},
150145
}
151146

152-
// Test ingress
153147
out := helm.RenderTemplate(t, options, helmChartPath, nvRel, []string{"templates/controller-deployment.yaml"})
154148
outs := splitYaml(out)
155149

@@ -168,7 +162,6 @@ func TestControllerDeploymentDisrupt(t *testing.T) {
168162
},
169163
}
170164

171-
// Test ingress
172165
out := helm.RenderTemplate(t, options, helmChartPath, nvRel, []string{"templates/controller-deployment.yaml"})
173166
outs := splitYaml(out)
174167

0 commit comments

Comments
 (0)