-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
required.go
223 lines (210 loc) · 8.22 KB
/
required.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package resourceproviders
import (
"fmt"
"strings"
)
// This file contains sets of resource providers which the provider should automatically register, depending on
// configuration by the user. Historically, we have ordained the same set of RPs for all users, and users could
// enable or disable automatic registration of the RPs in that set.
//
// Users may now choose a set of RPs that best meets their needs, via the provider block, or they can provide their
// own set. They can also choose to not register any RPs, and manage these out-of-band, if they wish.
//
// Note that resource providers are case-sensitive.
//
// Official Docs: https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers
type ResourceProviders map[string]struct{}
const (
ProviderRegistrationsNone = "none"
ProviderRegistrationsLegacy = "legacy"
ProviderRegistrationsCore = "core"
ProviderRegistrationsExtended = "extended"
ProviderRegistrationsAll = "all"
)
func (r ResourceProviders) Add(providers ...string) {
for _, p := range providers {
r[p] = struct{}{}
}
}
func (r ResourceProviders) Merge(a ResourceProviders) ResourceProviders {
for k, v := range a {
r[k] = v
}
return r
}
// Core is a minimal set of RPs, and will be the default set in a future major version of the provider.
func Core() ResourceProviders {
return ResourceProviders{
"Microsoft.Authorization": {},
"Microsoft.Compute": {},
"Microsoft.CostManagement": {},
"Microsoft.ManagedIdentity": {},
"Microsoft.MarketplaceOrdering": {},
"Microsoft.Network": {},
"Microsoft.Resources": {},
"Microsoft.Storage": {},
}
}
// Extended is an expanded set of resource providers, as suggested by the community.
func Extended() ResourceProviders {
return Core().Merge(ResourceProviders{
"Microsoft.ApiManagement": {},
"Microsoft.AppConfiguration": {},
"Microsoft.AppPlatform": {},
"Microsoft.Automation": {},
"Microsoft.Cache": {},
"Microsoft.Cdn": {},
"Microsoft.ContainerInstance": {},
"Microsoft.ContainerRegistry": {},
"Microsoft.ContainerService": {},
"Microsoft.DBforMySQL": {},
"Microsoft.DBforPostgreSQL": {},
"Microsoft.DataFactory": {},
"Microsoft.DataLakeAnalytics": {},
"Microsoft.DataLakeStore": {},
"Microsoft.DataMigration": {},
"Microsoft.DataProtection": {},
"Microsoft.Databricks": {},
"Microsoft.DevTestLab": {},
"Microsoft.Devices": {},
"Microsoft.DocumentDB": {},
"Microsoft.EventGrid": {},
"Microsoft.EventHub": {},
"Microsoft.HDInsight": {},
"microsoft.insights": {},
"Microsoft.KeyVault": {},
"Microsoft.Kusto": {},
"Microsoft.Logic": {},
"Microsoft.Maintenance": {},
"Microsoft.Management": {},
"Microsoft.NotificationHubs": {},
"Microsoft.OperationalInsights": {},
"Microsoft.OperationsManagement": {},
"Microsoft.PowerBIDedicated": {},
"Microsoft.Relay": {},
"Microsoft.Security": {},
"Microsoft.SecurityInsights": {},
"Microsoft.ServiceBus": {},
"Microsoft.ServiceFabric": {},
"Microsoft.SignalRService": {},
"Microsoft.Sql": {},
"Microsoft.StreamAnalytics": {},
"Microsoft.Web": {},
})
}
// All is intended to be a complete set of RPs that might be needed to utilize any functionality in the provider.
func All() ResourceProviders {
return Extended().Merge(ResourceProviders{
"Github.Network": {},
"Microsoft.AVS": {},
"Microsoft.AlertsManagement": {},
"Microsoft.Blueprint": {},
"Microsoft.BotService": {},
"Microsoft.CognitiveServices": {},
"Microsoft.CustomProviders": {},
"Microsoft.Dashboard": {},
"Microsoft.DesktopVirtualization": {},
"Microsoft.GuestConfiguration": {},
"Microsoft.HealthcareApis": {},
"Microsoft.IoTCentral": {},
"Microsoft.MachineLearningServices": {},
"Microsoft.ManagedServices": {},
"Microsoft.Maps": {},
"Microsoft.MixedReality": {},
"Microsoft.Monitor": {},
"Microsoft.PolicyInsights": {},
"Microsoft.RecoveryServices": {},
"Microsoft.Search": {},
})
}
// Legacy is the set of automatically registered RPs from earlier versions of the provider, and is provided for
// forwards compatibility. This set should not be changed going forward, and will be removed in a future major release.
func Legacy() ResourceProviders {
return ResourceProviders{
"Microsoft.AVS": {},
"Microsoft.ApiManagement": {},
"Microsoft.AppConfiguration": {},
"Microsoft.AppPlatform": {},
"Microsoft.Authorization": {},
"Microsoft.Automation": {},
"Microsoft.Blueprint": {},
"Microsoft.BotService": {},
"Microsoft.Cache": {},
"Microsoft.Cdn": {},
"Microsoft.CognitiveServices": {},
"Microsoft.Compute": {},
"Microsoft.ContainerInstance": {},
"Microsoft.ContainerRegistry": {},
"Microsoft.ContainerService": {},
"Microsoft.CostManagement": {},
"Microsoft.CustomProviders": {},
"Microsoft.DBforMariaDB": {},
"Microsoft.DBforMySQL": {},
"Microsoft.DBforPostgreSQL": {},
"Microsoft.DataFactory": {},
"Microsoft.DataLakeAnalytics": {},
"Microsoft.DataLakeStore": {},
"Microsoft.DataMigration": {},
"Microsoft.DataProtection": {},
"Microsoft.Databricks": {},
"Microsoft.DesktopVirtualization": {},
"Microsoft.DevTestLab": {},
"Microsoft.Devices": {},
"Microsoft.DocumentDB": {},
"Microsoft.EventGrid": {},
"Microsoft.EventHub": {},
"Microsoft.GuestConfiguration": {},
"Microsoft.HDInsight": {},
"Microsoft.HealthcareApis": {},
"Microsoft.KeyVault": {},
"Microsoft.Kusto": {},
"Microsoft.Logic": {},
"Microsoft.MachineLearningServices": {},
"Microsoft.Maintenance": {},
"Microsoft.ManagedIdentity": {},
"Microsoft.ManagedServices": {},
"Microsoft.Management": {},
"Microsoft.Maps": {},
"Microsoft.MarketplaceOrdering": {},
"Microsoft.Media": {},
"Microsoft.MixedReality": {},
"Microsoft.Network": {},
"Microsoft.NotificationHubs": {},
"Microsoft.OperationalInsights": {},
"Microsoft.OperationsManagement": {},
"Microsoft.PolicyInsights": {},
"Microsoft.PowerBIDedicated": {},
"Microsoft.RecoveryServices": {},
"Microsoft.Relay": {},
"Microsoft.Resources": {},
"Microsoft.Search": {},
"Microsoft.Security": {},
"Microsoft.SecurityInsights": {},
"Microsoft.ServiceBus": {},
"Microsoft.ServiceFabric": {},
"Microsoft.SignalRService": {},
"Microsoft.Sql": {},
"Microsoft.Storage": {},
"Microsoft.StreamAnalytics": {},
"Microsoft.Web": {},
"microsoft.insights": {},
}
}
func GetResourceProvidersSet(input string) (ResourceProviders, error) {
empty := make(ResourceProviders)
switch strings.ToLower(input) {
case ProviderRegistrationsLegacy:
return Legacy(), nil
case ProviderRegistrationsCore:
return Core(), nil
case ProviderRegistrationsAll:
return All(), nil
case ProviderRegistrationsExtended:
return Extended(), nil
case ProviderRegistrationsNone:
return empty, nil
}
return empty, fmt.Errorf("unsupported value %q for provider property `resource_provider_registrations`", input)
}