Skip to content

Commit cde43ae

Browse files
committed
fixup! refactor: Use declared builtin variable name rather than string
1 parent e5c6d6f commit cde43ae

File tree

27 files changed

+48
-48
lines changed

27 files changed

+48
-48
lines changed

common/pkg/capi/clustertopology/handlers/mutation/meta.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (mgp metaGeneratePatches) GeneratePatches(
101101
globalVars := lo.FilterSliceToMap(
102102
req.Variables,
103103
func(v runtimehooksv1.Variable) (string, apiextensionsv1.JSON, bool) {
104-
if v.Name == "builtin" {
104+
if v.Name == runtimehooksv1.BuiltinsName {
105105
return "", apiextensionsv1.JSON{}, false
106106
}
107107
return v.Name, v.Value, true

common/pkg/capi/clustertopology/patches/matchers/match_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func TestMatchesSelector(t *testing.T) {
225225
FieldPath: "spec.template.spec.bootstrap.configRef",
226226
},
227227
templateVariables: map[string]apiextensionsv1.JSON{
228-
"builtin": {Raw: []byte(`{"machineDeployment":{"class":"classA"}}`)},
228+
runtimehooksv1.BuiltinsName: {Raw: []byte(`{"machineDeployment":{"class":"classA"}}`)},
229229
},
230230
selector: clusterv1.PatchSelector{
231231
APIVersion: "bootstrap.cluster.x-k8s.io/v1beta1",
@@ -253,7 +253,7 @@ func TestMatchesSelector(t *testing.T) {
253253
FieldPath: "spec.template.spec.bootstrap.configRef",
254254
},
255255
templateVariables: map[string]apiextensionsv1.JSON{
256-
"builtin": {Raw: []byte(`{"machineDeployment":{"class":"classA"}}`)},
256+
runtimehooksv1.BuiltinsName: {Raw: []byte(`{"machineDeployment":{"class":"classA"}}`)},
257257
},
258258
selector: clusterv1.PatchSelector{
259259
APIVersion: "bootstrap.cluster.x-k8s.io/v1beta1",
@@ -281,7 +281,7 @@ func TestMatchesSelector(t *testing.T) {
281281
FieldPath: "spec.template.spec.bootstrap.configRef",
282282
},
283283
templateVariables: map[string]apiextensionsv1.JSON{
284-
"builtin": {Raw: []byte(`{"machineDeployment":{"class":"class-A"}}`)},
284+
runtimehooksv1.BuiltinsName: {Raw: []byte(`{"machineDeployment":{"class":"class-A"}}`)},
285285
},
286286
selector: clusterv1.PatchSelector{
287287
APIVersion: "bootstrap.cluster.x-k8s.io/v1beta1",
@@ -309,7 +309,7 @@ func TestMatchesSelector(t *testing.T) {
309309
FieldPath: "spec.template.spec.bootstrap.configRef",
310310
},
311311
templateVariables: map[string]apiextensionsv1.JSON{
312-
"builtin": {Raw: []byte(`{"machineDeployment":{"class":"class-A"}}`)},
312+
runtimehooksv1.BuiltinsName: {Raw: []byte(`{"machineDeployment":{"class":"class-A"}}`)},
313313
},
314314
selector: clusterv1.PatchSelector{
315315
APIVersion: "bootstrap.cluster.x-k8s.io/v1beta1",
@@ -337,7 +337,7 @@ func TestMatchesSelector(t *testing.T) {
337337
FieldPath: "spec.template.spec.bootstrap.configRef",
338338
},
339339
templateVariables: map[string]apiextensionsv1.JSON{
340-
"builtin": {Raw: []byte(`{"machineDeployment":{"class":"classA"}}`)},
340+
runtimehooksv1.BuiltinsName: {Raw: []byte(`{"machineDeployment":{"class":"classA"}}`)},
341341
},
342342
selector: clusterv1.PatchSelector{
343343
APIVersion: "bootstrap.cluster.x-k8s.io/v1beta1",
@@ -365,7 +365,7 @@ func TestMatchesSelector(t *testing.T) {
365365
FieldPath: "spec.template.spec.bootstrap.configRef",
366366
},
367367
templateVariables: map[string]apiextensionsv1.JSON{
368-
"builtin": {Raw: []byte(`{"machineDeployment":{"class":"classA"}}`)},
368+
runtimehooksv1.BuiltinsName: {Raw: []byte(`{"machineDeployment":{"class":"classA"}}`)},
369369
},
370370
selector: clusterv1.PatchSelector{
371371
APIVersion: "bootstrap.cluster.x-k8s.io/v1beta1",
@@ -391,7 +391,7 @@ func TestMatchesSelector(t *testing.T) {
391391
FieldPath: "spec.template.spec.bootstrap.configRef",
392392
},
393393
templateVariables: map[string]apiextensionsv1.JSON{
394-
"builtin": {Raw: []byte(`{"machineDeployment":{"class":"classA"}}`)},
394+
runtimehooksv1.BuiltinsName: {Raw: []byte(`{"machineDeployment":{"class":"classA"}}`)},
395395
},
396396
selector: clusterv1.PatchSelector{
397397
APIVersion: "bootstrap.cluster.x-k8s.io/v1beta1",
@@ -415,7 +415,7 @@ func TestMatchesSelector(t *testing.T) {
415415
FieldPath: "spec.template.spec.bootstrap.configRef",
416416
},
417417
templateVariables: map[string]apiextensionsv1.JSON{
418-
"builtin": {Raw: []byte(`{"machineDeployment":{"class":"classA"}}`)},
418+
runtimehooksv1.BuiltinsName: {Raw: []byte(`{"machineDeployment":{"class":"classA"}}`)},
419419
},
420420
selector: clusterv1.PatchSelector{
421421
APIVersion: "bootstrap.cluster.x-k8s.io/v1beta1",
@@ -443,7 +443,7 @@ func TestMatchesSelector(t *testing.T) {
443443
FieldPath: "spec.template.spec.infrastructureRef",
444444
},
445445
templateVariables: map[string]apiextensionsv1.JSON{
446-
"builtin": {Raw: []byte(`{"machineDeployment":{"class":"classA"}}`)},
446+
runtimehooksv1.BuiltinsName: {Raw: []byte(`{"machineDeployment":{"class":"classA"}}`)},
447447
},
448448
selector: clusterv1.PatchSelector{
449449
APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1",

pkg/handlers/aws/mutation/ami/inject_worker_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var _ = Describe("Generate AMI patches for Worker", func() {
3232
VariableName,
3333
),
3434
capitest.VariableWithValue(
35-
"builtin",
35+
runtimehooksv1.BuiltinsName,
3636
apiextensionsv1.JSON{
3737
Raw: []byte(`{"machineDeployment": {"class": "a-worker"}}`),
3838
},
@@ -63,7 +63,7 @@ var _ = Describe("Generate AMI patches for Worker", func() {
6363
VariableName,
6464
),
6565
capitest.VariableWithValue(
66-
"builtin",
66+
runtimehooksv1.BuiltinsName,
6767
apiextensionsv1.JSON{
6868
Raw: []byte(`{"machineDeployment": {"class": "a-worker"}}`),
6969
},

pkg/handlers/aws/mutation/iaminstanceprofile/inject_worker_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var _ = Describe("Generate IAMInstanceProfile patches for Worker", func() {
3535
VariableName,
3636
),
3737
capitest.VariableWithValue(
38-
"builtin",
38+
runtimehooksv1.BuiltinsName,
3939
apiextensionsv1.JSON{
4040
Raw: []byte(`{"machineDeployment": {"class": "a-worker"}}`),
4141
},

pkg/handlers/aws/mutation/instancetype/inject_worker_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var _ = Describe("Generate InstanceType patches for Worker", func() {
3535
VariableName,
3636
),
3737
capitest.VariableWithValue(
38-
"builtin",
38+
runtimehooksv1.BuiltinsName,
3939
apiextensionsv1.JSON{
4040
Raw: []byte(`{"machineDeployment": {"class": "a-worker"}}`),
4141
},

pkg/handlers/aws/mutation/placementgroup/inject_worker_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var _ = Describe("Generate PlacementGroup patches for Worker", func() {
3535
VariableName,
3636
),
3737
capitest.VariableWithValue(
38-
"builtin",
38+
runtimehooksv1.BuiltinsName,
3939
apiextensionsv1.JSON{
4040
Raw: []byte(`{"machineDeployment": {"class": "a-worker"}}`),
4141
},

pkg/handlers/aws/mutation/securitygroups/inject_worker_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var _ = Describe("Generate AWS SecurityGroups patches for Worker", func() {
3939
VariableName,
4040
),
4141
capitest.VariableWithValue(
42-
"builtin",
42+
runtimehooksv1.BuiltinsName,
4343
apiextensionsv1.JSON{
4444
Raw: []byte(`{"machineDeployment": {"class": "a-worker"}}`),
4545
},

pkg/handlers/docker/mutation/customimage/inject_control_plane.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (h *customImageControlPlanePatchHandler) Mutate(
9595
),
9696
log,
9797
func(obj *capdv1.DockerMachineTemplate) error {
98-
variablePath := []string{"builtin", "controlPlane", "version"}
98+
variablePath := []string{runtimehooksv1.BuiltinsName, "controlPlane", "version"}
9999

100100
if customImageVar == "" {
101101
kubernetesVersion, err := variables.Get[string](

pkg/handlers/docker/mutation/customimage/inject_control_plane_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var _ = Describe("Docker CustomImage patches for ControlPlane", func() {
2929
Name: "image unset for control plane",
3030
Vars: []runtimehooksv1.Variable{
3131
capitest.VariableWithValue(
32-
"builtin",
32+
runtimehooksv1.BuiltinsName,
3333
apiextensionsv1.JSON{Raw: []byte(`{"controlPlane": {"version": "v1.2.3"}}`)},
3434
),
3535
},
@@ -51,7 +51,7 @@ var _ = Describe("Docker CustomImage patches for ControlPlane", func() {
5151
VariableName,
5252
),
5353
capitest.VariableWithValue(
54-
"builtin",
54+
runtimehooksv1.BuiltinsName,
5555
apiextensionsv1.JSON{
5656
Raw: []byte(`{"machineDeployment": {"class": "a-worker"}}`),
5757
},

pkg/handlers/docker/mutation/customimage/inject_worker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (h *customImageWorkerPatchHandler) Mutate(
8787
),
8888
log,
8989
func(obj *capdv1.DockerMachineTemplate) error {
90-
fieldPath := []string{"builtin", "machineDeployment", "version"}
90+
fieldPath := []string{runtimehooksv1.BuiltinsName, "machineDeployment", "version"}
9191

9292
if customImageVar == "" {
9393
kubernetesVersion, err := variables.Get[string](

0 commit comments

Comments
 (0)