Skip to content
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

Merged
merged 20 commits into from
Nov 13, 2023
Merged

Modify http cred provider resolving logic #2259

merged 20 commits into from
Nov 13, 2023

Conversation

wty-Bryant
Copy link
Contributor

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

@wty-Bryant wty-Bryant marked this pull request as ready for review August 28, 2023 15:54
@wty-Bryant wty-Bryant requested a review from a team as a code owner August 28, 2023 15:54
Comment on lines 180 to 184
input := &client.GetCredentialsInput{}
if authToken != "" {
input.AuthorizationToken = authToken
}
return p.client.GetCredentials(ctx, input)
Copy link
Contributor

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:

Suggested change
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
Copy link
Contributor

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)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants