| 1 | package scwscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ |
| 2 | |
| 3 | import ( |
| 4 | "osscip-go gomod github.com/golang/go/src go1.17 os/" |
| 5 | "strconvscip-go gomod github.com/golang/go/src go1.17 strconv/" |
| 6 | |
| 7 | "github.com/scaleway/scaleway-sdk-go/loggerscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/" |
| 8 | ) |
| 9 | |
| 10 | // Environment variables |
| 11 | const ( |
| 12 | // Up-to-date |
| 13 | ScwCacheDirEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwCacheDirEnv. = "SCW_CACHE_DIR" |
| 14 | ScwConfigPathEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwConfigPathEnv. = "SCW_CONFIG_PATH" |
| 15 | ScwAccessKeyEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwAccessKeyEnv. = "SCW_ACCESS_KEY" |
| 16 | ScwSecretKeyEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwSecretKeyEnv. = "SCW_SECRET_KEY" // #nosec G101 |
| 17 | ScwActiveProfileEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwActiveProfileEnv. = "SCW_PROFILE" |
| 18 | ScwAPIURLEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwAPIURLEnv. = "SCW_API_URL" |
| 19 | ScwInsecureEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwInsecureEnv. = "SCW_INSECURE" |
| 20 | ScwDefaultOrganizationIDEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwDefaultOrganizationIDEnv. = "SCW_DEFAULT_ORGANIZATION_ID" |
| 21 | ScwDefaultProjectIDEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwDefaultProjectIDEnv. = "SCW_DEFAULT_PROJECT_ID" |
| 22 | ScwDefaultRegionEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwDefaultRegionEnv. = "SCW_DEFAULT_REGION" |
| 23 | ScwDefaultZoneEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwDefaultZoneEnv. = "SCW_DEFAULT_ZONE" |
| 24 | ScwEnableBetascip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwEnableBeta. = "SCW_ENABLE_BETA" |
| 25 | DebugEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/DebugEnv. = loggerscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/.DebugEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/DebugEnv. |
| 26 | |
| 27 | // All deprecated (cli&terraform) |
| 28 | terraformAccessKeyEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/terraformAccessKeyEnv. = "SCALEWAY_ACCESS_KEY" // used both as access key and secret key |
| 29 | terraformSecretKeyEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/terraformSecretKeyEnv. = "SCALEWAY_TOKEN" |
| 30 | terraformOrganizationEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/terraformOrganizationEnv. = "SCALEWAY_ORGANIZATION" |
| 31 | terraformRegionEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/terraformRegionEnv. = "SCALEWAY_REGION" |
| 32 | cliTLSVerifyEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/cliTLSVerifyEnv. = "SCW_TLSVERIFY" |
| 33 | cliOrganizationEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/cliOrganizationEnv. = "SCW_ORGANIZATION" |
| 34 | cliRegionEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/cliRegionEnv. = "SCW_REGION" |
| 35 | cliSecretKeyEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/cliSecretKeyEnv. = "SCW_TOKEN" |
| 36 | |
| 37 | // TBD |
| 38 | // cliVerboseEnv = "SCW_VERBOSE_API" |
| 39 | // cliDebugEnv = "DEBUG" |
| 40 | // cliNoCheckVersionEnv = "SCW_NOCHECKVERSION" |
| 41 | // cliTestWithRealAPIEnv = "TEST_WITH_REAL_API" |
| 42 | // cliSecureExecEnv = "SCW_SECURE_EXEC" |
| 43 | // cliGatewayEnv = "SCW_GATEWAY" |
| 44 | // cliSensitiveEnv = "SCW_SENSITIVE" |
| 45 | // cliAccountAPIEnv = "SCW_ACCOUNT_API" |
| 46 | // cliMetadataAPIEnv = "SCW_METADATA_API" |
| 47 | // cliMarketPlaceAPIEnv = "SCW_MARKETPLACE_API" |
| 48 | // cliComputePar1APIEnv = "SCW_COMPUTE_PAR1_API" |
| 49 | // cliComputeAms1APIEnv = "SCW_COMPUTE_AMS1_API" |
| 50 | // cliCommercialTypeEnv = "SCW_COMMERCIAL_TYPE" |
| 51 | // cliTargetArchEnv = "SCW_TARGET_ARCH" |
| 52 | ) |
| 53 | |
| 54 | const ( |
| 55 | v1RegionFrParscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/v1RegionFrPar. = "par1" |
| 56 | v1RegionNlAmsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/v1RegionNlAms. = "ams1" |
| 57 | ) |
| 58 | |
| 59 | func LoadEnvProfilescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/LoadEnvProfile().() *Profilescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile# { |
| 60 | p := &Profilescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#{} |
| 61 | |
| 62 | accessKey, _, envExist := getEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/getEnv().(ScwAccessKeyEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwAccessKeyEnv., terraformAccessKeyEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/terraformAccessKeyEnv.) |
| 63 | if envExist { |
| 64 | p.AccessKeyscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#AccessKey. = &accessKey |
| 65 | } |
| 66 | |
| 67 | secretKey, _, envExist := getEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/getEnv().(ScwSecretKeyEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwSecretKeyEnv., cliSecretKeyEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/cliSecretKeyEnv., terraformSecretKeyEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/terraformSecretKeyEnv., terraformAccessKeyEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/terraformAccessKeyEnv.) |
| 68 | if envExist { |
| 69 | p.SecretKeyscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#SecretKey. = &secretKey |
| 70 | } |
| 71 | |
| 72 | apiURL, _, envExist := getEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/getEnv().(ScwAPIURLEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwAPIURLEnv.) |
| 73 | if envExist { |
| 74 | p.APIURLscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#APIURL. = &apiURL |
| 75 | } |
| 76 | |
| 77 | insecureValue, envKey, envExist := getEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/getEnv().(ScwInsecureEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwInsecureEnv., cliTLSVerifyEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/cliTLSVerifyEnv.) |
| 78 | if envExist { |
| 79 | insecure, err := strconvscip-go gomod github.com/golang/go/src go1.17 strconv/.ParseBoolscip-go gomod github.com/golang/go/src go1.17 strconv/ParseBool().(insecureValue) |
| 80 | if err != nil { |
| 81 | loggerscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/.Warningfscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/Warningf().("env variable %s cannot be parsed: %s is invalid boolean", envKey, insecureValue) |
| 82 | } |
| 83 | |
| 84 | if envKey == cliTLSVerifyEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/cliTLSVerifyEnv. { |
| 85 | insecure = !insecure // TLSVerify is the inverse of Insecure |
| 86 | } |
| 87 | |
| 88 | p.Insecurescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#Insecure. = &insecure |
| 89 | } |
| 90 | |
| 91 | organizationID, _, envExist := getEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/getEnv().(ScwDefaultOrganizationIDEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwDefaultOrganizationIDEnv., cliOrganizationEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/cliOrganizationEnv., terraformOrganizationEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/terraformOrganizationEnv.) |
| 92 | if envExist { |
| 93 | p.DefaultOrganizationIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#DefaultOrganizationID. = &organizationID |
| 94 | } |
| 95 | |
| 96 | projectID, _, envExist := getEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/getEnv().(ScwDefaultProjectIDEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwDefaultProjectIDEnv.) |
| 97 | if envExist { |
| 98 | p.DefaultProjectIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#DefaultProjectID. = &projectID |
| 99 | } |
| 100 | |
| 101 | region, _, envExist := getEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/getEnv().(ScwDefaultRegionEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwDefaultRegionEnv., cliRegionEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/cliRegionEnv., terraformRegionEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/terraformRegionEnv.) |
| 102 | if envExist { |
| 103 | region = v1RegionToV2scip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/v1RegionToV2().(region) |
| 104 | p.DefaultRegionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#DefaultRegion. = ®ion |
| 105 | } |
| 106 | |
| 107 | zone, _, envExist := getEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/getEnv().(ScwDefaultZoneEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ScwDefaultZoneEnv.) |
| 108 | if envExist { |
| 109 | p.DefaultZonescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#DefaultZone. = &zone |
| 110 | } |
| 111 | |
| 112 | return p |
| 113 | } |
| 114 | |
| 115 | func getEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/getEnv().(upToDateKey string, deprecatedKeys ...string) (string, string, bool) { |
| 116 | value, exist := osscip-go gomod github.com/golang/go/src go1.17 os/.LookupEnvscip-go gomod github.com/golang/go/src go1.17 os/LookupEnv().(upToDateKey) |
| 117 | if exist { |
| 118 | loggerscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/.Debugfscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/Debugf().("reading value from %s\n", upToDateKey) |
| 119 | return value, upToDateKey, true |
| 120 | } |
| 121 | |
| 122 | for _, key := range deprecatedKeys { |
| 123 | value, exist := osscip-go gomod github.com/golang/go/src go1.17 os/.LookupEnvscip-go gomod github.com/golang/go/src go1.17 os/LookupEnv().(key) |
| 124 | if exist { |
| 125 | loggerscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/.Debugfscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/Debugf().("reading value from %s\n", key) |
| 126 | loggerscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/.Warningfscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/Warningf().("%s is deprecated, please use %s instead\n", key, upToDateKey) |
| 127 | return value, key, true |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | return "", "", false |
| 132 | } |
| 133 | |
| 134 | func v1RegionToV2scip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/v1RegionToV2().(region string) string { |
| 135 | switch region { |
| 136 | case v1RegionFrParscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/v1RegionFrPar.: |
| 137 | loggerscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/.Warningfscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/Warningf().("par1 is a deprecated name for region, use fr-par instead") |
| 138 | return "fr-par" |
| 139 | case v1RegionNlAmsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/v1RegionNlAms.: |
| 140 | loggerscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/.Warningfscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/logger`/Warningf().("ams1 is a deprecated name for region, use nl-ams instead") |
| 141 | return "nl-ams" |
| 142 | default: |
| 143 | return region |
| 144 | } |
| 145 | } |