Skip to content

Commit

Permalink
Add comment for new exported func and const
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianyi Wang committed Feb 2, 2024
1 parent b4ad6e1 commit 729b665
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions aws/accountid/account_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/aws/smithy-go/auth"
)

// AccountID retrieves the accountID from identity or ignores that depending on accountID endpoint mode
func AccountID(identity auth.Identity, mode accountidmode.AIDMode) *string {
if ca, ok := identity.(*smithy.CredentialsAdapter); ok && (mode == accountidmode.Preferred || mode == accountidmode.Required) {
return aws.String(ca.Credentials.AccountID)
Expand All @@ -16,6 +17,8 @@ func AccountID(identity auth.Identity, mode accountidmode.AIDMode) *string {
return nil
}

// CheckAccountID checks accountID mode in case the required accountID misses or
// accountID endpoint mode is configured with invalid value
func CheckAccountID(identity auth.Identity, mode accountidmode.AIDMode) error {
switch mode {
case "":
Expand Down
2 changes: 2 additions & 0 deletions aws/accountid/mode/mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import "fmt"
// AIDMode switches on/off the account ID based endpoint routing
type AIDMode string

// enums of valid AIDMode
const (
Preferred AIDMode = "preferred"
Required AIDMode = "required"
Disabled AIDMode = "disabled"
)

// SetFromString converts config string to corresponding AIDMode or reports error if the value is not enumerated
func (mode *AIDMode) SetFromString(s string) error {
switch {
case s == "preferred":
Expand Down

0 comments on commit 729b665

Please sign in to comment.