Skip to content

Commit

Permalink
wip: first pass at adding description to burn alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
lafentres committed Oct 30, 2024
1 parent 15d05ae commit 09f9347
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions client/burn_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type BurnAlert struct {
ExhaustionMinutes *int `json:"exhaustion_minutes,omitempty"`
BudgetRateWindowMinutes *int `json:"budget_rate_window_minutes,omitempty"`
BudgetRateDecreaseThresholdPerMillion *int `json:"budget_rate_decrease_threshold_per_million,omitempty"`
Description string `json:"description,omitempty"`
SLO SLORef `json:"slo"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions internal/models/burn_alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type BurnAlertResourceModel struct {
AlertType types.String `tfsdk:"alert_type"`
BudgetRateWindowMinutes types.Int64 `tfsdk:"budget_rate_window_minutes"`
BudgetRateDecreasePercent types.Float64 `tfsdk:"budget_rate_decrease_percent"`
Description types.String `tfsdk:"description"`
Dataset types.String `tfsdk:"dataset"`
SLOID types.String `tfsdk:"slo_id"`
ExhaustionMinutes types.Int64 `tfsdk:"exhaustion_minutes"`
Expand Down
15 changes: 12 additions & 3 deletions internal/provider/burn_alert_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ func (*burnAlertResource) Schema(_ context.Context, _ resource.SchemaRequest, re
stringplanmodifier.RequiresReplace(),
},
},
"description": schema.StringAttribute{
Description: "A description for this Burn Alert.",
Optional: true,
Validators: []validator.String{
stringvalidator.LengthAtMost(1023),
},
},
"exhaustion_minutes": schema.Int64Attribute{
Optional: true,
Description: "The amount of time, in minutes, remaining before the SLO's error budget will be exhausted and the alert will fire.",
Expand Down Expand Up @@ -235,9 +242,10 @@ func (r *burnAlertResource) Create(ctx context.Context, req resource.CreateReque

// Get attributes from config and construct the create request
createRequest := &client.BurnAlert{
AlertType: client.BurnAlertAlertType(plan.AlertType.ValueString()),
Recipients: expandNotificationRecipients(ctx, plan.Recipients, &resp.Diagnostics),
SLO: client.SLORef{ID: plan.SLOID.ValueString()},
AlertType: client.BurnAlertAlertType(plan.AlertType.ValueString()),
Recipients: expandNotificationRecipients(ctx, plan.Recipients, &resp.Diagnostics),
SLO: client.SLORef{ID: plan.SLOID.ValueString()},
Description: string(plan.Description.ValueString()),

Check failure on line 248 in internal/provider/burn_alert_resource.go

View workflow job for this annotation

GitHub Actions / Build

unnecessary conversion (unconvert)
}

// Process any attributes that could be nil and add them to the create request
Expand All @@ -264,6 +272,7 @@ func (r *burnAlertResource) Create(ctx context.Context, req resource.CreateReque
state.ID = types.StringValue(burnAlert.ID)
state.AlertType = types.StringValue(string(burnAlert.AlertType))
state.Dataset = plan.Dataset
state.Description = plan.Description
// we created them as authored so to avoid matching type-target or ID we can just use the same value
state.Recipients = config.Recipients
state.SLOID = types.StringValue(burnAlert.SLO.ID)
Expand Down

0 comments on commit 09f9347

Please sign in to comment.