Skip to content

Commit 70f28fa

Browse files
authored
chore: make consistent make() calls (#2154)
1 parent f4cfa2c commit 70f28fa

21 files changed

+95
-95
lines changed

kubernetes/patch_operations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
func diffStringMap(pathPrefix string, oldV, newV map[string]interface{}) PatchOperations {
14-
ops := make([]PatchOperation, 0, 0)
14+
ops := make([]PatchOperation, 0)
1515

1616
pathPrefix = strings.TrimRight(pathPrefix, "/")
1717

kubernetes/resource_kubernetes_ingress_class.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func flattenIngressClassSpec(in networking.IngressClassSpec) []interface{} {
299299
}
300300

301301
func flattenIngressClassParameters(in *networking.IngressClassParametersReference) []interface{} {
302-
att := make([]interface{}, 1, 1)
302+
att := make([]interface{}, 1)
303303

304304
m := make(map[string]interface{})
305305
m["kind"] = in.Kind

kubernetes/structure_csi_driver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func expandCSIDriverSpec(l []interface{}) storage.CSIDriverSpec {
3131
}
3232

3333
func expandCSIDriverVolumeLifecycleModes(l []interface{}) []storage.VolumeLifecycleMode {
34-
lifecycleModes := make([]storage.VolumeLifecycleMode, 0, 0)
34+
lifecycleModes := make([]storage.VolumeLifecycleMode, 0)
3535
for _, lifecycleMode := range l {
3636
lifecycleModes = append(lifecycleModes, storage.VolumeLifecycleMode(lifecycleMode.(string)))
3737
}
@@ -55,7 +55,7 @@ func flattenCSIDriverSpec(in storage.CSIDriverSpec) ([]interface{}, error) {
5555
}
5656

5757
func patchCSIDriverSpec(keyPrefix, pathPrefix string, d *schema.ResourceData) (*PatchOperations, error) {
58-
ops := make(PatchOperations, 0, 0)
58+
ops := make(PatchOperations, 0)
5959
if d.HasChange(keyPrefix + "attach_required") {
6060
ops = append(ops, &ReplaceOperation{
6161
Path: pathPrefix + "/attachRequired",

kubernetes/structure_csi_driver_v1.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func expandCSIDriverV1Spec(l []interface{}) storage.CSIDriverSpec {
3131
}
3232

3333
func expandCSIDriverV1VolumeLifecycleModes(l []interface{}) []storage.VolumeLifecycleMode {
34-
lifecycleModes := make([]storage.VolumeLifecycleMode, 0, 0)
34+
lifecycleModes := make([]storage.VolumeLifecycleMode, 0)
3535
for _, lifecycleMode := range l {
3636
lifecycleModes = append(lifecycleModes, storage.VolumeLifecycleMode(lifecycleMode.(string)))
3737
}
@@ -55,7 +55,7 @@ func flattenCSIDriverV1Spec(in storage.CSIDriverSpec) ([]interface{}, error) {
5555
}
5656

5757
func patchCSIDriverV1Spec(keyPrefix, pathPrefix string, d *schema.ResourceData) (*PatchOperations, error) {
58-
ops := make(PatchOperations, 0, 0)
58+
ops := make(PatchOperations, 0)
5959
if d.HasChange(keyPrefix + "attach_required") {
6060
ops = append(ops, &ReplaceOperation{
6161
Path: pathPrefix + "/attachRequired",

kubernetes/structure_endpoints.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func expandEndpointsSubsets(in *schema.Set) []api.EndpointSubset {
7575
}
7676

7777
func flattenEndpointsAddresses(in []api.EndpointAddress) *schema.Set {
78-
att := make([]interface{}, len(in), len(in))
78+
att := make([]interface{}, len(in))
7979
for i, n := range in {
8080
m := make(map[string]interface{})
8181
if n.Hostname != "" {
@@ -91,7 +91,7 @@ func flattenEndpointsAddresses(in []api.EndpointAddress) *schema.Set {
9191
}
9292

9393
func flattenEndpointsPorts(in []api.EndpointPort) *schema.Set {
94-
att := make([]interface{}, len(in), len(in))
94+
att := make([]interface{}, len(in))
9595
for i, n := range in {
9696
m := make(map[string]interface{})
9797
if n.Name != "" {
@@ -105,7 +105,7 @@ func flattenEndpointsPorts(in []api.EndpointPort) *schema.Set {
105105
}
106106

107107
func flattenEndpointsSubsets(in []api.EndpointSubset) *schema.Set {
108-
att := make([]interface{}, len(in), len(in))
108+
att := make([]interface{}, len(in))
109109
for i, n := range in {
110110
m := make(map[string]interface{})
111111
if len(n.Addresses) > 0 {

kubernetes/structure_endpointslice.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func expandEndpointSliceCondition(in []interface{}) api.EndpointConditions {
120120
}
121121

122122
func flattenEndpointSliceEndpoints(in []api.Endpoint) []interface{} {
123-
att := make([]interface{}, len(in), len(in))
123+
att := make([]interface{}, len(in))
124124
for i, e := range in {
125125
m := make(map[string]interface{})
126126
if e.Hostname != nil {
@@ -165,7 +165,7 @@ func flattenEndpointSliceConditions(in api.EndpointConditions) []interface{} {
165165
}
166166

167167
func flattenEndpointSlicePorts(in []api.EndpointPort) []interface{} {
168-
att := make([]interface{}, len(in), len(in))
168+
att := make([]interface{}, len(in))
169169
for i, e := range in {
170170
m := make(map[string]interface{})
171171
if *e.Name != "" {

kubernetes/structure_ingress_spec.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
// Flatteners
1313

1414
func flattenIngressRule(in []v1beta1.IngressRule) []interface{} {
15-
att := make([]interface{}, len(in), len(in))
15+
att := make([]interface{}, len(in))
1616
for i, r := range in {
1717
m := make(map[string]interface{})
1818

@@ -27,7 +27,7 @@ func flattenIngressRuleHttp(in *v1beta1.HTTPIngressRuleValue) []interface{} {
2727
if in == nil {
2828
return []interface{}{}
2929
}
30-
pathAtts := make([]interface{}, len(in.Paths), len(in.Paths))
30+
pathAtts := make([]interface{}, len(in.Paths))
3131
for i, p := range in.Paths {
3232
path := map[string]interface{}{
3333
"path": p.Path,
@@ -44,7 +44,7 @@ func flattenIngressRuleHttp(in *v1beta1.HTTPIngressRuleValue) []interface{} {
4444
}
4545

4646
func flattenIngressBackend(in *v1beta1.IngressBackend) []interface{} {
47-
att := make([]interface{}, 1, 1)
47+
att := make([]interface{}, 1)
4848

4949
m := make(map[string]interface{})
5050
m["service_name"] = in.ServiceName
@@ -78,7 +78,7 @@ func flattenIngressSpec(in v1beta1.IngressSpec) []interface{} {
7878
}
7979

8080
func flattenIngressTLS(in []v1beta1.IngressTLS) []interface{} {
81-
att := make([]interface{}, len(in), len(in))
81+
att := make([]interface{}, len(in))
8282

8383
for i, v := range in {
8484
m := make(map[string]interface{})
@@ -97,7 +97,7 @@ func expandIngressRule(l []interface{}) []v1beta1.IngressRule {
9797
if len(l) == 0 || l[0] == nil {
9898
return []v1beta1.IngressRule{}
9999
}
100-
obj := make([]v1beta1.IngressRule, len(l), len(l))
100+
obj := make([]v1beta1.IngressRule, len(l))
101101
for i, n := range l {
102102
cfg := n.(map[string]interface{})
103103

@@ -109,7 +109,7 @@ func expandIngressRule(l []interface{}) []v1beta1.IngressRule {
109109
http := h.(map[string]interface{})
110110
if v, ok := http["path"]; ok {
111111
pathList := v.([]interface{})
112-
paths = make([]v1beta1.HTTPIngressPath, len(pathList), len(pathList))
112+
paths = make([]v1beta1.HTTPIngressPath, len(pathList))
113113
for i, path := range pathList {
114114
p := path.(map[string]interface{})
115115
hip := v1beta1.HTTPIngressPath{
@@ -183,7 +183,7 @@ func expandIngressTLS(l []interface{}) []v1beta1.IngressTLS {
183183
return nil
184184
}
185185

186-
tlsList := make([]v1beta1.IngressTLS, len(l), len(l))
186+
tlsList := make([]v1beta1.IngressTLS, len(l))
187187
for i, t := range l {
188188
in := t.(map[string]interface{})
189189
obj := v1beta1.IngressTLS{}
@@ -204,7 +204,7 @@ func expandIngressTLS(l []interface{}) []v1beta1.IngressTLS {
204204
// Patch Ops
205205

206206
func patchIngressSpec(keyPrefix, pathPrefix string, d *schema.ResourceData) PatchOperations {
207-
ops := make([]PatchOperation, 0, 0)
207+
ops := make([]PatchOperation, 0)
208208
if d.HasChange(keyPrefix + "backend") {
209209
ops = append(ops, &ReplaceOperation{
210210
Path: pathPrefix + "backend",

kubernetes/structure_ingress_spec_v1.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
// Flatteners
1414

1515
func flattenIngressV1Rule(in []networking.IngressRule) []interface{} {
16-
att := make([]interface{}, len(in), len(in))
16+
att := make([]interface{}, len(in))
1717
for i, r := range in {
1818
m := make(map[string]interface{})
1919

@@ -28,7 +28,7 @@ func flattenIngressV1RuleHttp(in *networking.HTTPIngressRuleValue) []interface{}
2828
if in == nil {
2929
return []interface{}{}
3030
}
31-
pathAtts := make([]interface{}, len(in.Paths), len(in.Paths))
31+
pathAtts := make([]interface{}, len(in.Paths))
3232
for i, p := range in.Paths {
3333
path := map[string]interface{}{
3434
"path": p.Path,
@@ -105,7 +105,7 @@ func flattenIngressV1Spec(in networking.IngressSpec) []interface{} {
105105
}
106106

107107
func flattenIngressV1TLS(in []networking.IngressTLS) []interface{} {
108-
att := make([]interface{}, len(in), len(in))
108+
att := make([]interface{}, len(in))
109109

110110
for i, v := range in {
111111
m := make(map[string]interface{})
@@ -124,7 +124,7 @@ func expandIngressV1Rule(l []interface{}) []networking.IngressRule {
124124
if len(l) == 0 || l[0] == nil {
125125
return []networking.IngressRule{}
126126
}
127-
obj := make([]networking.IngressRule, len(l), len(l))
127+
obj := make([]networking.IngressRule, len(l))
128128
for i, n := range l {
129129
cfg := n.(map[string]interface{})
130130

@@ -136,7 +136,7 @@ func expandIngressV1Rule(l []interface{}) []networking.IngressRule {
136136
http := h.(map[string]interface{})
137137
if v, ok := http["path"]; ok {
138138
pathList := v.([]interface{})
139-
paths = make([]networking.HTTPIngressPath, len(pathList), len(pathList))
139+
paths = make([]networking.HTTPIngressPath, len(pathList))
140140
for i, path := range pathList {
141141
p := path.(map[string]interface{})
142142
t := networking.PathType(p["path_type"].(string))
@@ -242,7 +242,7 @@ func expandIngressV1TLS(l []interface{}) []networking.IngressTLS {
242242
return nil
243243
}
244244

245-
tlsList := make([]networking.IngressTLS, len(l), len(l))
245+
tlsList := make([]networking.IngressTLS, len(l))
246246
for i, t := range l {
247247
in := t.(map[string]interface{})
248248
obj := networking.IngressTLS{}
@@ -263,7 +263,7 @@ func expandIngressV1TLS(l []interface{}) []networking.IngressTLS {
263263
// Patch Ops
264264

265265
func patchIngressV1Spec(keyPrefix, pathPrefix string, d *schema.ResourceData) PatchOperations {
266-
ops := make([]PatchOperation, 0, 0)
266+
ops := make([]PatchOperation, 0)
267267
if d.HasChange(keyPrefix + "backend") {
268268
ops = append(ops, &ReplaceOperation{
269269
Path: pathPrefix + "backend",

kubernetes/structure_label_selector.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func flattenLabelSelector(in *metav1.LabelSelector) []interface{} {
2222
}
2323

2424
func flattenLabelSelectorRequirement(in []metav1.LabelSelectorRequirement) []interface{} {
25-
att := make([]interface{}, len(in), len(in))
25+
att := make([]interface{}, len(in))
2626
for i, n := range in {
2727
m := make(map[string]interface{})
2828
m["key"] = n.Key
@@ -54,7 +54,7 @@ func expandLabelSelectorRequirement(l []interface{}) []metav1.LabelSelectorRequi
5454
if len(l) == 0 || l[0] == nil {
5555
return []metav1.LabelSelectorRequirement{}
5656
}
57-
obj := make([]metav1.LabelSelectorRequirement, len(l), len(l))
57+
obj := make([]metav1.LabelSelectorRequirement, len(l))
5858
for i, n := range l {
5959
in := n.(map[string]interface{})
6060
obj[i] = metav1.LabelSelectorRequirement{

kubernetes/structure_network_policy.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1010
api "k8s.io/api/core/v1"
11-
"k8s.io/api/networking/v1"
11+
v1 "k8s.io/api/networking/v1"
1212
"k8s.io/apimachinery/pkg/util/intstr"
1313
)
1414

@@ -30,7 +30,7 @@ func flattenNetworkPolicySpec(in v1.NetworkPolicySpec) []interface{} {
3030
}
3131

3232
func flattenNetworkPolicyIngress(in []v1.NetworkPolicyIngressRule) []interface{} {
33-
att := make([]interface{}, len(in), len(in))
33+
att := make([]interface{}, len(in))
3434
for i, ingress := range in {
3535
m := make(map[string]interface{})
3636
if ingress.Ports != nil && len(ingress.Ports) > 0 {
@@ -45,7 +45,7 @@ func flattenNetworkPolicyIngress(in []v1.NetworkPolicyIngressRule) []interface{}
4545
}
4646

4747
func flattenNetworkPolicyEgress(in []v1.NetworkPolicyEgressRule) []interface{} {
48-
att := make([]interface{}, len(in), len(in))
48+
att := make([]interface{}, len(in))
4949
for i, egress := range in {
5050
m := make(map[string]interface{})
5151
if egress.Ports != nil && len(egress.Ports) > 0 {
@@ -60,7 +60,7 @@ func flattenNetworkPolicyEgress(in []v1.NetworkPolicyEgressRule) []interface{} {
6060
}
6161

6262
func flattenNetworkPolicyPorts(in []v1.NetworkPolicyPort) []interface{} {
63-
att := make([]interface{}, len(in), len(in))
63+
att := make([]interface{}, len(in))
6464
for i, port := range in {
6565
m := make(map[string]interface{})
6666
if port.Port != nil {
@@ -75,7 +75,7 @@ func flattenNetworkPolicyPorts(in []v1.NetworkPolicyPort) []interface{} {
7575
}
7676

7777
func flattenNetworkPolicyPeer(in []v1.NetworkPolicyPeer) []interface{} {
78-
att := make([]interface{}, len(in), len(in))
78+
att := make([]interface{}, len(in))
7979
for i, peer := range in {
8080
m := make(map[string]interface{})
8181
if peer.IPBlock != nil {
@@ -141,7 +141,7 @@ func expandNetworkPolicySpec(in []interface{}) (*v1.NetworkPolicySpec, error) {
141141
}
142142

143143
func expandNetworkPolicyIngress(l []interface{}) (*[]v1.NetworkPolicyIngressRule, error) {
144-
ingresses := make([]v1.NetworkPolicyIngressRule, len(l), len(l))
144+
ingresses := make([]v1.NetworkPolicyIngressRule, len(l))
145145
for i, ingress := range l {
146146
if ingress == nil {
147147
continue
@@ -170,7 +170,7 @@ func expandNetworkPolicyIngress(l []interface{}) (*[]v1.NetworkPolicyIngressRule
170170
}
171171

172172
func expandNetworkPolicyEgress(l []interface{}) (*[]v1.NetworkPolicyEgressRule, error) {
173-
egresses := make([]v1.NetworkPolicyEgressRule, len(l), len(l))
173+
egresses := make([]v1.NetworkPolicyEgressRule, len(l))
174174
for i, egress := range l {
175175
if egress == nil {
176176
continue
@@ -199,7 +199,7 @@ func expandNetworkPolicyEgress(l []interface{}) (*[]v1.NetworkPolicyEgressRule,
199199
}
200200

201201
func expandNetworkPolicyPorts(l []interface{}) (*[]v1.NetworkPolicyPort, error) {
202-
policyPorts := make([]v1.NetworkPolicyPort, len(l), len(l))
202+
policyPorts := make([]v1.NetworkPolicyPort, len(l))
203203
for i, port := range l {
204204
in, ok := port.(map[string]interface{})
205205
if !ok {
@@ -218,7 +218,7 @@ func expandNetworkPolicyPorts(l []interface{}) (*[]v1.NetworkPolicyPort, error)
218218
}
219219

220220
func expandNetworkPolicyPeer(l []interface{}) (*[]v1.NetworkPolicyPeer, error) {
221-
policyPeers := make([]v1.NetworkPolicyPeer, len(l), len(l))
221+
policyPeers := make([]v1.NetworkPolicyPeer, len(l))
222222
for i, peer := range l {
223223
if peer == nil {
224224
continue
@@ -263,7 +263,7 @@ func expandIPBlock(l []interface{}) (*v1.IPBlock, error) {
263263
}
264264

265265
func expandNetworkPolicyTypes(l []interface{}) (*[]v1.PolicyType, error) {
266-
policyTypes := make([]v1.PolicyType, 0, 0)
266+
policyTypes := make([]v1.PolicyType, 0)
267267
for _, policyType := range l {
268268
policyTypes = append(policyTypes, v1.PolicyType(policyType.(string)))
269269
}
@@ -273,7 +273,7 @@ func expandNetworkPolicyTypes(l []interface{}) (*[]v1.PolicyType, error) {
273273
// Patchers
274274

275275
func patchNetworkPolicySpec(keyPrefix, pathPrefix string, d *schema.ResourceData) (*PatchOperations, error) {
276-
ops := make(PatchOperations, 0, 0)
276+
ops := make(PatchOperations, 0)
277277
if d.HasChange(keyPrefix + "ingress") {
278278
oldV, _ := d.GetChange(keyPrefix + "ingress")
279279
ingress, err := expandNetworkPolicyIngress(d.Get(keyPrefix + "ingress").([]interface{}))

0 commit comments

Comments
 (0)