Skip to content

Commit

Permalink
add parameters to configEnv
Browse files Browse the repository at this point in the history
Signed-off-by: outscale_hmi <[email protected]>
  • Loading branch information
outscale-hmi authored and jerome-jutteau committed Sep 27, 2022
1 parent 682306b commit 742caab
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions v2/config_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ type ConfigEnv struct {
OutscaleApiEndpoint *string
ProfileName *string
Region *string
X509ClientCert *string
X509ClientKey *string
}

func NewConfigEnv() *ConfigEnv {
Expand All @@ -31,13 +33,22 @@ func NewConfigEnv() *ConfigEnv {
if value, present := os.LookupEnv("OSC_REGION"); present {
configEnv.Region = &value
}
if value, present := os.LookupEnv("OSC_X509_CLIENT_CERT"); present {
configEnv.X509ClientCert = &value
}
if value, present := os.LookupEnv("OSC_X509_CLIENT_KEY"); present {
configEnv.X509ClientKey = &value
}
return &configEnv
}

func (configEnv *ConfigEnv) Configuration() (*Configuration, error) {
var config *Configuration

if configEnv.ProfileName != nil {
if configEnv.AccessKey == nil && configEnv.SecretKey == nil {
if configEnv.ProfileName == nil {
*configEnv.ProfileName = "Default"
}
configFile, err := LoadDefaultConfigFile()
if err != nil {
return nil, err
Expand Down Expand Up @@ -83,7 +94,10 @@ func (configEnv *ConfigEnv) Context(ctx context.Context) (context.Context, error
var accessKey *string
var secretKey *string

if configEnv.ProfileName != nil {
if configEnv.AccessKey == nil && configEnv.SecretKey == nil {
if configEnv.ProfileName == nil {
*configEnv.ProfileName = "Default"
}
configFile, err := LoadDefaultConfigFile()
if err != nil {
return nil, err
Expand Down

0 comments on commit 742caab

Please sign in to comment.