-
Notifications
You must be signed in to change notification settings - Fork 60
/
environments.go
118 lines (108 loc) · 3.43 KB
/
environments.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package environments
import (
"fmt"
"strings"
)
// Environment represents a set of API configurations for a particular cloud.
type Environment struct {
// The Azure AD endpoint for acquiring access tokens.
AzureADEndpoint AzureADEndpoint
// Management plane API definitions
MsGraph Api
AadGraph Api
ResourceManager Api
BatchManagement Api
DataLake Api
KeyVault Api
OperationalInsights Api
OSSRDBMS Api
ServiceBus Api
ServiceManagement Api
SQLDatabase Api
Storage Api
Synapse Api
}
var (
Global = Environment{
AzureADEndpoint: AzureADGlobal,
MsGraph: MsGraphGlobal,
AadGraph: AadGraphGlobal,
ResourceManager: ResourceManagerPublic,
BatchManagement: BatchManagementPublic,
DataLake: DataLakePublic,
KeyVault: KeyVaultPublic,
OperationalInsights: OperationalInsightsPublic,
OSSRDBMS: OSSRDBMSPublic,
ServiceBus: ServiceBusPublic,
ServiceManagement: ServiceManagementPublic,
SQLDatabase: SQLDatabasePublic,
Storage: StoragePublic,
Synapse: SynapsePublic,
}
China = Environment{
AzureADEndpoint: AzureADChina,
MsGraph: MsGraphChina,
AadGraph: AadGraphChina,
ResourceManager: ResourceManagerChina,
BatchManagement: BatchManagementChina,
KeyVault: KeyVaultChina,
OperationalInsights: ApiUnavailable,
OSSRDBMS: OSSRDBMSChina,
ServiceBus: ServiceBusChina,
ServiceManagement: ServiceManagementChina,
SQLDatabase: SQLDatabaseChina,
Storage: StoragePublic,
Synapse: SynapsePublic,
}
USGovernmentL4 = Environment{
AzureADEndpoint: AzureADUSGov,
MsGraph: MsGraphUSGovL4,
AadGraph: AadGraphUSGov,
ResourceManager: ResourceManagerUSGov,
BatchManagement: BatchManagementUSGov,
DataLake: ApiUnavailable,
KeyVault: KeyVaultUSGov,
OperationalInsights: OperationalInsightsUSGov,
OSSRDBMS: OSSRDBMSUSGov,
ServiceBus: ServiceBusUSGov,
ServiceManagement: ServiceManagementUSGov,
SQLDatabase: SQLDatabaseUSGov,
Storage: StoragePublic,
Synapse: ApiUnavailable,
}
USGovernmentL5 = Environment{
AzureADEndpoint: AzureADUSGov,
MsGraph: MsGraphUSGovL5,
AadGraph: AadGraphUSGov,
ResourceManager: ResourceManagerUSGov,
BatchManagement: BatchManagementUSGov,
DataLake: ApiUnavailable,
KeyVault: KeyVaultUSGov,
OperationalInsights: OperationalInsightsUSGov,
OSSRDBMS: OSSRDBMSUSGov,
ServiceBus: ServiceBusUSGov,
ServiceManagement: ServiceManagementUSGov,
SQLDatabase: SQLDatabaseUSGov,
Storage: StoragePublic,
Synapse: ApiUnavailable,
}
Canary = Environment{
AzureADEndpoint: AzureADGlobal,
MsGraph: MsGraphCanary,
}
)
func EnvironmentFromString(env string) (Environment, error) {
switch strings.ToLower(env) {
case "", "public", "global":
return Global, nil
case "usgovernment", "usgovernmentl4":
return USGovernmentL4, nil
case "dod", "usgovernmentl5":
return USGovernmentL5, nil
case "canary":
return Canary, nil
case "china":
return China, nil
}
return Environment{}, fmt.Errorf("invalid environment specified: %s", env)
}