Skip to content

Commit c308731

Browse files
Merge pull request #334 from fmount/modernize
Modernize Go code with latest style conventions
2 parents 96633d0 + 40433cf commit c308731

File tree

5 files changed

+55
-55
lines changed

5 files changed

+55
-55
lines changed

containers/agent/checksum_discovery.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ func runChecksumStartCmd(_ *cobra.Command, _ []string) {
146146
}
147147

148148
if unstructured.Object["status"] == nil {
149-
unstructured.Object["status"] = map[string]interface{}{}
149+
unstructured.Object["status"] = map[string]any{}
150150
}
151151

152-
status := unstructured.Object["status"].(map[string]interface{})
152+
status := unstructured.Object["status"].(map[string]any)
153153

154154
status["osImageChecksumFilename"] = checksumFileName
155155
status["osImageChecksumType"] = checksumType

containers/agent/provision_ip_discovery.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ func updateProvisioningStatus(provServerClient dynamic.NamespaceableResourceInte
147147
}
148148

149149
if unstructured.Object["status"] == nil {
150-
unstructured.Object["status"] = map[string]interface{}{}
150+
unstructured.Object["status"] = map[string]any{}
151151
}
152152

153-
status := unstructured.Object["status"].(map[string]interface{})
153+
status := unstructured.Object["status"].(map[string]any)
154154
if curIP == "" {
155155
var errMsg, errMsgFull string
156156
if intfFound {

controllers/openstackprovisionserver_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ func (r *OpenStackProvisionServerReconciler) generateServiceConfigMaps(
605605

606606
cmLabels := labels.GetLabels(instance, openstackprovisionserver.AppLabel, map[string]string{})
607607

608-
templateParameters := make(map[string]interface{})
608+
templateParameters := make(map[string]any)
609609
templateParameters["Port"] = strconv.FormatInt(int64(instance.Spec.Port), 10)
610610
templateParameters["DocumentRoot"] = instance.Spec.OSImageDir
611611

@@ -706,7 +706,7 @@ func (r *OpenStackProvisionServerReconciler) getProvisioningInterface(
706706

707707
provisioningSpecIntf := provisioning.Object["spec"]
708708

709-
if provisioningSpec, ok := provisioningSpecIntf.(map[string]interface{}); ok {
709+
if provisioningSpec, ok := provisioningSpecIntf.(map[string]any); ok {
710710
bootMode := provisioningSpec["provisioningNetwork"]
711711
if bootMode == nil || bootMode != baremetalv1.ProvisioningNetworkManaged {
712712
return "", nil

pkg/openstackbaremetalset/baremetalhost.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func BaremetalHostProvision(
5959
sts := []util.Template{}
6060
// User data cloud-init secret
6161
if userDataSecret == nil {
62-
templateParameters := make(map[string]interface{})
62+
templateParameters := make(map[string]any)
6363
templateParameters["AuthorizedKeys"] = strings.TrimSuffix(string(sshSecret.Data["authorized_keys"]), "\n")
6464
templateParameters["HostName"] = hostName
6565
//If Hostname is fqdn, use it
@@ -108,7 +108,7 @@ func BaremetalHostProvision(
108108
CtlplaneIPVersion = "ipv4"
109109
}
110110

111-
templateParameters := make(map[string]interface{})
111+
templateParameters := make(map[string]any)
112112
templateParameters["CtlplaneIpVersion"] = CtlplaneIPVersion
113113
templateParameters["CtlplaneIp"] = ipAddr
114114
if instance.Spec.BaremetalHosts[hostName].CtlplaneVlan != nil {

tests/functional/base_test.go

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ import (
2929
)
3030

3131
// Create OpenstackBaremetalSet in k8s and test that no errors occur
32-
func CreateBaremetalSet(name types.NamespacedName, spec map[string]interface{}) *unstructured.Unstructured {
32+
func CreateBaremetalSet(name types.NamespacedName, spec map[string]any) *unstructured.Unstructured {
3333
instance := DefaultBaremetalSetTemplate(name, spec)
3434
return th.CreateUnstructured(instance)
3535
}
3636

3737
// Build OpenStackBaremetalSet struct and fill it with preset values
38-
func DefaultBaremetalSetTemplate(name types.NamespacedName, spec map[string]interface{}) map[string]interface{} {
39-
return map[string]interface{}{
38+
func DefaultBaremetalSetTemplate(name types.NamespacedName, spec map[string]any) map[string]any {
39+
return map[string]any{
4040

4141
"apiVersion": "baremetal.openstack.org/v1beta1",
4242
"kind": "OpenStackBaremetalSet",
43-
"metadata": map[string]interface{}{
43+
"metadata": map[string]any{
4444
"name": name.Name,
4545
"namespace": name.Namespace,
4646
},
@@ -49,10 +49,10 @@ func DefaultBaremetalSetTemplate(name types.NamespacedName, spec map[string]inte
4949
}
5050

5151
// Build BaremetalSetSpec struct and fill it with preset values
52-
func DefaultBaremetalSetSpec(name types.NamespacedName, withProvInterface bool) map[string]interface{} {
53-
spec := map[string]interface{}{
54-
"baremetalHosts": map[string]interface{}{
55-
"compute-0": map[string]interface{}{
52+
func DefaultBaremetalSetSpec(name types.NamespacedName, withProvInterface bool) map[string]any {
53+
spec := map[string]any{
54+
"baremetalHosts": map[string]any{
55+
"compute-0": map[string]any{
5656
"ctlPlaneIP": "10.0.0.1",
5757
},
5858
},
@@ -74,13 +74,13 @@ func DefaultBaremetalSetSpec(name types.NamespacedName, withProvInterface bool)
7474
}
7575

7676
// Build BaremetalSetSpec struct for two nodes
77-
func TwoNodeBaremetalSetSpec(namespace string) map[string]interface{} {
78-
spec := map[string]interface{}{
79-
"baremetalHosts": map[string]interface{}{
80-
"compute-0": map[string]interface{}{
77+
func TwoNodeBaremetalSetSpec(namespace string) map[string]any {
78+
spec := map[string]any{
79+
"baremetalHosts": map[string]any{
80+
"compute-0": map[string]any{
8181
"ctlPlaneIP": "10.0.0.1",
8282
},
83-
"compute-1": map[string]interface{}{
83+
"compute-1": map[string]any{
8484
"ctlPlaneIP": "10.0.0.1",
8585
},
8686
},
@@ -92,14 +92,14 @@ func TwoNodeBaremetalSetSpec(namespace string) map[string]interface{} {
9292
return spec
9393
}
9494

95-
func TwoNodeBaremetalSetSpecWithNodeLabel(namespace string) map[string]interface{} {
96-
spec := map[string]interface{}{
97-
"baremetalHosts": map[string]interface{}{
98-
"compute-0": map[string]interface{}{
95+
func TwoNodeBaremetalSetSpecWithNodeLabel(namespace string) map[string]any {
96+
spec := map[string]any{
97+
"baremetalHosts": map[string]any{
98+
"compute-0": map[string]any{
9999
"ctlPlaneIP": "10.0.0.1",
100100
"bmhLabelSelector": map[string]string{"nodeName": "compute-0"},
101101
},
102-
"compute-1": map[string]interface{}{
102+
"compute-1": map[string]any{
103103
"ctlPlaneIP": "10.0.0.1",
104104
"bmhLabelSelector": map[string]string{"nodeName": "compute-1"},
105105
},
@@ -112,14 +112,14 @@ func TwoNodeBaremetalSetSpecWithNodeLabel(namespace string) map[string]interface
112112
return spec
113113
}
114114

115-
func TwoNodeBaremetalSetSpecWithWrongNodeLabel(namespace string) map[string]interface{} {
116-
spec := map[string]interface{}{
117-
"baremetalHosts": map[string]interface{}{
118-
"compute-0": map[string]interface{}{
115+
func TwoNodeBaremetalSetSpecWithWrongNodeLabel(namespace string) map[string]any {
116+
spec := map[string]any{
117+
"baremetalHosts": map[string]any{
118+
"compute-0": map[string]any{
119119
"ctlPlaneIP": "10.0.0.1",
120120
"bmhLabelSelector": map[string]string{"nodeName": "compute-0"},
121121
},
122-
"compute-1": map[string]interface{}{
122+
"compute-1": map[string]any{
123123
"ctlPlaneIP": "10.0.0.1",
124124
"bmhLabelSelector": map[string]string{"nodeName": "compute-2"},
125125
},
@@ -132,18 +132,18 @@ func TwoNodeBaremetalSetSpecWithWrongNodeLabel(namespace string) map[string]inte
132132
return spec
133133
}
134134

135-
func MultiNodeBaremetalSetSpecWithSameNodeLabel(namespace string) map[string]interface{} {
136-
spec := map[string]interface{}{
137-
"baremetalHosts": map[string]interface{}{
138-
"compute-0": map[string]interface{}{
135+
func MultiNodeBaremetalSetSpecWithSameNodeLabel(namespace string) map[string]any {
136+
spec := map[string]any{
137+
"baremetalHosts": map[string]any{
138+
"compute-0": map[string]any{
139139
"ctlPlaneIP": "10.0.0.1",
140140
"bmhLabelSelector": map[string]string{"nodeType": "compute"},
141141
},
142-
"compute-1": map[string]interface{}{
142+
"compute-1": map[string]any{
143143
"ctlPlaneIP": "10.0.0.2",
144144
"bmhLabelSelector": map[string]string{"nodeType": "compute"},
145145
},
146-
"compute-2": map[string]interface{}{
146+
"compute-2": map[string]any{
147147
"ctlPlaneIP": "10.0.0.3",
148148
"bmhLabelSelector": map[string]string{"nodeType": "compute"},
149149
},
@@ -156,18 +156,18 @@ func MultiNodeBaremetalSetSpecWithSameNodeLabel(namespace string) map[string]int
156156
return spec
157157
}
158158

159-
func MultiNodeBaremetalSetSpecWithOverlappingNodeLabels(namespace string) map[string]interface{} {
160-
spec := map[string]interface{}{
161-
"baremetalHosts": map[string]interface{}{
162-
"compute-0": map[string]interface{}{
159+
func MultiNodeBaremetalSetSpecWithOverlappingNodeLabels(namespace string) map[string]any {
160+
spec := map[string]any{
161+
"baremetalHosts": map[string]any{
162+
"compute-0": map[string]any{
163163
"ctlPlaneIP": "10.0.0.1",
164164
"bmhLabelSelector": map[string]string{"nodeType": "compute", "dummyLabel": "dummy"},
165165
},
166-
"compute-1": map[string]interface{}{
166+
"compute-1": map[string]any{
167167
"ctlPlaneIP": "10.0.0.2",
168168
"bmhLabelSelector": map[string]string{"nodeType": "compute", "nodeName": "compute-1"},
169169
},
170-
"compute-2": map[string]interface{}{
170+
"compute-2": map[string]any{
171171
"ctlPlaneIP": "10.0.0.3",
172172
"bmhLabelSelector": map[string]string{"nodeType": "compute", "dummyLabel": "dummy"},
173173
},
@@ -181,22 +181,22 @@ func MultiNodeBaremetalSetSpecWithOverlappingNodeLabels(namespace string) map[st
181181
}
182182

183183
// Default BMH Template with preset values
184-
func DefaultBMHTemplate(name types.NamespacedName) map[string]interface{} {
185-
return map[string]interface{}{
184+
func DefaultBMHTemplate(name types.NamespacedName) map[string]any {
185+
return map[string]any{
186186
"apiVersion": "metal3.io/v1alpha1",
187187
"kind": "BareMetalHost",
188-
"metadata": map[string]interface{}{
188+
"metadata": map[string]any{
189189
"name": name.Name,
190190
"namespace": name.Namespace,
191191
"labels": map[string]string{
192192
"app": "openstack",
193193
},
194-
"annotations": map[string]interface{}{
194+
"annotations": map[string]any{
195195
"inspect.metal3.io": "disabled",
196196
},
197197
},
198-
"spec": map[string]interface{}{
199-
"bmc": map[string]interface{}{
198+
"spec": map[string]any{
199+
"bmc": map[string]any{
200200
"address": "fake_address",
201201
"credentialsName": "fake_credential",
202202
},
@@ -208,21 +208,21 @@ func DefaultBMHTemplate(name types.NamespacedName) map[string]interface{} {
208208
}
209209

210210
// Default BMH Template with preset values
211-
func BMHTemplateWithNodeLabels(name types.NamespacedName, nodeLabels map[string]string) map[string]interface{} {
211+
func BMHTemplateWithNodeLabels(name types.NamespacedName, nodeLabels map[string]string) map[string]any {
212212
labels := util.MergeMaps(map[string]string{"app": "openstack"}, nodeLabels)
213-
return map[string]interface{}{
213+
return map[string]any{
214214
"apiVersion": "metal3.io/v1alpha1",
215215
"kind": "BareMetalHost",
216-
"metadata": map[string]interface{}{
216+
"metadata": map[string]any{
217217
"name": name.Name,
218218
"namespace": name.Namespace,
219219
"labels": labels,
220-
"annotations": map[string]interface{}{
220+
"annotations": map[string]any{
221221
"inspect.metal3.io": "disabled",
222222
},
223223
},
224-
"spec": map[string]interface{}{
225-
"bmc": map[string]interface{}{
224+
"spec": map[string]any{
225+
"bmc": map[string]any{
226226
"address": "fake_address",
227227
"credentialsName": "fake_credential",
228228
},

0 commit comments

Comments
 (0)