@@ -11,32 +11,32 @@ import (
11
11
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1"
12
12
)
13
13
14
- func groupVersionKind (kind string ) schema.GroupVersionKind {
14
+ func GroupVersionKind (kind string ) schema.GroupVersionKind {
15
15
return schema.GroupVersionKind {
16
16
Group : "metallb.io" ,
17
17
Version : "v1beta1" ,
18
18
Kind : kind ,
19
19
}
20
20
}
21
21
22
- type configurationInput struct {
23
- name string
24
- namespace string
25
- addressRanges []v1alpha1.AddressRange
22
+ type ConfigurationInput struct {
23
+ Name string
24
+ Namespace string
25
+ AddressRanges []v1alpha1.AddressRange
26
26
}
27
27
28
- func configurationObjects (input * configurationInput ) ([]unstructured.Unstructured , error ) {
29
- if len (input .addressRanges ) == 0 {
30
- return nil , fmt .Errorf ("must define one or more addressRanges " )
28
+ func ConfigurationObjects (input * ConfigurationInput ) ([]* unstructured.Unstructured , error ) {
29
+ if len (input .AddressRanges ) == 0 {
30
+ return nil , fmt .Errorf ("must define one or more AddressRanges " )
31
31
}
32
32
33
- ipAddressPool := unstructured.Unstructured {}
34
- ipAddressPool .SetGroupVersionKind (groupVersionKind ("IPAddressPool" ))
35
- ipAddressPool .SetName (input .name )
36
- ipAddressPool .SetNamespace (input .namespace )
33
+ ipAddressPool := & unstructured.Unstructured {}
34
+ ipAddressPool .SetGroupVersionKind (GroupVersionKind ("IPAddressPool" ))
35
+ ipAddressPool .SetName (input .Name )
36
+ ipAddressPool .SetNamespace (input .Namespace )
37
37
38
38
addresses := []string {}
39
- for _ , ar := range input .addressRanges {
39
+ for _ , ar := range input .AddressRanges {
40
40
addresses = append (addresses , fmt .Sprintf ("%s-%s" , ar .Start , ar .End ))
41
41
}
42
42
if err := unstructured .SetNestedStringSlice (
@@ -48,10 +48,10 @@ func configurationObjects(input *configurationInput) ([]unstructured.Unstructure
48
48
return nil , fmt .Errorf ("failed to set IPAddressPool .spec.addresses: %w" , err )
49
49
}
50
50
51
- l2Advertisement := unstructured.Unstructured {}
52
- l2Advertisement .SetGroupVersionKind (groupVersionKind ("L2Advertisement" ))
53
- l2Advertisement .SetName (input .name )
54
- l2Advertisement .SetNamespace (input .namespace )
51
+ l2Advertisement := & unstructured.Unstructured {}
52
+ l2Advertisement .SetGroupVersionKind (GroupVersionKind ("L2Advertisement" ))
53
+ l2Advertisement .SetName (input .Name )
54
+ l2Advertisement .SetNamespace (input .Namespace )
55
55
56
56
if err := unstructured .SetNestedStringSlice (
57
57
l2Advertisement .Object ,
@@ -64,7 +64,7 @@ func configurationObjects(input *configurationInput) ([]unstructured.Unstructure
64
64
return nil , fmt .Errorf ("failed to set L2Advertisement .spec.ipAddressPools: %w" , err )
65
65
}
66
66
67
- return []unstructured.Unstructured {
67
+ return []* unstructured.Unstructured {
68
68
ipAddressPool ,
69
69
l2Advertisement ,
70
70
}, nil
0 commit comments