Skip to content

Commit ac3a60c

Browse files
committed
goreleaser bug
1 parent 24680cb commit ac3a60c

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

spectrocloud/kubevirt/schema/virtualmachineinstance/domain_spec.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ package virtualmachineinstance
22

33
import (
44
"fmt"
5+
"math"
56

67
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
78
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
89
"k8s.io/apimachinery/pkg/api/resource"
910
kubevirtapiv1 "kubevirt.io/api/core/v1"
1011

11-
"github.com/spectrocloud/terraform-provider-spectrocloud/spectrocloud/constants"
1212
"github.com/spectrocloud/terraform-provider-spectrocloud/spectrocloud/kubevirt/utils"
1313
)
1414

@@ -289,19 +289,19 @@ func expandCPU(cpu map[string]interface{}) (kubevirtapiv1.CPU, error) {
289289
}
290290

291291
if v, ok := cpu["cores"].(int); ok {
292-
if v < 0 || v > constants.UInt32MaxValue {
292+
if v < 0 || uint64(v) > math.MaxUint32 {
293293
return result, fmt.Errorf("cores value %d is out of range for uint32", v)
294294
}
295295
result.Cores = uint32(v)
296296
}
297297
if v, ok := cpu["sockets"].(int); ok {
298-
if v < 0 || v > constants.UInt32MaxValue {
298+
if v < 0 || uint64(v) > math.MaxUint32 {
299299
return result, fmt.Errorf("sockets value %d is out of range for uint32", v)
300300
}
301301
result.Sockets = uint32(v)
302302
}
303303
if v, ok := cpu["threads"].(int); ok {
304-
if v < 0 || v > constants.UInt32MaxValue {
304+
if v < 0 || uint64(v) > math.MaxUint32 {
305305
return result, fmt.Errorf("threads value %d is out of range for uint32", v)
306306
}
307307
result.Threads = uint32(v)

spectrocloud/resource_cluster_vsphere.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"log"
8+
"math"
89
"sort"
910
"strings"
1011
"time"
@@ -15,7 +16,6 @@ import (
1516
"github.com/spectrocloud/palette-sdk-go/api/models"
1617
"github.com/spectrocloud/palette-sdk-go/client"
1718

18-
"github.com/spectrocloud/terraform-provider-spectrocloud/spectrocloud/constants"
1919
"github.com/spectrocloud/terraform-provider-spectrocloud/spectrocloud/schemas"
2020
"github.com/spectrocloud/terraform-provider-spectrocloud/types"
2121
)
@@ -855,7 +855,7 @@ func toMachinePoolVsphere(machinePool interface{}) (*models.V1VsphereMachinePool
855855
memoryInt := ins["memory_mb"].(int)
856856
cpuInt := ins["cpu"].(int)
857857

858-
if diskSizeInt > constants.Int32MaxValue || memoryInt > constants.Int64MaxValue || cpuInt > constants.Int32MaxValue {
858+
if uint64(diskSizeInt) > math.MaxInt32 || uint64(memoryInt) > math.MaxInt64 || uint64(cpuInt) > math.MaxInt32 {
859859
return nil, fmt.Errorf("instance type values out of range: disk_size_gb=%d, memory_mb=%d, cpu=%d", diskSizeInt, memoryInt, cpuInt)
860860
}
861861

@@ -866,7 +866,7 @@ func toMachinePoolVsphere(machinePool interface{}) (*models.V1VsphereMachinePool
866866
}
867867

868868
countInt := m["count"].(int)
869-
if countInt > constants.Int32MaxValue {
869+
if uint64(countInt) > math.MaxInt32 {
870870
return nil, fmt.Errorf("count value %d is out of range for int32", countInt)
871871
}
872872

@@ -875,15 +875,15 @@ func toMachinePoolVsphere(machinePool interface{}) (*models.V1VsphereMachinePool
875875

876876
if m["min"] != nil {
877877
minInt := m["min"].(int)
878-
if minInt > constants.Int32MaxValue {
878+
if uint64(minInt) > math.MaxInt32 {
879879
return nil, fmt.Errorf("min value %d is out of range for int32", minInt)
880880
}
881881
min = SafeInt32(minInt)
882882
}
883883

884884
if m["max"] != nil {
885885
maxInt := m["max"].(int)
886-
if maxInt > constants.Int32MaxValue {
886+
if uint64(maxInt) > math.MaxInt32 {
887887
return nil, fmt.Errorf("max value %d is out of range for int32", maxInt)
888888
}
889889
max = SafeInt32(maxInt)
@@ -915,13 +915,13 @@ func toMachinePoolVsphere(machinePool interface{}) (*models.V1VsphereMachinePool
915915
if m["node_repave_interval"] != nil {
916916
nodeRepaveInterval = m["node_repave_interval"].(int)
917917
}
918-
if nodeRepaveInterval > constants.Int32MaxValue {
918+
if uint64(nodeRepaveInterval) > math.MaxInt32 {
919919
return nil, fmt.Errorf("node_repave_interval value %d is out of range for int32", nodeRepaveInterval)
920920
}
921921
mp.PoolConfig.NodeRepaveInterval = SafeInt32(nodeRepaveInterval)
922922
} else {
923923
nodeRepaveInterval := m["node_repave_interval"].(int)
924-
if nodeRepaveInterval > constants.Int32MaxValue {
924+
if uint64(nodeRepaveInterval) > math.MaxInt32 {
925925
return nil, fmt.Errorf("node_repave_interval value %d is out of range for int32", nodeRepaveInterval)
926926
}
927927
err := ValidationNodeRepaveIntervalForControlPlane(nodeRepaveInterval)

spectrocloud/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func SafeUint32(value int) uint32 {
2727
if value < 0 {
2828
return 0
2929
}
30-
if value > math.MaxUint32 {
30+
if uint64(value) > math.MaxUint32 {
3131
return math.MaxUint32
3232
}
3333
return uint32(value)

0 commit comments

Comments
 (0)