Skip to content

Commit

Permalink
Merge pull request #517 from weaveworks/fix-cluster-name-getters
Browse files Browse the repository at this point in the history
Fix regression in `getClusterName` helper
  • Loading branch information
errordeveloper authored Feb 7, 2019
2 parents 37cf2f6 + cc6ff3b commit cd49dfb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ coverage.out
# Test results
test-results/

integration/kubeconfig-*
19 changes: 12 additions & 7 deletions pkg/cfn/manager/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,9 @@ func (c *StackCollection) AppendNewClusterStackResource(dryRun bool) error {
}

func getClusterName(s *Stack) string {
for _, tag := range s.Tags {
if *tag.Key == api.ClusterNameTag {
if strings.HasSuffix(*s.StackName, "-cluster") ||
strings.Contains(*s.StackName, "-nodegroup-") {

return *tag.Value
}
if strings.HasSuffix(*s.StackName, "-cluster") {
if v := getClusterNameTag(s); v != "" {
return v
}
}

Expand All @@ -161,3 +157,12 @@ func getClusterName(s *Stack) string {
}
return ""
}

func getClusterNameTag(s *Stack) string {
for _, tag := range s.Tags {
if *tag.Key == api.ClusterNameTag {
return *tag.Value
}
}
return ""
}
2 changes: 1 addition & 1 deletion pkg/cfn/manager/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func (c *StackCollection) mapStackToNodeGroupSummary(stack *Stack) (*NodeGroupSu
return nil, errors.Wrapf(err, "error getting Cloudformation template for stack %s", *stack.StackName)
}

cluster := getClusterName(stack)
cluster := getClusterNameTag(stack)
name := getNodeGroupName(stack)
maxSize := gjson.Get(template, maxSizePath)
minSize := gjson.Get(template, minSizePath)
Expand Down

0 comments on commit cd49dfb

Please sign in to comment.