|
28 | 28 | errMissingClientSecret = errors.New(`"ClientSecret" is not specified in config`)
|
29 | 29 | errMissingFedTokenFile = errors.New(`"FederatedTokenFile" is not specified in config`)
|
30 | 30 | errInvalidCloud = errors.New(`"Cloud" is invalid`)
|
| 31 | + errInvalidMaxResPerBatch = errors.New(`"MaximumResourcesPerBatch" is invalid`) |
31 | 32 |
|
32 | 33 | monitorServices = []string{
|
33 | 34 | "Microsoft.EventGrid/eventSubscriptions",
|
@@ -254,6 +255,7 @@ type Config struct {
|
254 | 255 | AppendTagsAsAttributes bool `mapstructure:"append_tags_as_attributes"`
|
255 | 256 | UseBatchAPI bool `mapstructure:"use_batch_api"`
|
256 | 257 | Dimensions DimensionsConfig `mapstructure:"dimensions"`
|
| 258 | + MaximumResourcesPerBatch int `mapstructure:"maximum_resources_per_batch"` |
257 | 259 |
|
258 | 260 | // Authentication accepts the component azureauthextension,
|
259 | 261 | // and uses it to get an access token to make requests.
|
@@ -284,6 +286,8 @@ const (
|
284 | 286 | managedIdentity = "managed_identity"
|
285 | 287 | )
|
286 | 288 |
|
| 289 | +const defaultMaximumResourcesPerBatch = 50 |
| 290 | + |
287 | 291 | // Validate validates the configuration by checking for missing or invalid fields
|
288 | 292 | func (c Config) Validate() (err error) {
|
289 | 293 | if len(c.SubscriptionIDs) == 0 && !c.DiscoverSubscriptions {
|
@@ -329,5 +333,9 @@ func (c Config) Validate() (err error) {
|
329 | 333 | err = multierr.Append(err, errInvalidCloud)
|
330 | 334 | }
|
331 | 335 |
|
| 336 | + if c.UseBatchAPI && c.MaximumResourcesPerBatch != 0 && (c.MaximumResourcesPerBatch > defaultMaximumResourcesPerBatch || c.MaximumResourcesPerBatch < 0) { |
| 337 | + err = multierr.Append(err, errInvalidMaxResPerBatch) |
| 338 | + } |
| 339 | + |
332 | 340 | return
|
333 | 341 | }
|
0 commit comments