Skip to content

Commit 01889c1

Browse files
committed
fix: reverted log for no config and added validation unit test
1 parent 5e5ba7f commit 01889c1

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

pkg/handlers/generic/mutation/autorenewcerts/inject.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,12 @@ func (h *autoRenewCerts) Mutate(
6767
h.variableName,
6868
h.variableFieldPath...,
6969
)
70-
if err != nil && !variables.IsNotFoundError(err) {
71-
return err
70+
if err != nil {
71+
if variables.IsNotFoundError(err) {
72+
log.V(5).Info("Control Plane auto renew certs variable not defined")
73+
} else {
74+
return err
75+
}
7276
}
7377

7478
log = log.WithValues(

pkg/handlers/generic/mutation/autorenewcerts/inject_test.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ var _ = Describe("Generate auto renew patches", func() {
8989
},
9090
{
9191
patchTest: capitest.PatchTestDef{
92-
Name: "auto cert renewal set with Nutanix",
92+
Name: "auto cert renewal set to 10 with Nutanix",
9393
Vars: []runtimehooksv1.Variable{
9494
capitest.VariableWithValue(
9595
v1alpha1.ClusterConfigVariableName,
@@ -115,6 +115,31 @@ var _ = Describe("Generate auto renew patches", func() {
115115
}},
116116
},
117117
},
118+
{
119+
patchTest: capitest.PatchTestDef{
120+
Name: "auto cert renewal set to 0 with Nutanix",
121+
Vars: []runtimehooksv1.Variable{
122+
capitest.VariableWithValue(
123+
v1alpha1.ClusterConfigVariableName,
124+
v1alpha1.NutanixClusterConfigSpec{
125+
ControlPlane: &v1alpha1.NutanixControlPlaneSpec{
126+
GenericControlPlaneSpec: v1alpha1.GenericControlPlaneSpec{
127+
AutoRenewCertificates: &v1alpha1.AutoRenewCertificatesSpec{
128+
DaysBeforeExpiry: 0,
129+
},
130+
},
131+
},
132+
},
133+
),
134+
},
135+
RequestItem: request.NewKubeadmControlPlaneTemplateRequestItem(""),
136+
UnexpectedPatchMatchers: []capitest.JSONPatchMatcher{{
137+
Operation: "add",
138+
Path: "/spec/template/spec",
139+
ValueMatcher: gomega.HaveKey("rolloutBefore"),
140+
}},
141+
},
142+
},
118143
}
119144

120145
// create test node for each case

0 commit comments

Comments
 (0)