Skip to content

Commit

Permalink
feat: add option to ignore savings on scheduled rebalance (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikenorgate authored Jun 21, 2024
1 parent 4f5d23b commit 2b02380
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
8 changes: 8 additions & 0 deletions castai/resource_rebalancing_schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ func resourceRebalancingSchedule() *schema.Resource {
ValidateDiagFunc: validation.ToDiagFunc(validation.FloatAtLeast(0.0)),
Description: "Defines the minimum percentage of savings expected.",
},
"ignore_savings": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "If true, the savings percentage will be ignored and the rebalancing will be triggered regardless of the savings percentage.",
},
},
},
},
Expand Down Expand Up @@ -261,6 +267,7 @@ func stateToSchedule(d *schema.ResourceData) (*sdk.ScheduledrebalancingV1Rebalan
if triggerConditions := toSection(d, "trigger_conditions"); triggerConditions != nil {
result.TriggerConditions = sdk.ScheduledrebalancingV1TriggerConditions{
SavingsPercentage: readOptionalNumber[float64, float32](triggerConditions, "savings_percentage"),
IgnoreSavings: readOptionalValue[bool](triggerConditions, "ignore_savings"),
}
}

Expand Down Expand Up @@ -348,6 +355,7 @@ func scheduleToState(schedule *sdk.ScheduledrebalancingV1RebalancingSchedule, d

triggerConditions := map[string]any{
"savings_percentage": toFloat64PtrTruncated(schedule.TriggerConditions.SavingsPercentage),
"ignore_savings": schedule.TriggerConditions.IgnoreSavings,
}
if err := d.Set("trigger_conditions", []map[string]any{triggerConditions}); err != nil {
return err
Expand Down
23 changes: 17 additions & 6 deletions castai/sdk/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions docs/resources/rebalancing_schedule.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2b02380

Please sign in to comment.