Skip to content

Commit daf85a3

Browse files
author
Byron Wolfman
committed
Tune/address review feedback
1 parent fc8b9c6 commit daf85a3

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

internal/aws.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,18 @@ func readRoleFromAWS(role string, request *Request) (*iam.Role, error) {
8585
return roleObject, nil
8686
}
8787

88-
func constructAssumeRoleInput(arn string, externalId string, sessionName string) (*sts.AssumeRoleInput) {
88+
func constructAssumeRoleInput(arn string, externalId string) (*sts.AssumeRoleInput) {
8989
if externalId == "" {
9090
return &sts.AssumeRoleInput{
9191
RoleArn: aws.String(arn),
92-
RoleSessionName: aws.String(sessionName),
92+
RoleSessionName: aws.String("go-metadataproxy"),
9393
}
9494
}
9595

9696
return &sts.AssumeRoleInput{
9797
ExternalId: aws.String(externalId),
9898
RoleArn: aws.String(arn),
99-
RoleSessionName: aws.String(sessionName),
99+
RoleSessionName: aws.String("go-metadataproxy"),
100100
}
101101
}
102102

@@ -111,7 +111,7 @@ func assumeRoleFromAWS(arn string, externalId string, request *Request) (*sts.As
111111

112112
request.setLabel("assume_role_from_aws_cache", "miss")
113113
request.log.Infof("Requesting STS Assume Role info for %s from AWS", arn)
114-
req := stsService.AssumeRoleRequest(constructAssumeRoleInput(arn, externalId, "go-metadataproxy"))
114+
req := stsService.AssumeRoleRequest(constructAssumeRoleInput(arn, externalId))
115115

116116
assumedRole, err := req.Send()
117117
if err != nil {

internal/docker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ func findDockerContainerIAMRole(container *docker.Container, request *Request) (
105105
return "", fmt.Errorf("Could not find IAM_ROLE in the container ENV config")
106106
}
107107

108-
func findDockerContainerExternalId(container *docker.Container, request *Request) (string, error) {
108+
func findDockerContainerExternalId(container *docker.Container, request *Request) string {
109109
v, _ := findDockerContainerEnvValue(container, "IAM_EXTERNAL_ID")
110-
return v, nil
110+
return v
111111
}
112112

113113
func findDockerContainerEnvValue(container *docker.Container, key string) (string, bool) {

internal/http_helper.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,13 @@ func findContainerRoleByAddress(addr string, request *Request) (*iam.Role, strin
4848
return nil, "", err
4949
}
5050

51-
externalId, err := findDockerContainerExternalId(container, request)
52-
if err != nil {
53-
return nil, "", err
54-
}
55-
5651
role, err := readRoleFromAWS(roleName, request)
5752
if err != nil {
5853
return nil, "", err
5954
}
6055

56+
externalId := findDockerContainerExternalId(container, request)
57+
6158
return role, externalId, nil
6259
}
6360

0 commit comments

Comments
 (0)