Skip to content

Commit

Permalink
Merge pull request #149 from stuartio/ask_fix
Browse files Browse the repository at this point in the history
Adding support for Account Switch Keys from environment
  • Loading branch information
robertolopezlopez authored Mar 24, 2022
2 parents 7353159 + fd6fa90 commit f7ee36a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/edgegrid/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ func (c *Config) FromEnv(section string) error {
c.MaxBody = MaxBodySize
}

val, ok := os.LookupEnv(fmt.Sprintf("%s_%s", prefix, "ACCOUNT_KEY"))
if ok {
c.AccountKey = val
}

return nil
}

Expand Down
19 changes: 19 additions & 0 deletions pkg/edgegrid/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,25 @@ func TestConfig_FromEnv(t *testing.T) {
MaxBody: 123,
},
},
"default section, valid envs, account key": {
section: "default",
envs: map[string]string{
"AKAMAI_HOST": "test-host",
"AKAMAI_CLIENT_TOKEN": "test-client-token",
"AKAMAI_CLIENT_SECRET": "test-client-secret",
"AKAMAI_ACCESS_TOKEN": "test-access-token",
"AKAMAI_MAX_BODY": "123",
"AKAMAI_ACCOUNT_KEY": "account-key-123",
},
expected: Config{
Host: "test-host",
ClientToken: "test-client-token",
ClientSecret: "test-client-secret",
AccessToken: "test-access-token",
MaxBody: 123,
AccountKey: "account-key-123",
},
},
"custom section, valid envs": {
section: "test",
envs: map[string]string{
Expand Down

0 comments on commit f7ee36a

Please sign in to comment.