From 83bd23f8e6b4cdc64a64cb9d2e46629652cfdf63 Mon Sep 17 00:00:00 2001 From: Jonathan Remy Date: Thu, 31 Jul 2025 16:43:08 +0200 Subject: [PATCH 1/2] fix(cockpit): correct Cockpit Grafana URL format --- internal/services/cockpit/cockpit_test.go | 2 +- .../testdata/cockpit-import.cassette.yaml | 3 + ...ckpit-source-import-identity.cassette.yaml | 201 ++++++++++++++++++ internal/services/cockpit/types.go | 2 +- 4 files changed, 206 insertions(+), 2 deletions(-) create mode 100644 internal/services/cockpit/testdata/cockpit-import.cassette.yaml create mode 100644 internal/services/cockpit/testdata/cockpit-source-import-identity.cassette.yaml diff --git a/internal/services/cockpit/cockpit_test.go b/internal/services/cockpit/cockpit_test.go index eca369b428..3666b3282c 100644 --- a/internal/services/cockpit/cockpit_test.go +++ b/internal/services/cockpit/cockpit_test.go @@ -146,7 +146,7 @@ func checkGrafanaURL(resourceName, projectResource string) resource.TestCheckFun } projectID := rs.Primary.ID - expectedURL := fmt.Sprintf("https://%s.dashboards.obs.fr-par.scw.cloud", projectID) + expectedURL := fmt.Sprintf("https://%s.dashboard.obs.fr-par.scw.cloud", projectID) return resource.TestCheckResourceAttr(resourceName, "endpoints.0.grafana_url", expectedURL)(s) } diff --git a/internal/services/cockpit/testdata/cockpit-import.cassette.yaml b/internal/services/cockpit/testdata/cockpit-import.cassette.yaml new file mode 100644 index 0000000000..2797c38e00 --- /dev/null +++ b/internal/services/cockpit/testdata/cockpit-import.cassette.yaml @@ -0,0 +1,3 @@ +--- +version: 2 +interactions: [] diff --git a/internal/services/cockpit/testdata/cockpit-source-import-identity.cassette.yaml b/internal/services/cockpit/testdata/cockpit-source-import-identity.cassette.yaml new file mode 100644 index 0000000000..235fbb9995 --- /dev/null +++ b/internal/services/cockpit/testdata/cockpit-source-import-identity.cassette.yaml @@ -0,0 +1,201 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 128 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: '{"name":"tf_tests_cockpit_datasource_import_identity","organization_id":"105bdce1-64c0-48ab-899d-868455867ecf","description":""}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.0; darwin; arm64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/account/v3/projects + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 285 + uncompressed: false + body: '{"created_at":"2025-06-13T10:18:48.022747Z","description":"","id":"aacb5d9e-97da-4b82-9a85-4c2b554392c6","name":"tf_tests_cockpit_datasource_import_identity","organization_id":"105bdce1-64c0-48ab-899d-868455867ecf","qualification":null,"updated_at":"2025-06-13T10:18:48.022747Z"}' + headers: + Content-Length: + - "285" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Fri, 13 Jun 2025 10:18:48 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 3c24d623-a627-4cfb-9ca1-a8d493eb1cac + status: 200 OK + code: 200 + duration: 929.763ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.0; darwin; arm64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/account/v3/projects/aacb5d9e-97da-4b82-9a85-4c2b554392c6 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 330 + uncompressed: false + body: '{"created_at":"2025-06-13T10:18:48.022747Z","description":"","id":"aacb5d9e-97da-4b82-9a85-4c2b554392c6","name":"tf_tests_cockpit_datasource_import_identity","organization_id":"105bdce1-64c0-48ab-899d-868455867ecf","qualification":{"architecture_type":"unknown_architecture_type"},"updated_at":"2025-06-13T10:18:48.022747Z"}' + headers: + Content-Length: + - "330" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Fri, 13 Jun 2025 10:18:48 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - fbeaa66c-71e1-4d77-8708-04e00c8293a1 + status: 200 OK + code: 200 + duration: 156.196042ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 100 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: '{"project_id":"aacb5d9e-97da-4b82-9a85-4c2b554392c6","name":"","type":"metrics","retention_days":31}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.0; darwin; arm64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/cockpit/v1/regions/fr-par/data-sources + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 313 + uncompressed: false + body: '{"details":[{"argument_name":"name","help_message":"value length must be between 3 and 50 runes, inclusive","reason":"constraint"},{"argument_name":"name","help_message":"value does not match regex pattern \"^[A-Za-z0-9-_. ]+$\"","reason":"constraint"}],"message":"invalid argument(s)","type":"invalid_arguments"}' + headers: + Content-Length: + - "313" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Fri, 13 Jun 2025 10:18:48 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 358b8c22-455a-472e-864d-9e24043bc88c + status: 400 Bad Request + code: 400 + duration: 26.134375ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.0; darwin; arm64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/account/v3/projects/aacb5d9e-97da-4b82-9a85-4c2b554392c6 + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Fri, 13 Jun 2025 10:18:50 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 30000dd4-9410-454a-b782-2fe0b4110dae + status: 204 No Content + code: 204 + duration: 1.25992225s diff --git a/internal/services/cockpit/types.go b/internal/services/cockpit/types.go index 153f26c9f5..f20ae4554f 100644 --- a/internal/services/cockpit/types.go +++ b/internal/services/cockpit/types.go @@ -20,7 +20,7 @@ var scopeMapping = map[string]cockpit.TokenScope{ } func createGrafanaURL(projectID string, region scw.Region) string { - return fmt.Sprintf("https://%s.dashboards.obs.%s.scw.cloud", projectID, region) + return fmt.Sprintf("https://%s.dashboard.obs.%s.scw.cloud", projectID, region) } func flattenCockpitEndpoints(dataSources []*cockpit.DataSource, grafanaURL string, alertManagerURL string) []map[string]any { From 31a5ef90e3281197a2a2b48c5651fa9d13d5c899 Mon Sep 17 00:00:00 2001 From: Jonathan Remy Date: Thu, 31 Jul 2025 17:01:03 +0200 Subject: [PATCH 2/2] delete unused cassette --- .../testdata/cockpit-import.cassette.yaml | 3 - ...ckpit-source-import-identity.cassette.yaml | 201 ------------------ 2 files changed, 204 deletions(-) delete mode 100644 internal/services/cockpit/testdata/cockpit-import.cassette.yaml delete mode 100644 internal/services/cockpit/testdata/cockpit-source-import-identity.cassette.yaml diff --git a/internal/services/cockpit/testdata/cockpit-import.cassette.yaml b/internal/services/cockpit/testdata/cockpit-import.cassette.yaml deleted file mode 100644 index 2797c38e00..0000000000 --- a/internal/services/cockpit/testdata/cockpit-import.cassette.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -version: 2 -interactions: [] diff --git a/internal/services/cockpit/testdata/cockpit-source-import-identity.cassette.yaml b/internal/services/cockpit/testdata/cockpit-source-import-identity.cassette.yaml deleted file mode 100644 index 235fbb9995..0000000000 --- a/internal/services/cockpit/testdata/cockpit-source-import-identity.cassette.yaml +++ /dev/null @@ -1,201 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 128 - transfer_encoding: [] - trailer: {} - host: api.scaleway.com - remote_addr: "" - request_uri: "" - body: '{"name":"tf_tests_cockpit_datasource_import_identity","organization_id":"105bdce1-64c0-48ab-899d-868455867ecf","description":""}' - form: {} - headers: - Content-Type: - - application/json - User-Agent: - - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.0; darwin; arm64) terraform-provider/develop terraform/terraform-tests - url: https://api.scaleway.com/account/v3/projects - method: POST - response: - proto: HTTP/2.0 - proto_major: 2 - proto_minor: 0 - transfer_encoding: [] - trailer: {} - content_length: 285 - uncompressed: false - body: '{"created_at":"2025-06-13T10:18:48.022747Z","description":"","id":"aacb5d9e-97da-4b82-9a85-4c2b554392c6","name":"tf_tests_cockpit_datasource_import_identity","organization_id":"105bdce1-64c0-48ab-899d-868455867ecf","qualification":null,"updated_at":"2025-06-13T10:18:48.022747Z"}' - headers: - Content-Length: - - "285" - Content-Security-Policy: - - default-src 'none'; frame-ancestors 'none' - Content-Type: - - application/json - Date: - - Fri, 13 Jun 2025 10:18:48 GMT - Server: - - Scaleway API Gateway (fr-par-1;edge01) - Strict-Transport-Security: - - max-age=63072000 - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - DENY - X-Request-Id: - - 3c24d623-a627-4cfb-9ca1-a8d493eb1cac - status: 200 OK - code: 200 - duration: 929.763ms - - id: 1 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: api.scaleway.com - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - User-Agent: - - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.0; darwin; arm64) terraform-provider/develop terraform/terraform-tests - url: https://api.scaleway.com/account/v3/projects/aacb5d9e-97da-4b82-9a85-4c2b554392c6 - method: GET - response: - proto: HTTP/2.0 - proto_major: 2 - proto_minor: 0 - transfer_encoding: [] - trailer: {} - content_length: 330 - uncompressed: false - body: '{"created_at":"2025-06-13T10:18:48.022747Z","description":"","id":"aacb5d9e-97da-4b82-9a85-4c2b554392c6","name":"tf_tests_cockpit_datasource_import_identity","organization_id":"105bdce1-64c0-48ab-899d-868455867ecf","qualification":{"architecture_type":"unknown_architecture_type"},"updated_at":"2025-06-13T10:18:48.022747Z"}' - headers: - Content-Length: - - "330" - Content-Security-Policy: - - default-src 'none'; frame-ancestors 'none' - Content-Type: - - application/json - Date: - - Fri, 13 Jun 2025 10:18:48 GMT - Server: - - Scaleway API Gateway (fr-par-1;edge01) - Strict-Transport-Security: - - max-age=63072000 - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - DENY - X-Request-Id: - - fbeaa66c-71e1-4d77-8708-04e00c8293a1 - status: 200 OK - code: 200 - duration: 156.196042ms - - id: 2 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 100 - transfer_encoding: [] - trailer: {} - host: api.scaleway.com - remote_addr: "" - request_uri: "" - body: '{"project_id":"aacb5d9e-97da-4b82-9a85-4c2b554392c6","name":"","type":"metrics","retention_days":31}' - form: {} - headers: - Content-Type: - - application/json - User-Agent: - - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.0; darwin; arm64) terraform-provider/develop terraform/terraform-tests - url: https://api.scaleway.com/cockpit/v1/regions/fr-par/data-sources - method: POST - response: - proto: HTTP/2.0 - proto_major: 2 - proto_minor: 0 - transfer_encoding: [] - trailer: {} - content_length: 313 - uncompressed: false - body: '{"details":[{"argument_name":"name","help_message":"value length must be between 3 and 50 runes, inclusive","reason":"constraint"},{"argument_name":"name","help_message":"value does not match regex pattern \"^[A-Za-z0-9-_. ]+$\"","reason":"constraint"}],"message":"invalid argument(s)","type":"invalid_arguments"}' - headers: - Content-Length: - - "313" - Content-Security-Policy: - - default-src 'none'; frame-ancestors 'none' - Content-Type: - - application/json - Date: - - Fri, 13 Jun 2025 10:18:48 GMT - Server: - - Scaleway API Gateway (fr-par-1;edge01) - Strict-Transport-Security: - - max-age=63072000 - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - DENY - X-Request-Id: - - 358b8c22-455a-472e-864d-9e24043bc88c - status: 400 Bad Request - code: 400 - duration: 26.134375ms - - id: 3 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: api.scaleway.com - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - User-Agent: - - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.0; darwin; arm64) terraform-provider/develop terraform/terraform-tests - url: https://api.scaleway.com/account/v3/projects/aacb5d9e-97da-4b82-9a85-4c2b554392c6 - method: DELETE - response: - proto: HTTP/2.0 - proto_major: 2 - proto_minor: 0 - transfer_encoding: [] - trailer: {} - content_length: 0 - uncompressed: false - body: "" - headers: - Content-Security-Policy: - - default-src 'none'; frame-ancestors 'none' - Content-Type: - - application/json - Date: - - Fri, 13 Jun 2025 10:18:50 GMT - Server: - - Scaleway API Gateway (fr-par-1;edge01) - Strict-Transport-Security: - - max-age=63072000 - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - DENY - X-Request-Id: - - 30000dd4-9410-454a-b782-2fe0b4110dae - status: 204 No Content - code: 204 - duration: 1.25992225s