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

#36 | Support named profile configs #43

Closed
wants to merge 1 commit into from
Closed
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 config/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"io/ioutil"
"strings"

"github.com/pkg/errors"
ini "gopkg.in/ini.v1"
Expand Down Expand Up @@ -55,6 +56,10 @@ func Load(files ...string) (Profiles, error) {
continue
}

if strings.HasPrefix(name, "profile") {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would adding a trailing space be more consistent with the TrimPrefix?

Suggested change
if strings.HasPrefix(name, "profile") {
if strings.HasPrefix(name, "profile ") {

name = strings.TrimPrefix(name, "profile ")
}

init:

profile, ok := profiles[name]
Expand Down
2 changes: 1 addition & 1 deletion config/testdata/credentials
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

[foo]
[profile foo]
role_arn=arn:aws:iam::123456789012:role/marketingadmin
source_profile=default
external_id=123456
Expand Down
2 changes: 1 addition & 1 deletion config/testdata/merged
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ output=json
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

[foo]
[profile foo]
role_arn=arn:aws:iam::123456789012:role/marketingadmin
source_profile=default
external_id=123456
Expand Down