Skip to content

Commit cf96034

Browse files
committed
Move the FG to the field, on upgrade
Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>
1 parent b2764bc commit cf96034

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

assets/upgradePatches.json

+30
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,36 @@
7474
"jsonPatchApplyOptions": {
7575
"allowMissingPathOnRemove": true
7676
}
77+
},
78+
{
79+
"semverRange": "<1.15.0",
80+
"jsonPatch": [
81+
{
82+
"op": "test",
83+
"path": "/spec/featureGates/enableCommonBootImageImport",
84+
"value": false
85+
},
86+
{
87+
"op": "move",
88+
"from": "/spec/featureGates/enableCommonBootImageImport",
89+
"path": "/spec/enableCommonBootImageImport"
90+
}
91+
],
92+
"jsonPatchApplyOptions": {
93+
"allowMissingPathOnRemove": true
94+
}
95+
},
96+
{
97+
"semverRange": "<1.15.0",
98+
"jsonPatch": [
99+
{
100+
"op": "remove",
101+
"path": "/spec/featureGates/enableCommonBootImageImport"
102+
}
103+
],
104+
"jsonPatchApplyOptions": {
105+
"allowMissingPathOnRemove": true
106+
}
77107
}
78108
],
79109
"objectsToBeRemoved": [

pkg/upgradepatch/upgradePatches_test.go

+42
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,48 @@ var _ = Describe("upgradePatches", func() {
238238
Expect(newHc.Spec.FeatureGates.WithHostPassthroughCPU).To(BeNil())
239239
Expect(newHc.Spec.FeatureGates.PrimaryUserDefinedNetworkBinding).To(BeNil())
240240
})
241+
242+
DescribeTable("Moving the deprecated EnableCommonBootImageImport FG to a new field",
243+
func(oldFG, newFG *bool, ver semver.Version, assertField, assertFG types.GomegaMatcher) {
244+
hc := components.GetOperatorCR()
245+
hc.Spec.FeatureGates.EnableCommonBootImageImport = oldFG
246+
hc.Spec.EnableCommonBootImageImport = newFG
247+
248+
newHc, err := ApplyUpgradePatch(GinkgoLogr, hc, ver)
249+
Expect(err).NotTo(HaveOccurred())
250+
251+
Expect(newHc.Spec.EnableCommonBootImageImport).To(assertField)
252+
Expect(newHc.Spec.FeatureGates.EnableCommonBootImageImport).To(assertFG)
253+
},
254+
Entry("should move if the old value is not the default value",
255+
ptr.To(false),
256+
ptr.To(true),
257+
semver.MustParse("1.14.0"),
258+
HaveValue(BeFalse()),
259+
BeNil(),
260+
),
261+
Entry("should not move for newer versions",
262+
ptr.To(false),
263+
ptr.To(true),
264+
semver.MustParse("1.15.0"),
265+
HaveValue(BeTrue()),
266+
HaveValue(BeFalse()),
267+
),
268+
Entry("should not move if the old FG is empty",
269+
nil,
270+
ptr.To(true),
271+
semver.MustParse("1.14.0"),
272+
HaveValue(BeTrue()),
273+
BeNil(),
274+
),
275+
Entry("should not move if the old FG is the default one",
276+
ptr.To(true),
277+
ptr.To(false),
278+
semver.MustParse("1.14.0"),
279+
HaveValue(BeFalse()),
280+
BeNil(),
281+
),
282+
)
241283
})
242284
})
243285

0 commit comments

Comments
 (0)