Skip to content

Add optional preventInitialBackfill for SLO API #1071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions internal/kibana/slo.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,11 @@
Optional: true,
Computed: true,
},
"prevent_initial_backfill": {
Description: "Prevents the underlying ES transform from attempting to backfill data on start, which can sometimes be resource-intensive or time-consuming and unnecessary",
Type: schema.TypeBool,
Optional: true,
},
},
},
},
Expand Down Expand Up @@ -508,6 +513,14 @@
return nil
}

func getOrNilBool(path string, d *schema.ResourceData) *bool {
if v, ok := d.GetOk(path); ok {
b := v.(bool)
return &b
}
return nil
}

func getSloFromResourceData(d *schema.ResourceData) (models.Slo, diag.Diagnostics) {
var diags diag.Diagnostics

Expand Down Expand Up @@ -650,8 +663,9 @@
}

settings := slo.Settings{
SyncDelay: getOrNilString("settings.0.sync_delay", d),
Frequency: getOrNilString("settings.0.frequency", d),
SyncDelay: getOrNilString("settings.0.sync_delay", d),
Frequency: getOrNilString("settings.0.frequency", d),
PreventInitialBackfill: getOrNilBool("settings.0.prevent_initial_backfill", d),

Check failure on line 668 in internal/kibana/slo.go

View workflow job for this annotation

GitHub Actions / Lint

unknown field PreventInitialBackfill in struct literal of type slo.Settings

Check failure on line 668 in internal/kibana/slo.go

View workflow job for this annotation

GitHub Actions / Lint

unknown field PreventInitialBackfill in struct literal of type slo.Settings

Check failure on line 668 in internal/kibana/slo.go

View workflow job for this annotation

GitHub Actions / Build

unknown field PreventInitialBackfill in struct literal of type slo.Settings
}

budgetingMethod := slo.BudgetingMethod(d.Get("budgeting_method").(string))
Expand Down Expand Up @@ -904,8 +918,9 @@

if err := d.Set("settings", []interface{}{
map[string]interface{}{
"sync_delay": s.Settings.SyncDelay,
"frequency": s.Settings.Frequency,
"sync_delay": s.Settings.SyncDelay,
"frequency": s.Settings.Frequency,
"prevent_initial_backfill": s.Settings.PreventInitialBackfill,

Check failure on line 923 in internal/kibana/slo.go

View workflow job for this annotation

GitHub Actions / Lint

s.Settings.PreventInitialBackfill undefined (type *slo.Settings has no field or method PreventInitialBackfill) (typecheck)

Check failure on line 923 in internal/kibana/slo.go

View workflow job for this annotation

GitHub Actions / Lint

s.Settings.PreventInitialBackfill undefined (type *slo.Settings has no field or method PreventInitialBackfill)) (typecheck)

Check failure on line 923 in internal/kibana/slo.go

View workflow job for this annotation

GitHub Actions / Build

s.Settings.PreventInitialBackfill undefined (type *slo.Settings has no field or method PreventInitialBackfill)
},
}); err != nil {
return diag.FromErr(err)
Expand Down
Loading