Skip to content

Commit fa3a872

Browse files
author
Michal Kopczynski
committed
PRICE-1437: Expose auto assignment setting in commitments module
1 parent 1e50190 commit fa3a872

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

castai/resource_commitments.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ func resourceCommitments() *schema.Resource {
225225
Description: "Scaling strategy of the commitment in CAST AI. One of: Default, CPUBased, RamBased",
226226
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"Default", "CPUBased", "RamBased"}, false)),
227227
},
228+
"auto_assignment": {
229+
Type: schema.TypeBool,
230+
Optional: true,
231+
Description: "If enabled, the commitment is automatically assigned to all clusters in the matching region. When disabled, only explicitly listed cluster assignments are used. Defaults to true for new commitments if not specified.",
232+
},
228233
}),
229234
},
230235
},

castai/resource_commitments_mapping.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ type (
7676
AllowedUsage *float64 `mapstructure:"allowed_usage,omitempty"`
7777
Assignments []*commitmentAssignmentResource `mapstructure:"assignments,omitempty"`
7878
ScalingStrategy *string `mapstructure:"scaling_strategy,omitempty"`
79+
AutoAssignment *bool `mapstructure:"auto_assignment,omitempty"`
7980
}
8081
commitmentConfigMatcherResource struct {
8182
Name string `mapstructure:"name"`
@@ -525,6 +526,9 @@ func mapCommitmentImportWithConfigToUpdateRequest(
525526
if c.Config.ScalingStrategy != nil {
526527
req.ScalingStrategy = (*sdk.CastaiInventoryV1beta1CommitmentScalingStrategy)(c.Config.ScalingStrategy)
527528
}
529+
if c.Config.AutoAssignment != nil {
530+
req.AutoAssignment = c.Config.AutoAssignment
531+
}
528532
}
529533
return req
530534
}

0 commit comments

Comments
 (0)