-
Notifications
You must be signed in to change notification settings - Fork 642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify http cred provider resolving logic #2259
Conversation
input := &client.GetCredentialsInput{} | ||
if authToken != "" { | ||
input.AuthorizationToken = authToken | ||
} | ||
return p.client.GetCredentials(ctx, input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can condense this to like what it was before:
input := &client.GetCredentialsInput{} | |
if authToken != "" { | |
input.AuthorizationToken = authToken | |
} | |
return p.client.GetCredentials(ctx, input) | |
return p.client.GetCredentials(ctx, &client.GetCredentialsInput{AuthorizationToken: authToken}) |
The zero value for string
is already ""
- there's no need to check whether you ended up with something else in authToken
.
@@ -132,5 +163,23 @@ func (p *Provider) Retrieve(ctx context.Context) (aws.Credentials, error) { | |||
} | |||
|
|||
func (p *Provider) getCredentials(ctx context.Context) (*client.GetCredentialsOutput, error) { | |||
return p.client.GetCredentials(ctx, &client.GetCredentialsInput{AuthorizationToken: p.options.AuthorizationToken}) | |||
authToken := p.options.AuthorizationToken |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend you compartmentalize this-- e.g.
authToken, err := p.resolveAuthToken()
if err != nil {
return nil, fmt.Errorf("resolve auth token: %v", err)
}
Modify http cred provider resolving logic to allow EKS/ECS host url and auth token from a file, which can be retrieved from env var