mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-08 13:39:53 +00:00
48 lines
1.0 KiB
Go
48 lines
1.0 KiB
Go
package common
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud"
|
|
)
|
|
|
|
func IsEnvironmentPublic(env string) bool {
|
|
switch strings.ToLower(env) {
|
|
case "", "default", "public", "azurecloud":
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
func IsEnvironmentGovernment(env string) bool {
|
|
switch strings.ToLower(env) {
|
|
case "usgovernment", "government", "azureusgovernment", "azuregovernment":
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
func IsEnvironmentChina(env string) bool {
|
|
switch strings.ToLower(env) {
|
|
case "china", "chinacloud", "azurechina", "azurechinacloud":
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
func GetCloudEnvironmentConfiguration(env string) (cloud.Configuration, error) {
|
|
if IsEnvironmentPublic(env) {
|
|
return cloud.AzurePublic, nil
|
|
} else if IsEnvironmentGovernment(env) {
|
|
return cloud.AzureGovernment, nil
|
|
} else if IsEnvironmentChina(env) {
|
|
return cloud.AzureChina, nil
|
|
}
|
|
|
|
return cloud.Configuration{}, fmt.Errorf("unknown azure cloud environment %s", env)
|
|
}
|