Skip to content

Commit

Permalink
Add default values for string fields
Browse files Browse the repository at this point in the history
  • Loading branch information
csmarchbanks committed Jul 10, 2024
1 parent 9f08406 commit ea335d7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/resources/machinelearning/resource_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand Down Expand Up @@ -116,21 +117,29 @@ func (r *alertResource) Schema(ctx context.Context, req resource.SchemaRequest,
"anomaly_condition": schema.StringAttribute{
Description: "The condition for when to consider a point as anomalous.",
Optional: true,
Computed: true,
Default: stringdefault.StaticString("any"),
Validators: []validator.String{
stringvalidator.OneOf("any", "low", "high"),
},
},
"for": schema.StringAttribute{
Description: "How long values must be anomalous before firing an alert.",
Optional: true,
Computed: true,
Default: stringdefault.StaticString("0s"),
},
"threshold": schema.StringAttribute{
Description: "The threshold of points over the window that need to be anomalous to alert.",
Optional: true,
Computed: true,
Default: stringdefault.StaticString(""),
},
"window": schema.StringAttribute{
Description: "How much time to average values over",
Optional: true,
Computed: true,
Default: stringdefault.StaticString("0s"),
},
"labels": schema.MapAttribute{
Description: "Labels to add to the alert generated in Grafana.",
Expand All @@ -145,6 +154,8 @@ func (r *alertResource) Schema(ctx context.Context, req resource.SchemaRequest,
"no_data_state": schema.StringAttribute{
Description: "How the alert should be processed when no data is returned by the underlying series",
Optional: true,
Computed: true,
Default: stringdefault.StaticString("OK"),
Validators: []validator.String{
stringvalidator.OneOf("Alerting", "NoData", "OK"),
},
Expand Down

0 comments on commit ea335d7

Please sign in to comment.