Skip to content

Commit f314cc2

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

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

assets/upgradePatches.json

+18
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,24 @@
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+
}
7795
}
7896
],
7997
"objectsToBeRemoved": [

pkg/upgradepatch/upgradePatches_test.go

+36
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,42 @@ 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", func(oldFG, newFG *bool, ver semver.Version, assertion types.GomegaMatcher) {
243+
hc := components.GetOperatorCR()
244+
hc.Spec.FeatureGates.EnableCommonBootImageImport = oldFG
245+
hc.Spec.EnableCommonBootImageImport = newFG
246+
247+
newHc, err := ApplyUpgradePatch(GinkgoLogr, hc, ver)
248+
Expect(err).NotTo(HaveOccurred())
249+
250+
Expect(newHc.Spec.EnableCommonBootImageImport).To(assertion)
251+
},
252+
Entry("should move if the old value is not the default value",
253+
ptr.To(false),
254+
ptr.To(true),
255+
semver.MustParse("1.14.0"),
256+
HaveValue(BeFalse()),
257+
),
258+
Entry("should not move for newer versions",
259+
ptr.To(false),
260+
ptr.To(true),
261+
semver.MustParse("1.15.0"),
262+
HaveValue(BeTrue()),
263+
),
264+
Entry("should not move if the old FG is empty",
265+
nil,
266+
ptr.To(true),
267+
semver.MustParse("1.14.0"),
268+
HaveValue(BeTrue()),
269+
),
270+
Entry("should not move if the old FG is the default one",
271+
ptr.To(true),
272+
ptr.To(false),
273+
semver.MustParse("1.14.0"),
274+
HaveValue(BeFalse()),
275+
),
276+
)
241277
})
242278
})
243279

0 commit comments

Comments
 (0)