mirror of https://github.com/kubernetes/kops.git
FIX: Change int fields to string
The ./hack/update-expected.sh script generates some fields which are required to be string fields and hence results in linting errors. This PR changes those fields to string/*string and removes lint warnings.
This commit is contained in:
parent
7f035dc824
commit
e32717f31d
|
|
@ -314,21 +314,21 @@ func (b *AutoscalingGroupModelBuilder) buildAutoScalingGroupTask(c *fi.ModelBuil
|
|||
},
|
||||
}
|
||||
|
||||
minSize := int32(1)
|
||||
maxSize := int32(1)
|
||||
minSize := fi.Int64(1)
|
||||
maxSize := fi.Int64(1)
|
||||
if ig.Spec.MinSize != nil {
|
||||
minSize = fi.Int32Value(ig.Spec.MinSize)
|
||||
minSize = fi.Int64(int64(*ig.Spec.MinSize))
|
||||
} else if ig.Spec.Role == kops.InstanceGroupRoleNode {
|
||||
minSize = 2
|
||||
minSize = fi.Int64(2)
|
||||
}
|
||||
if ig.Spec.MaxSize != nil {
|
||||
maxSize = *ig.Spec.MaxSize
|
||||
maxSize = fi.Int64(int64(*ig.Spec.MaxSize))
|
||||
} else if ig.Spec.Role == kops.InstanceGroupRoleNode {
|
||||
maxSize = 2
|
||||
maxSize = fi.Int64(2)
|
||||
}
|
||||
|
||||
t.MinSize = fi.Int64(int64(minSize))
|
||||
t.MaxSize = fi.Int64(int64(maxSize))
|
||||
t.MinSize = minSize
|
||||
t.MaxSize = maxSize
|
||||
|
||||
subnets, err := b.GatherSubnets(ig)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -862,8 +862,8 @@ type cloudformationAutoscalingGroup struct {
|
|||
Name *string `json:"AutoScalingGroupName,omitempty"`
|
||||
LaunchConfigurationName *cloudformation.Literal `json:"LaunchConfigurationName,omitempty"`
|
||||
LaunchTemplate *cloudformationAutoscalingLaunchTemplateSpecification `json:"LaunchTemplate,omitempty"`
|
||||
MaxSize *int64 `json:"MaxSize,omitempty"`
|
||||
MinSize *int64 `json:"MinSize,omitempty"`
|
||||
MaxSize *string `json:"MaxSize,omitempty"`
|
||||
MinSize *string `json:"MinSize,omitempty"`
|
||||
VPCZoneIdentifier []*cloudformation.Literal `json:"VPCZoneIdentifier,omitempty"`
|
||||
Tags []*cloudformationASGTag `json:"Tags,omitempty"`
|
||||
MetricsCollection []*cloudformationASGMetricsCollection `json:"MetricsCollection,omitempty"`
|
||||
|
|
@ -876,8 +876,8 @@ type cloudformationAutoscalingGroup struct {
|
|||
func (_ *AutoscalingGroup) RenderCloudformation(t *cloudformation.CloudformationTarget, a, e, changes *AutoscalingGroup) error {
|
||||
cf := &cloudformationAutoscalingGroup{
|
||||
Name: e.Name,
|
||||
MinSize: e.MinSize,
|
||||
MaxSize: e.MaxSize,
|
||||
MinSize: fi.ToString(e.MinSize),
|
||||
MaxSize: fi.ToString(e.MaxSize),
|
||||
MetricsCollection: []*cloudformationASGMetricsCollection{
|
||||
{
|
||||
Granularity: e.Granularity,
|
||||
|
|
|
|||
|
|
@ -349,8 +349,8 @@ func TestAutoscalingGroupCloudformationRender(t *testing.T) {
|
|||
"Type": "AWS::AutoScaling::AutoScalingGroup",
|
||||
"Properties": {
|
||||
"AutoScalingGroupName": "test1",
|
||||
"MaxSize": 10,
|
||||
"MinSize": 5,
|
||||
"MaxSize": "10",
|
||||
"MinSize": "5",
|
||||
"VPCZoneIdentifier": [
|
||||
{
|
||||
"Ref": "AWSEC2Subnettestsg"
|
||||
|
|
|
|||
|
|
@ -805,18 +805,18 @@ type cloudformationLoadBalancer struct {
|
|||
}
|
||||
|
||||
type cloudformationLoadBalancerListener struct {
|
||||
InstancePort int `json:"InstancePort"`
|
||||
InstancePort string `json:"InstancePort"`
|
||||
InstanceProtocol string `json:"InstanceProtocol"`
|
||||
LoadBalancerPort int64 `json:"LoadBalancerPort"`
|
||||
LoadBalancerPort string `json:"LoadBalancerPort"`
|
||||
LoadBalancerProtocol string `json:"Protocol"`
|
||||
}
|
||||
|
||||
type cloudformationLoadBalancerHealthCheck struct {
|
||||
Target *string `json:"Target"`
|
||||
HealthyThreshold *int64 `json:"HealthyThreshold"`
|
||||
UnhealthyThreshold *int64 `json:"UnhealthyThreshold"`
|
||||
Interval *int64 `json:"Interval"`
|
||||
Timeout *int64 `json:"Timeout"`
|
||||
HealthyThreshold *string `json:"HealthyThreshold"`
|
||||
UnhealthyThreshold *string `json:"UnhealthyThreshold"`
|
||||
Interval *string `json:"Interval"`
|
||||
Timeout *string `json:"Timeout"`
|
||||
}
|
||||
|
||||
type cloudformationConnectionDrainingPolicy struct {
|
||||
|
|
@ -853,15 +853,11 @@ func (_ *LoadBalancer) RenderCloudformation(t *cloudformation.CloudformationTarg
|
|||
}
|
||||
|
||||
for loadBalancerPort, listener := range e.Listeners {
|
||||
loadBalancerPortInt, err := strconv.ParseInt(loadBalancerPort, 10, 64)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error parsing load balancer listener port: %q", loadBalancerPort)
|
||||
}
|
||||
|
||||
tf.Listener = append(tf.Listener, &cloudformationLoadBalancerListener{
|
||||
InstanceProtocol: "TCP",
|
||||
InstancePort: listener.InstancePort,
|
||||
LoadBalancerPort: loadBalancerPortInt,
|
||||
InstancePort: strconv.Itoa(listener.InstancePort),
|
||||
LoadBalancerPort: loadBalancerPort,
|
||||
LoadBalancerProtocol: "TCP",
|
||||
})
|
||||
}
|
||||
|
|
@ -869,10 +865,10 @@ func (_ *LoadBalancer) RenderCloudformation(t *cloudformation.CloudformationTarg
|
|||
if e.HealthCheck != nil {
|
||||
tf.HealthCheck = &cloudformationLoadBalancerHealthCheck{
|
||||
Target: e.HealthCheck.Target,
|
||||
HealthyThreshold: e.HealthCheck.HealthyThreshold,
|
||||
UnhealthyThreshold: e.HealthCheck.UnhealthyThreshold,
|
||||
Interval: e.HealthCheck.Interval,
|
||||
Timeout: e.HealthCheck.Timeout,
|
||||
HealthyThreshold: fi.ToString(e.HealthCheck.HealthyThreshold),
|
||||
UnhealthyThreshold: fi.ToString(e.HealthCheck.UnhealthyThreshold),
|
||||
Interval: fi.ToString(e.HealthCheck.Interval),
|
||||
Timeout: fi.ToString(e.HealthCheck.Timeout),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func StringValue(s *string) string {
|
||||
|
|
@ -202,3 +203,22 @@ func DebugAsJsonStringIndent(v interface{}) string {
|
|||
}
|
||||
return string(data)
|
||||
}
|
||||
|
||||
func ToInt64(s *string) *int64 {
|
||||
if s == nil {
|
||||
return nil
|
||||
}
|
||||
v, err := strconv.ParseInt(*s, 10, 64)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return &v
|
||||
}
|
||||
|
||||
func ToString(v *int64) *string {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
s := strconv.FormatInt(*v, 10)
|
||||
return &s
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue