Skip to content

Commit 034b0da

Browse files
committed
PEM-7501: Loaded custom azure environment from file
1 parent 5f44feb commit 034b0da

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

azure/scope/azure_secret_cloud.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package scope
2+
3+
import (
4+
"context"
5+
"os"
6+
7+
"github.com/Azure/go-autorest/autorest/azure"
8+
"sigs.k8s.io/cluster-api-provider-azure/util/tele"
9+
)
10+
11+
const (
12+
AzureEnvironentFileEnvName = "AZURE_ENVIRONMENT_FILE"
13+
AzureSecretCloudName = "AzureSecretCloud"
14+
)
15+
16+
func init() {
17+
_, log, done := tele.StartSpanWithLogger(context.Background(), "scope.AzureScope.init")
18+
defer done()
19+
path := os.Getenv(AzureEnvironentFileEnvName)
20+
if path == "" {
21+
return
22+
}
23+
if env, err := azure.EnvironmentFromFile(path); err == nil {
24+
azure.SetEnvironment(AzureSecretCloudName, env)
25+
} else {
26+
log.Error(err, "reason", "failed to load Azure environment from file", "path", path)
27+
}
28+
}

0 commit comments

Comments
 (0)