Skip to content

Commit

Permalink
Group informative struct fields together
Browse files Browse the repository at this point in the history
  • Loading branch information
errordeveloper committed Jul 11, 2018
1 parent 337425a commit 51b3989
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions pkg/eks/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ const (
)

type ClusterProvider struct {
// core fields used for config and AWS APIs
cfg *ClusterConfig
svc *providerServices

// informative fields, i.e. used as outputs
iamRoleARN string
sessionCreds *credentials.Credentials
}

Expand All @@ -41,7 +44,6 @@ type providerServices struct {
eks eksiface.EKSAPI
ec2 ec2iface.EC2API
sts stsiface.STSAPI
arn string
}

// simple config, to be replaced with Cluster API
Expand Down Expand Up @@ -144,8 +146,8 @@ func (c *ClusterProvider) CheckAuth() error {
if err != nil {
return errors.Wrap(err, "checking AWS STS access – cannot get role ARN for current session")
}
c.svc.arn = *output.Arn
logger.Debug("role ARN for the current session is %q", c.svc.arn)
c.iamRoleARN = *output.Arn
logger.Debug("role ARN for the current session is %q", c.iamRoleARN)
}
{
input := &cloudformation.ListStacksInput{}
Expand Down
4 changes: 2 additions & 2 deletions pkg/eks/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (c *ClusterProvider) MaybeDeletePublicSSHKey() {
}

func (c *ClusterProvider) getUsername() string {
usernameParts := strings.Split(c.svc.arn, "/")
usernameParts := strings.Split(c.iamRoleARN, "/")
if len(usernameParts) > 1 {
return usernameParts[len(usernameParts)-1]
}
Expand Down Expand Up @@ -179,7 +179,7 @@ func (c *ClusterProvider) NewClientConfig() (*ClientConfig, error) {
},
ClusterName: clusterName,
ContextName: contextName,
roleARN: c.svc.arn,
roleARN: c.iamRoleARN,
sts: c.svc.sts,
}

Expand Down

0 comments on commit 51b3989

Please sign in to comment.