Skip to content
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

[Fix] Adds check to ensure that the Grafana-Terraform-Provider header is set #1631

Merged
merged 10 commits into from
Jun 13, 2024
1 change: 0 additions & 1 deletion internal/resources/slo/resource_slo.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ func resourceSloRead(ctx context.Context, d *schema.ResourceData, client *slo.AP

req := client.DefaultAPI.V1SloIdGet(ctx, sloID)
slo, _, err := req.Execute()

if err != nil {
return apiError("Unable to read SLO - API", err)
}
Expand Down
6 changes: 5 additions & 1 deletion internal/resources/slo/resource_slo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,14 @@ func testAccSloCheckExists(rn string, slo *slo.SloV00Slo) resource.TestCheckFunc
client := testutils.Provider.Meta().(*common.Client).SLOClient
req := client.DefaultAPI.V1SloIdGet(context.Background(), rs.Primary.ID)
gotSlo, _, err := req.Execute()

if err != nil {
return fmt.Errorf("error getting SLO: %s", err)
}

if *gotSlo.ReadOnly.Provenance != "terraform" {
return fmt.Errorf("provenance header missing - verify within the Grafana Terraform Provider that the 'Grafana-Terraform-Provider' request header is set to 'true'")
}

*slo = *gotSlo

return nil
Expand Down Expand Up @@ -155,6 +158,7 @@ func testAccSloCheckDestroy(slo *slo.SloV00Slo) resource.TestCheckFunc {
if resp.StatusCode == 404 {
return nil
}

if gotSlo.ReadOnly.Status.Type == "deleting" {
return nil
}
Expand Down
Loading