| Conditions | 3 |
| Total Lines | 25 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | package providers |
||
| 26 | func (provider *EnvironmentVariableCredentialsProvider) GetCredentials() (cc *Credentials, err error) { |
||
| 27 | accessKeyId := os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID") |
||
| 28 | |||
| 29 | if accessKeyId == "" { |
||
| 30 | err = fmt.Errorf("unable to get credentials from enviroment variables, Access key ID must be specified via environment variable (ALIBABA_CLOUD_ACCESS_KEY_ID)") |
||
| 31 | return |
||
| 32 | } |
||
| 33 | |||
| 34 | accessKeySecret := os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET") |
||
| 35 | |||
| 36 | if accessKeySecret == "" { |
||
| 37 | err = fmt.Errorf("unable to get credentials from enviroment variables, Access key secret must be specified via environment variable (ALIBABA_CLOUD_ACCESS_KEY_SECRET)") |
||
| 38 | return |
||
| 39 | } |
||
| 40 | |||
| 41 | securityToken := os.Getenv("ALIBABA_CLOUD_SECURITY_TOKEN") |
||
| 42 | |||
| 43 | cc = &Credentials{ |
||
| 44 | AccessKeyId: accessKeyId, |
||
| 45 | AccessKeySecret: accessKeySecret, |
||
| 46 | SecurityToken: securityToken, |
||
| 47 | ProviderName: provider.GetProviderName(), |
||
| 48 | } |
||
| 49 | |||
| 50 | return |
||
| 51 | } |
||
| 56 |