Skip to content

Commit

Permalink
se unique cluster alias as identifier rather than redundant eksID
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Linkhorst <[email protected]>
  • Loading branch information
linki committed Sep 20, 2024
1 parent 6695a52 commit 2a211c0
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 18 deletions.
2 changes: 1 addition & 1 deletion provisioner/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ type EKSClusterDetails struct {

func (a *awsAdapter) GetEKSClusterDetails(cluster *api.Cluster) (*EKSClusterDetails, error) {
resp, err := a.eksClient.DescribeCluster(&eks.DescribeClusterInput{
Name: aws.String(eksID(cluster.ID)),
Name: aws.String(cluster.Alias),
})
if err != nil {
return nil, err
Expand Down
6 changes: 0 additions & 6 deletions provisioner/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func renderTemplate(context *templateContext, file string) (string, error) {
"azID": azID,
"azCount": azCount,
"split": split,
"eksID": eksID,
"mountUnitName": mountUnitName,
"accountID": accountID,
"portRanges": portRanges,
Expand Down Expand Up @@ -281,11 +280,6 @@ func list(args ...interface{}) []interface{} {
return args
}

func eksID(id string) string {
parts := strings.Split(id, ":")
return parts[len(parts)-1]
}

// accountID returns just the ID part of an account
func accountID(account string) (string, error) {
items := strings.Split(account, ":")
Expand Down
9 changes: 0 additions & 9 deletions provisioner/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,6 @@ func TestAccountIDFailsOnInvalid(t *testing.T) {
require.Error(t, err)
}

func TestEKSID(t *testing.T) {
result, err := renderSingle(
t,
`{{ eksID "aws:000000:eu-north-1:kube-1" }}`,
"")
require.NoError(t, err)
require.EqualValues(t, "kube-1", result)
}

func TestParsePortRanges(t *testing.T) {
testTemplate := `{{- if index .Values.data.portRanges -}}
{{- range $index, $element := portRanges .Values.data.portRanges -}}
Expand Down
4 changes: 2 additions & 2 deletions provisioner/zalando_eks.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (z *ZalandoEKSProvisioner) Provision(
return fmt.Errorf("failed to setup AWS Adapter: %v", err)
}

eksTokenSource := eks.NewTokenSource(awsAdapter.session, eksID(cluster.ID))
eksTokenSource := eks.NewTokenSource(awsAdapter.session, cluster.Alias)

logger.Infof(
"clusterpy: Prepare for provisioning EKS cluster %s (%s)..",
Expand Down Expand Up @@ -127,7 +127,7 @@ func (z *ZalandoEKSProvisioner) Decommission(
}

cluster.APIServerURL = cluster.ConfigItems[KeyEKSEndpoint]
tokenSource := eks.NewTokenSource(awsAdapter.session, eksID(cluster.ID))
tokenSource := eks.NewTokenSource(awsAdapter.session, cluster.Alias)

return z.decommission(
ctx,
Expand Down

0 comments on commit 2a211c0

Please sign in to comment.