Skip to content

Commit 91a5e70

Browse files
committed
refactor: slice initializations to var syntax (#358)
1 parent 74871bb commit 91a5e70

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

internal/cluster/cluster_operations.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func TryConvertToClusterSpec(object map[string]interface{}) (*vcf.ClusterSpec, e
248248
if vdsRaw, ok := object["vds"]; ok {
249249
vdsList := vdsRaw.([]interface{})
250250
if len(vdsList) > 0 {
251-
vdsSpecs := []vcf.VdsSpec{}
251+
var vdsSpecs []vcf.VdsSpec
252252
for _, vdsListEntry := range vdsList {
253253
vdsSpec, err := network.TryConvertToVdsSpec(vdsListEntry.(map[string]interface{}))
254254
if err != nil {
@@ -321,7 +321,7 @@ func tryConvertToClusterDatastoreSpec(object map[string]interface{}, clusterName
321321
if nfsDatastoresRaw, ok := object["nfs_datastores"]; ok && !validationUtils.IsEmpty(nfsDatastoresRaw) {
322322
nfsDatastoresList := nfsDatastoresRaw.([]interface{})
323323
if len(nfsDatastoresList) > 0 {
324-
specs := []vcf.NfsDatastoreSpec{}
324+
var specs []vcf.NfsDatastoreSpec
325325
for _, nfsDatastoreListEntry := range nfsDatastoresList {
326326
nfsDatastoreSpec, err := datastores.TryConvertToNfsDatastoreSpec(
327327
nfsDatastoreListEntry.(map[string]interface{}))
@@ -337,7 +337,7 @@ func tryConvertToClusterDatastoreSpec(object map[string]interface{}, clusterName
337337
if vvolDatastoresRaw, ok := object["vvol_datastores"]; ok && !validationUtils.IsEmpty(vvolDatastoresRaw) {
338338
vvolDatastoresList := vvolDatastoresRaw.([]interface{})
339339
if len(vvolDatastoresList) > 0 {
340-
specs := []vcf.VvolDatastoreSpec{}
340+
var specs []vcf.VvolDatastoreSpec
341341
for _, vvolDatastoreListEntry := range vvolDatastoresList {
342342
vvolDatastoreSpec, err := datastores.TryConvertToVvolDatastoreSpec(
343343
vvolDatastoreListEntry.(map[string]interface{}))

internal/cluster/host_spec_subresource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func TryConvertToHostSpec(object map[string]interface{}) (*vcf.HostSpec, error)
138138
vmNicsList := vmNicsRaw.([]interface{})
139139
if len(vmNicsList) > 0 {
140140
result.HostNetworkSpec = &vcf.HostNetworkSpec{}
141-
vmNics := []vcf.VmNic{}
141+
var vmNics []vcf.VmNic
142142
for _, vmNicListEntry := range vmNicsList {
143143
vmNic, err := network.TryConvertToVmNic(vmNicListEntry.(map[string]interface{}))
144144
if err != nil {

internal/datastores/vmfs_datastore_subresource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func TryConvertToVmfsDatastoreSpec(object map[string]interface{}) (*vcf.VmfsData
3535
return nil, fmt.Errorf("cannot convert to VmfsDatastoreSpec, datastore_names is required")
3636
}
3737
result := &vcf.VmfsDatastoreSpec{}
38-
specs := []vcf.FcSpec{}
38+
var specs []vcf.FcSpec
3939
for _, datastoreName := range datastoreNames {
4040
specs = append(specs, vcf.FcSpec{DatastoreName: datastoreName})
4141
}

internal/datastores/vsan_remote_datastore_cluster_subresource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func TryConvertToVSANRemoteDatastoreClusterSpec(object map[string]interface{}) (
3535
return nil, fmt.Errorf("cannot convert to VSANRemoteDatastoreClusterSpec, datastore_uuids is required")
3636
}
3737
result := &vcf.VsanRemoteDatastoreClusterSpec{}
38-
specs := []vcf.VsanRemoteDatastoreSpec{}
38+
var specs []vcf.VsanRemoteDatastoreSpec
3939
for _, datastoreUuid := range datastoreUuids {
4040
specs = append(specs, vcf.VsanRemoteDatastoreSpec{DatastoreUuid: datastoreUuid})
4141
}

internal/network/ip_address_pool_subresource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func GetIpAddressPoolSpecFromSchema(object map[string]interface{}) (*vcf.IpAddre
102102
if subnetsRaw, ok := object["subnet"]; ok {
103103
subnetsList := subnetsRaw.([]interface{})
104104
if len(subnetsList) > 0 {
105-
subnets := []vcf.IpAddressPoolSubnetSpec{}
105+
var subnets []vcf.IpAddressPoolSubnetSpec
106106
for _, subnetsListEntry := range subnetsList {
107107
ipAddressPoolSubnetSpec, err := getIpAddressPoolSubnetSpecFromSchema(subnetsListEntry.(map[string]interface{}))
108108
if err != nil {

internal/network/vds_subresource.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TryConvertToVdsSpec(object map[string]interface{}) (*vcf.VdsSpec, error) {
6868
if portgroupsRaw, ok := object["portgroup"]; ok && !validationutils.IsEmpty(portgroupsRaw) {
6969
portgroupsList := portgroupsRaw.([]interface{})
7070
if len(portgroupsList) > 0 {
71-
portGroupSpecs := []vcf.PortgroupSpec{}
71+
var portGroupSpecs []vcf.PortgroupSpec
7272
for _, portgroupListEntry := range portgroupsList {
7373
portgroupSpec, err := tryConvertToPortgroupSpec(portgroupListEntry.(map[string]interface{}))
7474
if err != nil {
@@ -82,7 +82,7 @@ func TryConvertToVdsSpec(object map[string]interface{}) (*vcf.VdsSpec, error) {
8282
if niocBandwidthAllocationsRaw, ok := object["nioc_bandwidth_allocations"]; ok && !validationutils.IsEmpty(niocBandwidthAllocationsRaw) {
8383
niocBandwidthAllocationsList := niocBandwidthAllocationsRaw.([]interface{})
8484
if len(niocBandwidthAllocationsList) > 0 {
85-
specs := []vcf.NiocBandwidthAllocationSpec{}
85+
var specs []vcf.NiocBandwidthAllocationSpec
8686
for _, niocBandwidthAllocationListEntry := range niocBandwidthAllocationsList {
8787
niocBandwidthAllocationSpec, err := tryConvertToNiocBandwidthAllocationSpec(
8888
niocBandwidthAllocationListEntry.(map[string]interface{}))

internal/provider/data_host.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ func dataSourceHostRead(ctx context.Context, d *schema.ResourceData, meta interf
345345
_ = d.Set("network_pool", networkPool)
346346

347347
// CPU information.
348-
cpuCores := []map[string]interface{}{}
348+
var cpuCores []map[string]interface{}
349349
for _, core := range *host.Cpu.CpuCores {
350350
cpuCore := map[string]interface{}{
351351
"frequency_mhz": core.FrequencyMHz,
@@ -379,7 +379,7 @@ func dataSourceHostRead(ctx context.Context, d *schema.ResourceData, meta interf
379379
_ = d.Set("compatible_storage_type", host.CompatibleStorageType)
380380

381381
// Storage information.
382-
disks := []map[string]interface{}{}
382+
var disks []map[string]interface{}
383383
for _, disk := range *host.Storage.Disks {
384384
diskInfo := map[string]interface{}{
385385
"capacity_mb": disk.CapacityMB,
@@ -400,7 +400,7 @@ func dataSourceHostRead(ctx context.Context, d *schema.ResourceData, meta interf
400400
_ = d.Set("storage", storage)
401401

402402
// Physical NICs information.
403-
physicalNics := []map[string]interface{}{}
403+
var physicalNics []map[string]interface{}
404404
for _, nic := range *host.PhysicalNics {
405405
physicalNic := map[string]interface{}{
406406
"device_name": nic.DeviceName,
@@ -413,7 +413,7 @@ func dataSourceHostRead(ctx context.Context, d *schema.ResourceData, meta interf
413413
_ = d.Set("physical_nics", physicalNics)
414414

415415
// IP addresses information.
416-
ipAddresses := []map[string]interface{}{}
416+
var ipAddresses []map[string]interface{}
417417
for _, ip := range *host.IpAddresses {
418418
ipAddress := map[string]interface{}{
419419
"ip_address": ip.IpAddress,

0 commit comments

Comments
 (0)