mirror of https://github.com/kubernetes/kops.git
Address review comments
This commit is contained in:
parent
fdf976809e
commit
1d6a51aff9
|
|
@ -145,7 +145,7 @@ func ListResourcesAWS(cloud awsup.AWSCloud, clusterName string) (map[string]*res
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
lts, err := FindAutoScalingLaunchTemplates(cloud, clusterName, securityGroups)
|
||||
lts, err := FindAutoScalingLaunchTemplates(cloud, clusterName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -1179,8 +1179,8 @@ func ListAutoScalingGroups(cloud fi.Cloud, clusterName string) ([]*resources.Res
|
|||
return resourceTrackers, nil
|
||||
}
|
||||
|
||||
// FindAutoScalingLaunchTemplates finds any launch configurations which reference the security groups
|
||||
func FindAutoScalingLaunchTemplates(cloud fi.Cloud, clusterName string, securityGroups sets.String) ([]*resources.Resource, error) {
|
||||
// FindAutoScalingLaunchTemplates finds any launch templates owned by the cluster (by tag).
|
||||
func FindAutoScalingLaunchTemplates(cloud fi.Cloud, clusterName string) ([]*resources.Resource, error) {
|
||||
c := cloud.(awsup.AWSCloud)
|
||||
|
||||
klog.V(2).Infof("Finding all AutoScaling LaunchTemplates owned by the cluster")
|
||||
|
|
@ -1188,8 +1188,8 @@ func FindAutoScalingLaunchTemplates(cloud fi.Cloud, clusterName string, security
|
|||
input := &ec2.DescribeLaunchTemplatesInput{
|
||||
Filters: []*ec2.Filter{
|
||||
{
|
||||
Name: aws.String("tag:KubernetesCluster"),
|
||||
Values: []*string{aws.String(clusterName)},
|
||||
Name: aws.String("tag:kubernetes.io/cluster/" + clusterName),
|
||||
Values: []*string{aws.String("owned")},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,15 +147,14 @@ func (t *LaunchTemplate) CheckChanges(a, e, changes *LaunchTemplate) error {
|
|||
func (t *LaunchTemplate) FindDeletions(c *fi.Context) ([]fi.Deletion, error) {
|
||||
var removals []fi.Deletion
|
||||
|
||||
configurations, err := t.findAllLaunchTemplates(c)
|
||||
list, err := t.findAllLaunchTemplates(c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prefix := fmt.Sprintf("%s-", fi.StringValue(t.Name))
|
||||
for _, configuration := range configurations {
|
||||
if strings.HasPrefix(aws.StringValue(configuration.LaunchTemplateName), prefix) {
|
||||
removals = append(removals, &deleteLaunchTemplate{lc: configuration})
|
||||
for _, lt := range list {
|
||||
if aws.StringValue(lt.LaunchTemplateName) != aws.StringValue(t.Name) {
|
||||
removals = append(removals, &deleteLaunchTemplate{lc: lt})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ func (t *LaunchTemplate) findAllLaunchTemplates(c *fi.Context) ([]*ec2.LaunchTem
|
|||
return list, nil
|
||||
}
|
||||
|
||||
// findLatestLaunchTemplateVersion returns the latest template
|
||||
// findLatestLaunchTemplateVersion returns the latest template version
|
||||
func (t *LaunchTemplate) findLatestLaunchTemplateVersion(c *fi.Context) (*ec2.LaunchTemplateVersion, error) {
|
||||
cloud, ok := c.Cloud.(awsup.AWSCloud)
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -723,10 +723,10 @@ func findAutoscalingGroupLaunchConfiguration(c AWSCloud, g *autoscaling.Group) (
|
|||
return "", fmt.Errorf("error finding launch template by ID: %q", id)
|
||||
}
|
||||
launchTemplate := output.LaunchTemplates[0]
|
||||
if version == "" || version == "$Default" {
|
||||
version = strconv.FormatInt(*launchTemplate.DefaultVersionNumber, 10)
|
||||
} else {
|
||||
if version == "$Latest" {
|
||||
version = strconv.FormatInt(*launchTemplate.LatestVersionNumber, 10)
|
||||
} else {
|
||||
version = strconv.FormatInt(*launchTemplate.DefaultVersionNumber, 10)
|
||||
}
|
||||
}
|
||||
klog.V(4).Infof("Launch Template Version used for compare: %q", version)
|
||||
|
|
|
|||
Loading…
Reference in New Issue