mirror of https://github.com/kubernetes/kops.git
replace slice loop with append for simple and clear
Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
This commit is contained in:
parent
2afa3490f0
commit
c295a49bb1
|
@ -260,9 +260,7 @@ func (m *MockEC2) AuthorizeSecurityGroupEgress(request *ec2.AuthorizeSecurityGro
|
|||
sg.IpPermissionsEgress = append(sg.IpPermissionsEgress, p)
|
||||
}
|
||||
|
||||
for _, p := range request.IpPermissions {
|
||||
sg.IpPermissionsEgress = append(sg.IpPermissionsEgress, p)
|
||||
}
|
||||
sg.IpPermissionsEgress = append(sg.IpPermissionsEgress, request.IpPermissions...)
|
||||
|
||||
// TODO: We need to fold permissions
|
||||
|
||||
|
@ -318,9 +316,7 @@ func (m *MockEC2) AuthorizeSecurityGroupIngress(request *ec2.AuthorizeSecurityGr
|
|||
sg.IpPermissions = append(sg.IpPermissions, p)
|
||||
}
|
||||
|
||||
for _, p := range request.IpPermissions {
|
||||
sg.IpPermissions = append(sg.IpPermissions, p)
|
||||
}
|
||||
sg.IpPermissions = append(sg.IpPermissions, request.IpPermissions...)
|
||||
|
||||
// TODO: We need to fold permissions
|
||||
|
||||
|
|
|
@ -60,9 +60,7 @@ func (r *Route53APIStub) ListResourceRecordSetsPages(input *route53.ListResource
|
|||
output.ResourceRecordSets = []*route53.ResourceRecordSet{}
|
||||
} else {
|
||||
for _, rrsets := range r.recordSets[*input.HostedZoneId] {
|
||||
for _, rrset := range rrsets {
|
||||
output.ResourceRecordSets = append(output.ResourceRecordSets, rrset)
|
||||
}
|
||||
output.ResourceRecordSets = append(output.ResourceRecordSets, rrsets...)
|
||||
}
|
||||
}
|
||||
lastPage := true
|
||||
|
|
|
@ -144,9 +144,7 @@ func run() error {
|
|||
}
|
||||
}
|
||||
|
||||
for _, p := range result.PriceList {
|
||||
prices = append(prices, p)
|
||||
}
|
||||
prices = append(prices, result.PriceList...)
|
||||
|
||||
if result.NextToken != nil {
|
||||
input.NextToken = result.NextToken
|
||||
|
|
|
@ -545,9 +545,7 @@ func (b *KubeletBuilder) buildKubeletConfigSpec() (*kops.KubeletConfigSpec, erro
|
|||
|
||||
// Use --register-with-taints for k8s 1.6 and on
|
||||
if b.Cluster.IsKubernetesGTE("1.6") {
|
||||
for _, t := range b.InstanceGroup.Spec.Taints {
|
||||
c.Taints = append(c.Taints, t)
|
||||
}
|
||||
c.Taints = append(c.Taints, b.InstanceGroup.Spec.Taints...)
|
||||
|
||||
if len(c.Taints) == 0 && isMaster {
|
||||
// (Even though the value is empty, we still expect <Key>=<Value>:<Effect>)
|
||||
|
|
|
@ -64,9 +64,7 @@ func (s *gcsAclStrategy) GetACL(p vfs.Path, cluster *kops.Cluster) (vfs.ACL, err
|
|||
}
|
||||
|
||||
var acls []*storage.ObjectAccessControl
|
||||
for _, a := range bucket.DefaultObjectAcl {
|
||||
acls = append(acls, a)
|
||||
}
|
||||
acls = append(acls, bucket.DefaultObjectAcl...)
|
||||
|
||||
acls = append(acls, &storage.ObjectAccessControl{
|
||||
Email: serviceAccount,
|
||||
|
|
|
@ -310,9 +310,7 @@ func (b *AutoscalingGroupModelBuilder) buildAutoScalingGroupTask(c *fi.ModelBuil
|
|||
t.Tags = tags
|
||||
|
||||
processes := []string{}
|
||||
for _, p := range ig.Spec.SuspendProcesses {
|
||||
processes = append(processes, p)
|
||||
}
|
||||
processes = append(processes, ig.Spec.SuspendProcesses...)
|
||||
t.SuspendProcesses = &processes
|
||||
|
||||
t.InstanceProtection = ig.Spec.InstanceProtection
|
||||
|
|
|
@ -327,9 +327,7 @@ func (d *clusterDiscoveryALI) ListSecurityGroup() ([]*resources.Resource, error)
|
|||
}
|
||||
}
|
||||
|
||||
for _, block := range blocked {
|
||||
groupTracker.Blocked = append(groupTracker.Blocked, block)
|
||||
}
|
||||
groupTracker.Blocked = append(groupTracker.Blocked, blocked...)
|
||||
resourceTrackers = append(resourceTrackers, groupTracker)
|
||||
}
|
||||
}
|
||||
|
@ -558,9 +556,7 @@ func (d *clusterDiscoveryALI) ListVPC() ([]*resources.Resource, error) {
|
|||
for _, vpc := range vpcs {
|
||||
if name == vpc.VpcName {
|
||||
vpcsToDelete = append(vpcsToDelete, vpc.VpcId)
|
||||
for _, vswitch := range vpc.VSwitchIds.VSwitchId {
|
||||
vswitchsToDelete = append(vswitchsToDelete, vswitch)
|
||||
}
|
||||
vswitchsToDelete = append(vswitchsToDelete, vpc.VSwitchIds.VSwitchId...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -258,9 +258,7 @@ func FindAutoscalingLaunchConfiguration(cloud awsup.AWSCloud, name string) (*aut
|
|||
LaunchConfigurationNames: []*string{&name},
|
||||
}
|
||||
err := cloud.Autoscaling().DescribeLaunchConfigurationsPages(request, func(p *autoscaling.DescribeLaunchConfigurationsOutput, lastPage bool) bool {
|
||||
for _, t := range p.LaunchConfigurations {
|
||||
results = append(results, t)
|
||||
}
|
||||
results = append(results, p.LaunchConfigurations...)
|
||||
return true
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -1094,9 +1092,7 @@ func DescribeInternetGateways(cloud fi.Cloud) ([]*ec2.InternetGateway, error) {
|
|||
}
|
||||
|
||||
var gateways []*ec2.InternetGateway
|
||||
for _, o := range response.InternetGateways {
|
||||
gateways = append(gateways, o)
|
||||
}
|
||||
gateways = append(gateways, response.InternetGateways...)
|
||||
|
||||
return gateways, nil
|
||||
}
|
||||
|
@ -1116,9 +1112,7 @@ func DescribeInternetGatewaysIgnoreTags(cloud fi.Cloud) ([]*ec2.InternetGateway,
|
|||
|
||||
var gateways []*ec2.InternetGateway
|
||||
|
||||
for _, igw := range response.InternetGateways {
|
||||
gateways = append(gateways, igw)
|
||||
}
|
||||
gateways = append(gateways, response.InternetGateways...)
|
||||
|
||||
return gateways, nil
|
||||
}
|
||||
|
|
|
@ -40,9 +40,7 @@ func DeleteResources(cloud fi.Cloud, resourceMap map[string]*resources.Resource)
|
|||
depMap[block] = append(depMap[block], k)
|
||||
}
|
||||
|
||||
for _, blocked := range t.Blocked {
|
||||
depMap[k] = append(depMap[k], blocked)
|
||||
}
|
||||
depMap[k] = append(depMap[k], t.Blocked...)
|
||||
|
||||
if t.Done {
|
||||
done[k] = t
|
||||
|
|
|
@ -62,9 +62,7 @@ func (p *SeedProvider) GetSeeds() ([]string, error) {
|
|||
|
||||
for _, instance := range instances {
|
||||
// TODO: Multiple IP addresses?
|
||||
for _, ip := range instance.VpcAttributes.PrivateIpAddress.IpAddress {
|
||||
seeds = append(seeds, ip)
|
||||
}
|
||||
seeds = append(seeds, instance.VpcAttributes.PrivateIpAddress.IpAddress...)
|
||||
}
|
||||
|
||||
return seeds, nil
|
||||
|
|
|
@ -33,9 +33,7 @@ func (p *GossipDnsProvider) Replace(fqdn string, values []string) error {
|
|||
Name: fqdn,
|
||||
RrsType: "A",
|
||||
}
|
||||
for _, value := range values {
|
||||
record.Rrdatas = append(record.Rrdatas, value)
|
||||
}
|
||||
record.Rrdatas = append(record.Rrdatas, values...)
|
||||
return p.DNSView.ApplyChangeset(p.Zone, nil, []*dns.DNSRecord{record})
|
||||
}
|
||||
|
||||
|
|
|
@ -66,9 +66,7 @@ func performNetworkAssignmentsIPAliases(ctx context.Context, c *kops.Cluster, cl
|
|||
|
||||
var regions []*compute.Region
|
||||
if err := cloud.Compute().Regions.List(cloud.Project()).Pages(ctx, func(p *compute.RegionList) error {
|
||||
for _, r := range p.Items {
|
||||
regions = append(regions, r)
|
||||
}
|
||||
regions = append(regions, p.Items...)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return fmt.Errorf("error listing Regions: %v", err)
|
||||
|
@ -89,9 +87,7 @@ func performNetworkAssignmentsIPAliases(ctx context.Context, c *kops.Cluster, cl
|
|||
var subnets []*compute.Subnetwork
|
||||
for _, r := range regions {
|
||||
if err := cloud.Compute().Subnetworks.List(cloud.Project(), r.Name).Pages(ctx, func(p *compute.SubnetworkList) error {
|
||||
for _, s := range p.Items {
|
||||
subnets = append(subnets, s)
|
||||
}
|
||||
subnets = append(subnets, p.Items...)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return fmt.Errorf("error listing Subnetworks: %v", err)
|
||||
|
|
|
@ -73,9 +73,7 @@ func (e *Instance) Find(c *fi.Context) (*Instance, error) {
|
|||
|
||||
actual := &Instance{}
|
||||
actual.Name = &r.Name
|
||||
for _, tag := range r.Tags.Items {
|
||||
actual.Tags = append(actual.Tags, tag)
|
||||
}
|
||||
actual.Tags = append(actual.Tags, r.Tags.Items...)
|
||||
actual.Zone = fi.String(lastComponent(r.Zone))
|
||||
actual.MachineType = fi.String(lastComponent(r.MachineType))
|
||||
actual.CanIPForward = &r.CanIpForward
|
||||
|
|
|
@ -103,9 +103,7 @@ func (e *InstanceTemplate) Find(c *fi.Context) (*InstanceTemplate, error) {
|
|||
|
||||
p := r.Properties
|
||||
|
||||
for _, tag := range p.Tags.Items {
|
||||
actual.Tags = append(actual.Tags, tag)
|
||||
}
|
||||
actual.Tags = append(actual.Tags, p.Tags.Items...)
|
||||
actual.MachineType = fi.String(lastComponent(p.MachineType))
|
||||
actual.CanIPForward = &p.CanIpForward
|
||||
|
||||
|
|
|
@ -635,9 +635,7 @@ func findInstances(c awsup.AWSCloud) ([]*ec2.Instance, error) {
|
|||
|
||||
err := c.EC2().DescribeInstancesPages(request, func(p *ec2.DescribeInstancesOutput, lastPage bool) bool {
|
||||
for _, reservation := range p.Reservations {
|
||||
for _, instance := range reservation.Instances {
|
||||
instances = append(instances, instance)
|
||||
}
|
||||
instances = append(instances, reservation.Instances...)
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue