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

Backport of Backend/azure: Update go-azure-sdk version to v0.20250131.1134653 #36680

Merged
merged 2 commits into from
Mar 12, 2025
Merged
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 .changes/v1.11/ENHANCEMENTS-20250207-164803.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: ENHANCEMENTS
body: Azure Backend supports ADO Pipelines OIDC token refresh by using the `oidc_request_url`, `oidc_request_token` and (the new) `ado_pipeline_service_connection_id`.
time: 2025-02-07T16:48:03.902464157+11:00
custom:
Issue: "36458"
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ require (
github.com/hashicorp/consul/api v1.13.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-azure-helpers v0.71.0 // indirect
github.com/hashicorp/go-azure-sdk/resource-manager v0.20241212.1154051 // indirect
github.com/hashicorp/go-azure-sdk/sdk v0.20241212.1154051 // indirect
github.com/hashicorp/go-azure-sdk/resource-manager v0.20250131.1134653 // indirect
github.com/hashicorp/go-azure-sdk/sdk v0.20250131.1134653 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-immutable-radix v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -618,10 +618,10 @@ github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-azure-helpers v0.71.0 h1:ra3aIRzg01g6MLKQ+yABcb6WJtrqRUDDgyuPLmyZ9lY=
github.com/hashicorp/go-azure-helpers v0.71.0/go.mod h1:BmbF4JDYXK5sEmFeU5hcn8Br21uElcqLfdQxjatwQKw=
github.com/hashicorp/go-azure-sdk/resource-manager v0.20241212.1154051 h1:jFgd3bzeRViGTzicIn9gDw2O/Gk6WjVJCTTefPNOGPY=
github.com/hashicorp/go-azure-sdk/resource-manager v0.20241212.1154051/go.mod h1:XapOZ9HiCtXz3qb5yNFiCuWbOBj2I3WU1K2jwqgK2zA=
github.com/hashicorp/go-azure-sdk/sdk v0.20241212.1154051 h1:4fCKJPSeLVvwl7ZCqU7MOUKyx/M7kl/J6wlw2O3xn40=
github.com/hashicorp/go-azure-sdk/sdk v0.20241212.1154051/go.mod h1:oI5R0fTbBx3K/sJBK5R/OlEy8ozdQjvctxVU9v3EDkc=
github.com/hashicorp/go-azure-sdk/resource-manager v0.20250131.1134653 h1:KuDCZKWoOByX5MUyFRNWLl4Gy6wpZCwJ7Ez1mbUwouo=
github.com/hashicorp/go-azure-sdk/resource-manager v0.20250131.1134653/go.mod h1:AawbnS/Kkp/IURMJVzmvD+Co2zK91lKFqYYDbenCpGU=
github.com/hashicorp/go-azure-sdk/sdk v0.20250131.1134653 h1:Bd+glHUD1mdal1zn0NgoS4wDFhUB8Qfw61j0nZEnC5A=
github.com/hashicorp/go-azure-sdk/sdk v0.20250131.1134653/go.mod h1:oI5R0fTbBx3K/sJBK5R/OlEy8ozdQjvctxVU9v3EDkc=
github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU=
github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg=
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
Expand Down
19 changes: 14 additions & 5 deletions internal/backend/remote-state/azure/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,24 @@ func New() backend.Backend {
Description: "Allow OpenID Connect to be used for authentication",
},

"ado_pipeline_service_connection_id": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"ARM_ADO_PIPELINE_SERVICE_CONNECTION_ID", "ARM_OIDC_AZURE_SERVICE_CONNECTION_ID"}, nil),
Description: "The Azure DevOps Pipeline Service Connection ID.",
},

"oidc_request_token": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"ARM_OIDC_REQUEST_TOKEN", "ACTIONS_ID_TOKEN_REQUEST_TOKEN"}, ""),
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"ARM_OIDC_REQUEST_TOKEN", "ACTIONS_ID_TOKEN_REQUEST_TOKEN", "SYSTEM_ACCESSTOKEN"}, nil),
Description: "The bearer token for the request to the OIDC provider. For use when authenticating as a Service Principal using OpenID Connect.",
},

"oidc_request_url": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"ARM_OIDC_REQUEST_URL", "ACTIONS_ID_TOKEN_REQUEST_URL"}, ""),
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"ARM_OIDC_REQUEST_URL", "ACTIONS_ID_TOKEN_REQUEST_URL", "SYSTEM_OIDCREQUESTURI"}, nil),
Description: "The URL for the OIDC provider from which to request an ID token. For use when authenticating as a Service Principal using OpenID Connect.",
},

Expand Down Expand Up @@ -329,9 +336,10 @@ func (b *Backend) configure(ctx context.Context) error {
ClientCertificatePassword: data.Get("client_certificate_password").(string),
ClientSecret: *clientSecret,

OIDCAssertionToken: *oidcToken,
GitHubOIDCTokenRequestURL: data.Get("oidc_request_url").(string),
GitHubOIDCTokenRequestToken: data.Get("oidc_request_token").(string),
OIDCAssertionToken: *oidcToken,
OIDCTokenRequestURL: data.Get("oidc_request_url").(string),
OIDCTokenRequestToken: data.Get("oidc_request_token").(string),
ADOPipelineServiceConnectionID: data.Get("ado_pipeline_service_connection_id").(string),

CustomManagedIdentityEndpoint: data.Get("msi_endpoint").(string),

Expand All @@ -341,6 +349,7 @@ func (b *Backend) configure(ctx context.Context) error {
EnableAuthenticatingUsingManagedIdentity: enableManagedIdentity,
EnableAuthenticationUsingOIDC: enableOidc,
EnableAuthenticationUsingGitHubOIDC: enableOidc,
EnableAuthenticationUsingADOPipelineOIDC: enableOidc,
}

backendConfig := BackendConfig{
Expand Down
79 changes: 70 additions & 9 deletions internal/backend/remote-state/azure/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestAccBackendAccessKeyBasic(t *testing.T) {
}
defer m.destroyTestResources(ctx)

clearEnv()
clearARMEnv()
b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
"storage_account_name": m.names.storageAccountName,
"container_name": m.names.storageContainerName,
Expand Down Expand Up @@ -89,7 +89,7 @@ func TestAccBackendSASTokenBasic(t *testing.T) {
t.Fatalf("Error building SAS Token: %+v", err)
}

clearEnv()
clearARMEnv()
b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
"storage_account_name": m.names.storageAccountName,
"container_name": m.names.storageContainerName,
Expand All @@ -106,6 +106,16 @@ func TestAccBackendGithubOIDCBasic(t *testing.T) {

testAccAzureBackendRunningInGitHubActions(t)

oidcRequestToken := os.Getenv("ACTIONS_ID_TOKEN_REQUEST_TOKEN")
if oidcRequestToken == "" {
t.Fatalf("Missing ACTIONS_ID_TOKEN_REQUEST_TOKEN")
}

oidcRequestURL := os.Getenv("ACTIONS_ID_TOKEN_REQUEST_URL")
if oidcRequestURL == "" {
t.Fatalf("Missing ACTIONS_ID_TOKEN_REQUEST_URL")
}

ctx := newCtx()
m := BuildTestMeta(t, ctx)

Expand All @@ -116,14 +126,16 @@ func TestAccBackendGithubOIDCBasic(t *testing.T) {
}
defer m.destroyTestResources(ctx)

clearEnv()
clearARMEnv()
b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
"subscription_id": m.subscriptionId,
"resource_group_name": m.names.resourceGroup,
"storage_account_name": m.names.storageAccountName,
"container_name": m.names.storageContainerName,
"key": m.names.storageKeyName,
"use_oidc": true,
"oidc_request_token": oidcRequestToken,
"oidc_request_url": oidcRequestURL,
"tenant_id": m.tenantId,
"client_id": m.clientId,
"environment": m.env.Name,
Expand All @@ -132,6 +144,55 @@ func TestAccBackendGithubOIDCBasic(t *testing.T) {
backend.TestBackendStates(t, b)
}

func TestAccBackendADOPipelinesOIDCBasic(t *testing.T) {
t.Parallel()

testAccAzureBackendRunningInADOPipelines(t)

oidcRequestToken := os.Getenv("SYSTEM_ACCESSTOKEN")
if oidcRequestToken == "" {
t.Fatalf("Missing SYSTEM_ACCESSTOKEN")
}

oidcRequestURL := os.Getenv("SYSTEM_OIDCREQUESTURI")
if oidcRequestURL == "" {
t.Fatalf("Missing SYSTEM_OIDCREQUESTURI")
}

adoPipelineServiceConnectionId := os.Getenv("ARM_ADO_PIPELINE_SERVICE_CONNECTION_ID")
if adoPipelineServiceConnectionId == "" {
t.Fatalf("Missing ARM_ADO_PIPELINE_SERVICE_CONNECTION_ID")
}

ctx := newCtx()
m := BuildTestMeta(t, ctx)

err := m.buildTestResources(ctx)
if err != nil {
m.destroyTestResources(ctx)
t.Fatalf("Error creating Test Resources: %q", err)
}
defer m.destroyTestResources(ctx)

clearARMEnv()
b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
"subscription_id": m.subscriptionId,
"resource_group_name": m.names.resourceGroup,
"storage_account_name": m.names.storageAccountName,
"container_name": m.names.storageContainerName,
"key": m.names.storageKeyName,
"use_oidc": true,
"oidc_request_token": oidcRequestToken,
"oidc_request_url": oidcRequestURL,
"ado_pipeline_service_connection_id": adoPipelineServiceConnectionId,
"tenant_id": m.tenantId,
"client_id": m.clientId,
"environment": m.env.Name,
})).(*Backend)

backend.TestBackendStates(t, b)
}

func TestAccBackendAzureADAuthBasic(t *testing.T) {
t.Parallel()

Expand All @@ -147,7 +208,7 @@ func TestAccBackendAzureADAuthBasic(t *testing.T) {
}
defer m.destroyTestResources(ctx)

clearEnv()
clearARMEnv()
b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
"subscription_id": m.subscriptionId,
"resource_group_name": m.names.resourceGroup,
Expand Down Expand Up @@ -179,7 +240,7 @@ func TestAccBackendManagedServiceIdentityBasic(t *testing.T) {
}
defer m.destroyTestResources(ctx)

clearEnv()
clearARMEnv()
b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
"subscription_id": m.subscriptionId,
"resource_group_name": m.names.resourceGroup,
Expand Down Expand Up @@ -215,7 +276,7 @@ func TestAccBackendServicePrincipalClientCertificateBasic(t *testing.T) {
}
defer m.destroyTestResources(ctx)

clearEnv()
clearARMEnv()
b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
"subscription_id": m.subscriptionId,
"resource_group_name": m.names.resourceGroup,
Expand Down Expand Up @@ -247,7 +308,7 @@ func TestAccBackendServicePrincipalClientSecretBasic(t *testing.T) {
}
defer m.destroyTestResources(ctx)

clearEnv()
clearARMEnv()
b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
"subscription_id": m.subscriptionId,
"resource_group_name": m.names.resourceGroup,
Expand Down Expand Up @@ -278,7 +339,7 @@ func TestAccBackendAccessKeyLocked(t *testing.T) {
}
defer m.destroyTestResources(ctx)

clearEnv()
clearARMEnv()

b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
"storage_account_name": m.names.storageAccountName,
Expand Down Expand Up @@ -318,7 +379,7 @@ func TestAccBackendServicePrincipalLocked(t *testing.T) {
}
defer m.destroyTestResources(ctx)

clearEnv()
clearARMEnv()

b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
"subscription_id": m.subscriptionId,
Expand Down
12 changes: 6 additions & 6 deletions internal/backend/remote-state/azure/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestRemoteClientAccessKeyBasic(t *testing.T) {
}
defer m.destroyTestResources(ctx)

clearEnv()
clearARMEnv()
b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
"storage_account_name": m.names.storageAccountName,
"container_name": m.names.storageContainerName,
Expand Down Expand Up @@ -61,7 +61,7 @@ func TestRemoteClientManagedServiceIdentityBasic(t *testing.T) {
}
defer m.destroyTestResources(ctx)

clearEnv()
clearARMEnv()
b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
"subscription_id": m.subscriptionId,
"resource_group_name": m.names.resourceGroup,
Expand Down Expand Up @@ -101,7 +101,7 @@ func TestRemoteClientSasTokenBasic(t *testing.T) {
t.Fatalf("Error building SAS Token: %+v", err)
}

clearEnv()
clearARMEnv()
b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
"storage_account_name": m.names.storageAccountName,
"container_name": m.names.storageContainerName,
Expand Down Expand Up @@ -133,7 +133,7 @@ func TestRemoteClientServicePrincipalBasic(t *testing.T) {
}
defer m.destroyTestResources(ctx)

clearEnv()
clearARMEnv()
b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
"subscription_id": m.subscriptionId,
"resource_group_name": m.names.resourceGroup,
Expand Down Expand Up @@ -169,7 +169,7 @@ func TestRemoteClientAccessKeyLocks(t *testing.T) {
}
defer m.destroyTestResources(ctx)

clearEnv()
clearARMEnv()

b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
"storage_account_name": m.names.storageAccountName,
Expand Down Expand Up @@ -215,7 +215,7 @@ func TestRemoteClientServicePrincipalLocks(t *testing.T) {
}
defer m.destroyTestResources(ctx)

clearEnv()
clearARMEnv()

b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{
"subscription_id": m.subscriptionId,
Expand Down
4 changes: 2 additions & 2 deletions internal/backend/remote-state/azure/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.23.3

require (
github.com/hashicorp/go-azure-helpers v0.71.0
github.com/hashicorp/go-azure-sdk/resource-manager v0.20241212.1154051
github.com/hashicorp/go-azure-sdk/sdk v0.20241212.1154051
github.com/hashicorp/go-azure-sdk/resource-manager v0.20250131.1134653
github.com/hashicorp/go-azure-sdk/sdk v0.20250131.1134653
github.com/hashicorp/go-uuid v1.0.3
github.com/hashicorp/terraform v0.0.0-00010101000000-000000000000
github.com/hashicorp/terraform/internal/legacy v0.0.0-00010101000000-000000000000
Expand Down
8 changes: 4 additions & 4 deletions internal/backend/remote-state/azure/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-azure-helpers v0.71.0 h1:ra3aIRzg01g6MLKQ+yABcb6WJtrqRUDDgyuPLmyZ9lY=
github.com/hashicorp/go-azure-helpers v0.71.0/go.mod h1:BmbF4JDYXK5sEmFeU5hcn8Br21uElcqLfdQxjatwQKw=
github.com/hashicorp/go-azure-sdk/resource-manager v0.20241212.1154051 h1:jFgd3bzeRViGTzicIn9gDw2O/Gk6WjVJCTTefPNOGPY=
github.com/hashicorp/go-azure-sdk/resource-manager v0.20241212.1154051/go.mod h1:XapOZ9HiCtXz3qb5yNFiCuWbOBj2I3WU1K2jwqgK2zA=
github.com/hashicorp/go-azure-sdk/sdk v0.20241212.1154051 h1:4fCKJPSeLVvwl7ZCqU7MOUKyx/M7kl/J6wlw2O3xn40=
github.com/hashicorp/go-azure-sdk/sdk v0.20241212.1154051/go.mod h1:oI5R0fTbBx3K/sJBK5R/OlEy8ozdQjvctxVU9v3EDkc=
github.com/hashicorp/go-azure-sdk/resource-manager v0.20250131.1134653 h1:KuDCZKWoOByX5MUyFRNWLl4Gy6wpZCwJ7Ez1mbUwouo=
github.com/hashicorp/go-azure-sdk/resource-manager v0.20250131.1134653/go.mod h1:AawbnS/Kkp/IURMJVzmvD+Co2zK91lKFqYYDbenCpGU=
github.com/hashicorp/go-azure-sdk/sdk v0.20250131.1134653 h1:Bd+glHUD1mdal1zn0NgoS4wDFhUB8Qfw61j0nZEnC5A=
github.com/hashicorp/go-azure-sdk/sdk v0.20250131.1134653/go.mod h1:oI5R0fTbBx3K/sJBK5R/OlEy8ozdQjvctxVU9v3EDkc=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI=
Expand Down
41 changes: 31 additions & 10 deletions internal/backend/remote-state/azure/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,16 @@ func testAccAzureBackendRunningInGitHubActions(t *testing.T) {
}
}

// clearEnv cleans up the azure related environment variables.
// these kind of tests can only run when within ADO Pipelines (e.g. OIDC)
func testAccAzureBackendRunningInADOPipelines(t *testing.T) {
testAccAzureBackend(t)

if os.Getenv("TF_RUNNING_IN_ADO_PIPELINES") == "" {
t.Skip("Skipping test since not running in ADO Pipelines")
}
}

// clearARMEnv cleans up the azure related environment variables.
// This is to ensure the configuration only comes from HCL, which avoids
// env vars for test setup interfere the behavior.
//
Expand All @@ -65,7 +74,7 @@ func testAccAzureBackendRunningInGitHubActions(t *testing.T) {
// impact can be eliminated given all the tests are implemented in a similar
// pattern that those env vars will be consumed at the very begining. The test
// runner has to ensure to set a **big enough parallelism**.
func clearEnv() {
func clearARMEnv() {
for _, evexp := range os.Environ() {
k, _, ok := strings.Cut(evexp, "=")
if !ok {
Expand Down Expand Up @@ -178,19 +187,21 @@ func BuildTestMeta(t *testing.T, ctx context.Context) *TestMeta {
// - MSI: For MSI related tests
// - OIDC: For OIDC related tests
authConfig := &auth.Credentials{
Environment: *env,
TenantID: tenantID,
ClientID: clientID,
ClientSecret: clientSecret,
ClientCertificatePath: os.Getenv("ARM_CLIENT_CERTIFICATE_PATH"),
ClientCertificatePassword: os.Getenv("ARM_CLIENT_CERTIFICATE_PASSWORD"),
GitHubOIDCTokenRequestURL: os.Getenv("ACTIONS_ID_TOKEN_REQUEST_URL"),
GitHubOIDCTokenRequestToken: os.Getenv("ACTIONS_ID_TOKEN_REQUEST_TOKEN"),
Environment: *env,
TenantID: tenantID,
ClientID: clientID,
ClientSecret: clientSecret,
ClientCertificatePath: os.Getenv("ARM_CLIENT_CERTIFICATE_PATH"),
ClientCertificatePassword: os.Getenv("ARM_CLIENT_CERTIFICATE_PASSWORD"),
OIDCTokenRequestURL: getEnvvars("ACTIONS_ID_TOKEN_REQUEST_URL", "SYSTEM_OIDCREQUESTURI"),
OIDCTokenRequestToken: getEnvvars("ACTIONS_ID_TOKEN_REQUEST_TOKEN", "SYSTEM_ACCESSTOKEN"),
ADOPipelineServiceConnectionID: os.Getenv("ARM_ADO_PIPELINE_SERVICE_CONNECTION_ID"),

EnableAuthenticatingUsingClientSecret: true,
EnableAuthenticatingUsingClientCertificate: true,
EnableAuthenticatingUsingManagedIdentity: true,
EnableAuthenticationUsingGitHubOIDC: true,
EnableAuthenticationUsingADOPipelineOIDC: true,
}

resourceManagerAuth, err := auth.NewAuthorizerFromCredentials(ctx, *authConfig, env.ResourceManager)
Expand Down Expand Up @@ -325,3 +336,13 @@ func randString(strlen int) string {
}
return string(result)
}

// getEnvvars return the first non-empty env var specified. If none is found, it returns empty string.
func getEnvvars(envvars ...string) string {
for _, envvar := range envvars {
if v := os.Getenv(envvar); v != "" {
return v
}
}
return ""
}
Loading