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

refactor config setters #119

Merged
merged 1 commit into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions credentials/credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ func (s *Config) SetSTSEndpoint(v string) *Config {
return s
}

func (s *Config) SetExternalId(v string) *Config {
s.ExternalId = &v
return s
}

// NewCredential return a credential according to the type in config.
// if config is nil, the function will use default provider chain to get credentials.
// please see README.md for detail.
Expand Down
9 changes: 9 additions & 0 deletions credentials/credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ func TestNewCredentialWithRAMRoleARN(t *testing.T) {
cred, err = NewCredential(config)
assert.Nil(t, err)
assert.NotNil(t, cred)

config.SetExternalId("externalId")
config.SetPolicy("policy")
config.SetRoleSessionExpiration(3600)
config.SetRoleSessionName("roleSessionName")
cred, err = NewCredential(config)
assert.Nil(t, err)
assert.NotNil(t, cred)

}

func TestNewCredentialWithBearerToken(t *testing.T) {
Expand Down
Loading