diff --git a/.github/workflows/acc-tests.yml b/.github/workflows/acc-tests.yml index 5ecabc53c..1975e3383 100644 --- a/.github/workflows/acc-tests.yml +++ b/.github/workflows/acc-tests.yml @@ -53,33 +53,32 @@ jobs: fail-fast: false # Let all versions run, even if one fails matrix: # OSS tests, run on all versions - version: ['10.3.1', '10.2.3', '9.5.15', '8.5.27'] + version: ['11.0.0', '10.4.3', '9.5.18'] type: ['oss'] subset: ['basic', 'other', 'long'] include: - # Examples, run only on latest version - - version: '10.3.1' + - version: '11.0.0' type: 'oss' subset: examples # TLS proxy tests, run only on latest version - - version: '10.3.1' + - version: '11.0.0' type: 'tls' subset: 'basic' # Sub-path tests. Runs tests on localhost:3000/grafana/ - - version: '10.3.1' + - version: '11.0.0' type: 'subpath' subset: 'basic' - - version: '10.3.1' + - version: '11.0.0' type: 'subpath' subset: 'other' # Enterprise tests - - version: '10.3.1' + - version: '11.0.0' type: 'enterprise' subset: 'all' - - version: '9.5.15' + - version: '10.4.3' type: 'enterprise' subset: 'all' - - version: '8.5.27' + - version: '9.5.18' type: 'enterprise' subset: 'all' name: ${{ matrix.version }} - ${{ matrix.type }} - ${{ matrix.subset }} diff --git a/GNUmakefile b/GNUmakefile index 1354a2d3c..d938d8f0b 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,4 +1,4 @@ -GRAFANA_VERSION ?= 10.3.1 +GRAFANA_VERSION ?= 11.0.0 DOCKER_COMPOSE_ARGS ?= --force-recreate --detach --remove-orphans --wait testacc: diff --git a/docs/resources/message_template.md b/docs/resources/message_template.md index 14280debc..ae51c6686 100644 --- a/docs/resources/message_template.md +++ b/docs/resources/message_template.md @@ -4,7 +4,7 @@ page_title: "grafana_message_template Resource - terraform-provider-grafana" subcategory: "Alerting" description: |- Manages Grafana Alerting message templates. - Official documentation https://grafana.com/docs/grafana/latest/alerting/manage-notifications/template-notifications/create-notification-templates/HTTP API https://grafana.com/docs/grafana/next/developers/http_api/alerting_provisioning/#templates + Official documentation https://grafana.com/docs/grafana/latest/alerting/configure-notifications/template-notifications/create-notification-templates/HTTP API https://grafana.com/docs/grafana/next/developers/http_api/alerting_provisioning/#templates This resource requires Grafana 9.1.0 or later. --- @@ -12,7 +12,7 @@ description: |- Manages Grafana Alerting message templates. -* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/manage-notifications/template-notifications/create-notification-templates/) +* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/configure-notifications/template-notifications/create-notification-templates/) * [HTTP API](https://grafana.com/docs/grafana/next/developers/http_api/alerting_provisioning/#templates) This resource requires Grafana 9.1.0 or later. diff --git a/docs/resources/mute_timing.md b/docs/resources/mute_timing.md index 1d878ae45..e8faaefc4 100644 --- a/docs/resources/mute_timing.md +++ b/docs/resources/mute_timing.md @@ -4,7 +4,7 @@ page_title: "grafana_mute_timing Resource - terraform-provider-grafana" subcategory: "Alerting" description: |- Manages Grafana Alerting mute timings. - Official documentation https://grafana.com/docs/grafana/latest/alerting/manage-notifications/mute-timings/HTTP API https://grafana.com/docs/grafana/next/developers/http_api/alerting_provisioning/#mute-timings + Official documentation https://grafana.com/docs/grafana/latest/alerting/configure-notifications/mute-timings/HTTP API https://grafana.com/docs/grafana/next/developers/http_api/alerting_provisioning/#mute-timings This resource requires Grafana 9.1.0 or later. --- @@ -12,7 +12,7 @@ description: |- Manages Grafana Alerting mute timings. -* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/manage-notifications/mute-timings/) +* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/configure-notifications/mute-timings/) * [HTTP API](https://grafana.com/docs/grafana/next/developers/http_api/alerting_provisioning/#mute-timings) This resource requires Grafana 9.1.0 or later. diff --git a/docs/resources/notification_policy.md b/docs/resources/notification_policy.md index 392407578..bc675de7f 100644 --- a/docs/resources/notification_policy.md +++ b/docs/resources/notification_policy.md @@ -5,7 +5,7 @@ subcategory: "Alerting" description: |- Sets the global notification policy for Grafana. !> This resource manages the entire notification policy tree, and will overwrite any existing policies. - Official documentation https://grafana.com/docs/grafana/latest/alerting/manage-notifications/HTTP API https://grafana.com/docs/grafana/latest/developers/http_api/alerting_provisioning/ + Official documentation https://grafana.com/docs/grafana/latest/alerting/configure-notifications/HTTP API https://grafana.com/docs/grafana/latest/developers/http_api/alerting_provisioning/ This resource requires Grafana 9.1.0 or later. --- @@ -15,7 +15,7 @@ Sets the global notification policy for Grafana. !> This resource manages the entire notification policy tree, and will overwrite any existing policies. -* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/manage-notifications/) +* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/configure-notifications/) * [HTTP API](https://grafana.com/docs/grafana/latest/developers/http_api/alerting_provisioning/) This resource requires Grafana 9.1.0 or later. diff --git a/internal/resources/examples_test.go b/internal/resources/examples_test.go index 24fa81968..469b4c0de 100644 --- a/internal/resources/examples_test.go +++ b/internal/resources/examples_test.go @@ -39,23 +39,23 @@ func TestAccExamples(t *testing.T) { { category: "Alerting", testCheck: func(t *testing.T, filename string) { - testutils.CheckOSSTestsEnabled(t, ">=10.3.0") // Only run on latest OSS version. The examples should be updated to reflect their latest working config. + testutils.CheckOSSTestsEnabled(t, ">=11.0.0") // Only run on latest OSS version. The examples should be updated to reflect their latest working config. }, }, { category: "Grafana OSS", testCheck: func(t *testing.T, filename string) { if strings.Contains(filename, "sso_settings") { - t.Skip() // TODO: Run on v10.4.0 once it's released + t.Skip() // TODO: Fix the tests to run on local instances } else { - testutils.CheckOSSTestsEnabled(t, ">=10.3.0") // Only run on latest OSS version. The examples should be updated to reflect their latest working config. + testutils.CheckOSSTestsEnabled(t, ">=11.0.0") // Only run on latest OSS version. The examples should be updated to reflect their latest working config. } }, }, { category: "Grafana Enterprise", testCheck: func(t *testing.T, filename string) { - testutils.CheckEnterpriseTestsEnabled(t, ">=10.3.0") // Only run on latest version + testutils.CheckEnterpriseTestsEnabled(t, ">=11.0.0") // Only run on latest version }, }, diff --git a/internal/resources/grafana/common_check_exists_test.go b/internal/resources/grafana/common_check_exists_test.go index 708436550..bcada03d4 100644 --- a/internal/resources/grafana/common_check_exists_test.go +++ b/internal/resources/grafana/common_check_exists_test.go @@ -2,11 +2,13 @@ package grafana_test import ( "fmt" + "os" "strconv" "strings" "github.com/go-openapi/runtime" goapi "github.com/grafana/grafana-openapi-client-go/client" + "github.com/grafana/grafana-openapi-client-go/client/annotations" "github.com/grafana/grafana-openapi-client-go/client/provisioning" "github.com/grafana/grafana-openapi-client-go/models" "github.com/grafana/terraform-provider-grafana/v2/internal/common" @@ -24,6 +26,9 @@ var ( func(client *goapi.GrafanaHTTPAPI, id string) (*models.ContactPoints, error) { params := provisioning.NewGetContactpointsParams().WithName(&id) resp, err := client.Provisioning.GetContactpoints(params) + if castErr, ok := err.(*runtime.APIError); strings.HasPrefix(os.Getenv("GRAFANA_VERSION"), "10.4") && ok && castErr.Code == 500 { + return nil, &runtime.APIError{Code: 404} // There's a bug in 10.4 where the API returns a 500 if no contact points are found + } if err != nil { return nil, err } @@ -72,8 +77,16 @@ var ( annotationsCheckExists = newCheckExistsHelper( func(a *models.Annotation) string { return strconv.FormatInt(a.ID, 10) }, func(client *goapi.GrafanaHTTPAPI, id string) (*models.Annotation, error) { - resp, err := client.Annotations.GetAnnotationByID(id) - return payloadOrError(resp, err) + resp, err := client.Annotations.GetAnnotations(annotations.NewGetAnnotationsParams()) + if err != nil { + return nil, err + } + for _, a := range resp.Payload { + if strconv.FormatInt(a.ID, 10) == id { + return a, nil + } + } + return nil, &runtime.APIError{Code: 404, Response: "annotation not found"} }, ) dashboardCheckExists = newCheckExistsHelper( diff --git a/internal/resources/grafana/resource_alerting_message_template.go b/internal/resources/grafana/resource_alerting_message_template.go index 7ee2d28e9..df18285d3 100644 --- a/internal/resources/grafana/resource_alerting_message_template.go +++ b/internal/resources/grafana/resource_alerting_message_template.go @@ -21,7 +21,7 @@ func resourceMessageTemplate() *common.Resource { Description: ` Manages Grafana Alerting message templates. -* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/manage-notifications/template-notifications/create-notification-templates/) +* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/configure-notifications/template-notifications/create-notification-templates/) * [HTTP API](https://grafana.com/docs/grafana/next/developers/http_api/alerting_provisioning/#templates) This resource requires Grafana 9.1.0 or later. diff --git a/internal/resources/grafana/resource_alerting_mute_timing.go b/internal/resources/grafana/resource_alerting_mute_timing.go index 5ad50b070..62b787cd2 100644 --- a/internal/resources/grafana/resource_alerting_mute_timing.go +++ b/internal/resources/grafana/resource_alerting_mute_timing.go @@ -19,7 +19,7 @@ func resourceMuteTiming() *common.Resource { Description: ` Manages Grafana Alerting mute timings. -* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/manage-notifications/mute-timings/) +* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/configure-notifications/mute-timings/) * [HTTP API](https://grafana.com/docs/grafana/next/developers/http_api/alerting_provisioning/#mute-timings) This resource requires Grafana 9.1.0 or later. diff --git a/internal/resources/grafana/resource_alerting_notification_policy.go b/internal/resources/grafana/resource_alerting_notification_policy.go index 5a3e2cf7c..104af855c 100644 --- a/internal/resources/grafana/resource_alerting_notification_policy.go +++ b/internal/resources/grafana/resource_alerting_notification_policy.go @@ -24,7 +24,7 @@ Sets the global notification policy for Grafana. !> This resource manages the entire notification policy tree, and will overwrite any existing policies. -* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/manage-notifications/) +* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/configure-notifications/) * [HTTP API](https://grafana.com/docs/grafana/latest/developers/http_api/alerting_provisioning/) This resource requires Grafana 9.1.0 or later. diff --git a/internal/resources/grafana/resource_alerting_rule_group_test.go b/internal/resources/grafana/resource_alerting_rule_group_test.go index 170746fc6..32be069bc 100644 --- a/internal/resources/grafana/resource_alerting_rule_group_test.go +++ b/internal/resources/grafana/resource_alerting_rule_group_test.go @@ -471,7 +471,7 @@ func TestAccAlertRule_zeroSeconds(t *testing.T) { } func TestAccAlertRule_NotificationSettings(t *testing.T) { - testutils.CheckCloudInstanceTestsEnabled(t) // TODO: Run on v10.4.0 once it's released + testutils.CheckOSSTestsEnabled(t, ">=10.4.0") var group models.AlertRuleGroup var name = acctest.RandString(10) diff --git a/internal/resources/grafana/resource_sso_settings_test.go b/internal/resources/grafana/resource_sso_settings_test.go index f9fa48e3b..6d088ec1b 100644 --- a/internal/resources/grafana/resource_sso_settings_test.go +++ b/internal/resources/grafana/resource_sso_settings_test.go @@ -16,7 +16,7 @@ import ( ) func TestSSOSettings_basic_oauth2(t *testing.T) { - testutils.CheckCloudInstanceTestsEnabled(t) // TODO: Run on v10.4.0 once it's released + testutils.CheckCloudInstanceTestsEnabled(t) // TODO: Fix the tests to run on local instances providers := []string{"gitlab", "google", "generic_oauth", "azuread", "okta"} @@ -102,7 +102,7 @@ func TestSSOSettings_basic_saml(t *testing.T) { } func TestSSOSettings_customFields(t *testing.T) { - testutils.CheckCloudInstanceTestsEnabled(t) // TODO: Run on v10.4.0 once it's released + testutils.CheckCloudInstanceTestsEnabled(t) // TODO: Fix the tests to run on local instances api := grafanaTestClient()