diff --git a/config/servicemappings/sql.yaml b/config/servicemappings/sql.yaml index 23e6b2b5ce..ca4465dba8 100644 --- a/config/servicemappings/sql.yaml +++ b/config/servicemappings/sql.yaml @@ -43,6 +43,8 @@ spec: containers: - type: project tfField: project + mutableButUnreadableFields: + - deletion_policy - name: google_sql_database_instance kind: SQLInstance metadataMapping: diff --git a/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/_generated_object_sqldatabase.golden.yaml b/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasebasic/_generated_object_sqldatabasebasic.golden.yaml similarity index 94% rename from pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/_generated_object_sqldatabase.golden.yaml rename to pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasebasic/_generated_object_sqldatabasebasic.golden.yaml index 5e4ed40a3b..d8cb023280 100644 --- a/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/_generated_object_sqldatabase.golden.yaml +++ b/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasebasic/_generated_object_sqldatabasebasic.golden.yaml @@ -3,6 +3,7 @@ kind: SQLDatabase metadata: annotations: cnrm.cloud.google.com/management-conflict-prevention-policy: none + cnrm.cloud.google.com/mutable-but-unreadable-fields: '{}' cnrm.cloud.google.com/project-id: ${projectId} cnrm.cloud.google.com/state-into-spec: absent finalizers: diff --git a/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/_http.log b/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasebasic/_http.log similarity index 100% rename from pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/_http.log rename to pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasebasic/_http.log diff --git a/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/create.yaml b/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasebasic/create.yaml similarity index 100% rename from pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/create.yaml rename to pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasebasic/create.yaml diff --git a/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/dependencies.yaml b/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasebasic/dependencies.yaml similarity index 100% rename from pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/dependencies.yaml rename to pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasebasic/dependencies.yaml diff --git a/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/update.yaml b/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasebasic/update.yaml similarity index 100% rename from pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/update.yaml rename to pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasebasic/update.yaml diff --git a/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasesismerge/_generated_object_sqldatabasesismerge.golden.yaml b/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasesismerge/_generated_object_sqldatabasesismerge.golden.yaml new file mode 100644 index 0000000000..4f3e82cfbf --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasesismerge/_generated_object_sqldatabasesismerge.golden.yaml @@ -0,0 +1,32 @@ +apiVersion: sql.cnrm.cloud.google.com/v1beta1 +kind: SQLDatabase +metadata: + annotations: + cnrm.cloud.google.com/management-conflict-prevention-policy: none + cnrm.cloud.google.com/mutable-but-unreadable-fields: '{"spec":{"deletionPolicy":"DELETE"}}' + cnrm.cloud.google.com/project-id: ${projectId} + cnrm.cloud.google.com/state-into-spec: merge + finalizers: + - cnrm.cloud.google.com/finalizer + - cnrm.cloud.google.com/deletion-defender + generation: 3 + labels: + cnrm-test: "true" + name: sqldatabase-${uniqueId} + namespace: ${uniqueId} +spec: + charset: utf8mb4 + collation: utf8mb4_bin + deletionPolicy: DELETE + instanceRef: + name: sqlinstance-${uniqueId} + resourceID: sqldatabase-${uniqueId} +status: + conditions: + - lastTransitionTime: "1970-01-01T00:00:00Z" + message: The resource is up to date + reason: UpToDate + status: "True" + type: Ready + observedGeneration: 3 + selfLink: https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}/databases/sqldatabase-${uniqueId} diff --git a/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasesismerge/_http.log b/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasesismerge/_http.log new file mode 100644 index 0000000000..b524d7d6c1 --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasesismerge/_http.log @@ -0,0 +1,809 @@ +GET https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}?alt=json&prettyPrint=false +User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +404 Not Found +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "error": { + "code": 404, + "errors": [ + { + "domain": "global", + "message": "The Cloud SQL instance does not exist.", + "reason": "instanceDoesNotExist" + } + ], + "message": "The Cloud SQL instance does not exist." + } +} + +--- + +POST https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances?alt=json&prettyPrint=false +Content-Type: application/json +User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +{ + "databaseVersion": "MYSQL_8_0", + "name": "sqlinstance-${uniqueId}", + "region": "us-central1", + "settings": { + "activationPolicy": "ALWAYS", + "availabilityType": "ZONAL", + "dataDiskType": "PD_SSD", + "edition": "ENTERPRISE", + "pricingPlan": "PER_USE", + "storageAutoResize": true, + "tier": "db-n1-standard-1", + "userLabels": { + "cnrm-test": "true", + "label-one": "value-one", + "managed-by-cnrm": "true" + } + } +} + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "insertTime": "2024-04-01T12:34:56.123456Z", + "kind": "sql#operation", + "name": "${operationID}", + "operationType": "CREATE", + "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/operations/${operationID}", + "status": "PENDING", + "targetId": "sqlinstance-${uniqueId}", + "targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}", + "targetProject": "${projectId}", + "user": "user@example.com" +} + +--- + +GET https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/operations/${operationID}?alt=json&prettyPrint=false +User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "endTime": "2024-04-01T12:34:56.123456Z", + "insertTime": "2024-04-01T12:34:56.123456Z", + "kind": "sql#operation", + "name": "${operationID}", + "operationType": "CREATE", + "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "DONE", + "targetId": "sqlinstance-${uniqueId}", + "targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}", + "targetProject": "${projectId}", + "user": "user@example.com" +} + +--- + +GET https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}/users?alt=json&prettyPrint=false +User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "items": [ + { + "etag": "abcdef0123A=", + "host": "", + "instance": "sqlinstance-${uniqueId}", + "kind": "sql#user", + "name": "root", + "project": "${projectId}" + } + ], + "kind": "sql#usersList" +} + +--- + +DELETE https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}/users?alt=json&host=%25&name=root&prettyPrint=false +User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "endTime": "2024-04-01T12:34:56.123456Z", + "insertTime": "2024-04-01T12:34:56.123456Z", + "kind": "sql#operation", + "name": "${operationID}", + "operationType": "DELETE_USER", + "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "DONE", + "targetId": "sqlinstance-${uniqueId}", + "targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}", + "targetProject": "${projectId}", + "user": "user@example.com" +} + +--- + +GET https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}?alt=json&prettyPrint=false +User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "backendType": "SECOND_GEN", + "connectionName": "${projectId}:us-central1:sqlinstance-${uniqueId}", + "createTime": "2024-04-01T12:34:56.123456Z", + "databaseInstalledVersion": "MYSQL_8_0_31", + "databaseVersion": "MYSQL_8_0", + "etag": "abcdef0123A=", + "gceZone": "us-central1-a", + "geminiConfig": { + "entitled": false, + "flagRecommenderEnabled": false, + "indexAdvisorEnabled": false + }, + "instanceType": "CLOUD_SQL_INSTANCE", + "ipAddresses": [ + { + "ipAddress": "10.1.2.3", + "type": "PRIMARY" + } + ], + "kind": "sql#instance", + "maintenanceVersion": "MYSQL_8_0_31.R20240527.01_00", + "name": "sqlinstance-${uniqueId}", + "project": "${projectId}", + "region": "us-central1", + "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}", + "serverCaCert": { + "cert": "-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----\n", + "certSerialNumber": "0", + "commonName": "common-name", + "createTime": "2024-04-01T12:34:56.123456Z", + "expirationTime": "2024-04-01T12:34:56.123456Z", + "instance": "sqlinstance-${uniqueId}", + "kind": "sql#sslCert", + "sha1Fingerprint": "12345678" + }, + "serviceAccountEmailAddress": "p${projectNumber}-abcdef@gcp-sa-cloud-sql.iam.gserviceaccount.com", + "settings": { + "activationPolicy": "ALWAYS", + "authorizedGaeApplications": [], + "availabilityType": "ZONAL", + "backupConfiguration": { + "backupRetentionSettings": { + "retainedBackups": 7, + "retentionUnit": "COUNT" + }, + "enabled": false, + "kind": "sql#backupConfiguration", + "startTime": "12:00", + "transactionLogRetentionDays": 7, + "transactionalLogStorageState": "TRANSACTIONAL_LOG_STORAGE_STATE_UNSPECIFIED" + }, + "connectorEnforcement": "NOT_REQUIRED", + "dataDiskSizeGb": "10", + "dataDiskType": "PD_SSD", + "deletionProtectionEnabled": false, + "edition": "ENTERPRISE", + "ipConfiguration": { + "authorizedNetworks": [], + "ipv4Enabled": true, + "requireSsl": false, + "sslMode": "ALLOW_UNENCRYPTED_AND_ENCRYPTED" + }, + "kind": "sql#settings", + "locationPreference": { + "kind": "sql#locationPreference", + "zone": "us-central1-a" + }, + "pricingPlan": "PER_USE", + "replicationType": "SYNCHRONOUS", + "settingsVersion": "123", + "storageAutoResize": true, + "storageAutoResizeLimit": "0", + "tier": "db-n1-standard-1", + "userLabels": { + "cnrm-test": "true", + "label-one": "value-one", + "managed-by-cnrm": "true" + } + }, + "sqlNetworkArchitecture": "NEW_NETWORK_ARCHITECTURE", + "state": "RUNNABLE", + "upgradableDatabaseVersions": [ + { + "displayName": "MySQL 8.0.18", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_18" + }, + { + "displayName": "MySQL 8.0.26", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_26" + }, + { + "displayName": "MySQL 8.0.27", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_27" + }, + { + "displayName": "MySQL 8.0.28", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_28" + }, + { + "displayName": "MySQL 8.0.29", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_29" + }, + { + "displayName": "MySQL 8.0.30", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_30" + }, + { + "displayName": "MySQL 8.0.32", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_32" + }, + { + "displayName": "MySQL 8.0.33", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_33" + }, + { + "displayName": "MySQL 8.0.34", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_34" + }, + { + "displayName": "MySQL 8.0.35", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_35" + }, + { + "displayName": "MySQL 8.0.36", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_36" + }, + { + "displayName": "MySQL 8.0.37", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_37" + } + ] +} + +--- + +GET https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}/databases/sqldatabase-${uniqueId}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +404 Not Found +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "error": { + "code": 404, + "errors": [ + { + "domain": "global", + "message": "Not Found", + "reason": "notFound" + } + ], + "message": "Not Found", + "status": "NOT_FOUND" + } +} + +--- + +POST https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}/databases?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +{ + "charset": "utf8mb4", + "collation": "utf8mb4_0900_ai_ci", + "instance": "sqlinstance-${uniqueId}", + "name": "sqldatabase-${uniqueId}" +} + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "endTime": "2024-04-01T12:34:56.123456Z", + "insertTime": "2024-04-01T12:34:56.123456Z", + "kind": "sql#operation", + "name": "${operationID}", + "operationType": "CREATE_DATABASE", + "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "DONE", + "targetId": "sqlinstance-${uniqueId}", + "targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}/databases/sqldatabase-${uniqueId}", + "targetProject": "${projectId}", + "user": "user@example.com" +} + +--- + +GET https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}/databases/sqldatabase-${uniqueId}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "charset": "utf8mb4", + "collation": "utf8mb4_0900_ai_ci", + "etag": "abcdef0123A=", + "instance": "sqlinstance-${uniqueId}", + "kind": "sql#database", + "name": "sqldatabase-${uniqueId}", + "project": "${projectId}", + "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}/databases/sqldatabase-${uniqueId}" +} + +--- + +PUT https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}/databases/sqldatabase-${uniqueId}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +{ + "charset": "utf8mb4", + "collation": "utf8mb4_bin", + "instance": "sqlinstance-${uniqueId}", + "name": "sqldatabase-${uniqueId}" +} + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "insertTime": "2024-04-01T12:34:56.123456Z", + "kind": "sql#operation", + "name": "${operationID}", + "operationType": "UPDATE_DATABASE", + "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/operations/${operationID}", + "status": "PENDING", + "targetId": "sqlinstance-${uniqueId}", + "targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}/databases/sqldatabase-${uniqueId}", + "targetProject": "${projectId}", + "user": "user@example.com" +} + +--- + +GET https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/operations/${operationID}?alt=json&prettyPrint=false +User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "endTime": "2024-04-01T12:34:56.123456Z", + "insertTime": "2024-04-01T12:34:56.123456Z", + "kind": "sql#operation", + "name": "${operationID}", + "operationType": "UPDATE_DATABASE", + "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "DONE", + "targetId": "sqlinstance-${uniqueId}", + "targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}/databases/sqldatabase-${uniqueId}", + "targetProject": "${projectId}", + "user": "user@example.com" +} + +--- + +GET https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}/databases/sqldatabase-${uniqueId}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "charset": "utf8mb4", + "collation": "utf8mb4_bin", + "etag": "abcdef0123A=", + "instance": "sqlinstance-${uniqueId}", + "kind": "sql#database", + "name": "sqldatabase-${uniqueId}", + "project": "${projectId}", + "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}/databases/sqldatabase-${uniqueId}" +} + +--- + +DELETE https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}/databases/sqldatabase-${uniqueId}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "insertTime": "2024-04-01T12:34:56.123456Z", + "kind": "sql#operation", + "name": "${operationID}", + "operationType": "DELETE_DATABASE", + "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/operations/${operationID}", + "status": "PENDING", + "targetId": "sqlinstance-${uniqueId}", + "targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}/databases/sqldatabase-${uniqueId}", + "targetProject": "${projectId}", + "user": "user@example.com" +} + +--- + +GET https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/operations/${operationID}?alt=json&prettyPrint=false +User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "endTime": "2024-04-01T12:34:56.123456Z", + "insertTime": "2024-04-01T12:34:56.123456Z", + "kind": "sql#operation", + "name": "${operationID}", + "operationType": "DELETE_DATABASE", + "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "DONE", + "targetId": "sqlinstance-${uniqueId}", + "targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}/databases/sqldatabase-${uniqueId}", + "targetProject": "${projectId}", + "user": "user@example.com" +} + +--- + +GET https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}?alt=json&prettyPrint=false +User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "backendType": "SECOND_GEN", + "connectionName": "${projectId}:us-central1:sqlinstance-${uniqueId}", + "createTime": "2024-04-01T12:34:56.123456Z", + "databaseInstalledVersion": "MYSQL_8_0_31", + "databaseVersion": "MYSQL_8_0", + "etag": "abcdef0123A=", + "gceZone": "us-central1-a", + "geminiConfig": { + "entitled": false, + "flagRecommenderEnabled": false, + "indexAdvisorEnabled": false + }, + "instanceType": "CLOUD_SQL_INSTANCE", + "ipAddresses": [ + { + "ipAddress": "10.1.2.3", + "type": "PRIMARY" + } + ], + "kind": "sql#instance", + "maintenanceVersion": "MYSQL_8_0_31.R20240527.01_00", + "name": "sqlinstance-${uniqueId}", + "project": "${projectId}", + "region": "us-central1", + "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}", + "serverCaCert": { + "cert": "-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----\n", + "certSerialNumber": "0", + "commonName": "common-name", + "createTime": "2024-04-01T12:34:56.123456Z", + "expirationTime": "2024-04-01T12:34:56.123456Z", + "instance": "sqlinstance-${uniqueId}", + "kind": "sql#sslCert", + "sha1Fingerprint": "12345678" + }, + "serviceAccountEmailAddress": "p${projectNumber}-abcdef@gcp-sa-cloud-sql.iam.gserviceaccount.com", + "settings": { + "activationPolicy": "ALWAYS", + "authorizedGaeApplications": [], + "availabilityType": "ZONAL", + "backupConfiguration": { + "backupRetentionSettings": { + "retainedBackups": 7, + "retentionUnit": "COUNT" + }, + "enabled": false, + "kind": "sql#backupConfiguration", + "startTime": "12:00", + "transactionLogRetentionDays": 7, + "transactionalLogStorageState": "TRANSACTIONAL_LOG_STORAGE_STATE_UNSPECIFIED" + }, + "connectorEnforcement": "NOT_REQUIRED", + "dataDiskSizeGb": "10", + "dataDiskType": "PD_SSD", + "deletionProtectionEnabled": false, + "edition": "ENTERPRISE", + "ipConfiguration": { + "authorizedNetworks": [], + "ipv4Enabled": true, + "requireSsl": false, + "sslMode": "ALLOW_UNENCRYPTED_AND_ENCRYPTED" + }, + "kind": "sql#settings", + "locationPreference": { + "kind": "sql#locationPreference", + "zone": "us-central1-a" + }, + "pricingPlan": "PER_USE", + "replicationType": "SYNCHRONOUS", + "settingsVersion": "123", + "storageAutoResize": true, + "storageAutoResizeLimit": "0", + "tier": "db-n1-standard-1", + "userLabels": { + "cnrm-test": "true", + "label-one": "value-one", + "managed-by-cnrm": "true" + } + }, + "sqlNetworkArchitecture": "NEW_NETWORK_ARCHITECTURE", + "state": "RUNNABLE", + "upgradableDatabaseVersions": [ + { + "displayName": "MySQL 8.0.18", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_18" + }, + { + "displayName": "MySQL 8.0.26", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_26" + }, + { + "displayName": "MySQL 8.0.27", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_27" + }, + { + "displayName": "MySQL 8.0.28", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_28" + }, + { + "displayName": "MySQL 8.0.29", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_29" + }, + { + "displayName": "MySQL 8.0.30", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_30" + }, + { + "displayName": "MySQL 8.0.32", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_32" + }, + { + "displayName": "MySQL 8.0.33", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_33" + }, + { + "displayName": "MySQL 8.0.34", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_34" + }, + { + "displayName": "MySQL 8.0.35", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_35" + }, + { + "displayName": "MySQL 8.0.36", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_36" + }, + { + "displayName": "MySQL 8.0.37", + "majorVersion": "MYSQL_8_0", + "name": "MYSQL_8_0_37" + } + ] +} + +--- + +DELETE https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}?alt=json&prettyPrint=false +User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "insertTime": "2024-04-01T12:34:56.123456Z", + "kind": "sql#operation", + "name": "${operationID}", + "operationType": "DELETE", + "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/operations/${operationID}", + "status": "PENDING", + "targetId": "sqlinstance-${uniqueId}", + "targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}", + "targetProject": "${projectId}", + "user": "user@example.com" +} + +--- + +GET https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/operations/${operationID}?alt=json&prettyPrint=false +User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "endTime": "2024-04-01T12:34:56.123456Z", + "insertTime": "2024-04-01T12:34:56.123456Z", + "kind": "sql#operation", + "name": "${operationID}", + "operationType": "DELETE", + "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "DONE", + "targetId": "sqlinstance-${uniqueId}", + "targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}", + "targetProject": "${projectId}", + "user": "user@example.com" +} \ No newline at end of file diff --git a/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasesismerge/create.yaml b/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasesismerge/create.yaml new file mode 100644 index 0000000000..59d630e662 --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasesismerge/create.yaml @@ -0,0 +1,26 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: sql.cnrm.cloud.google.com/v1beta1 +kind: SQLDatabase +metadata: + annotations: + cnrm.cloud.google.com/state-into-spec: merge + name: sqldatabase-${uniqueId} +spec: + charset: utf8mb4 + collation: utf8mb4_0900_ai_ci + deletionPolicy: ABANDON + instanceRef: + name: sqlinstance-${uniqueId} diff --git a/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasesismerge/dependencies.yaml b/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasesismerge/dependencies.yaml new file mode 100644 index 0000000000..df808ca86f --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasesismerge/dependencies.yaml @@ -0,0 +1,25 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: sql.cnrm.cloud.google.com/v1beta1 +kind: SQLInstance +metadata: + labels: + label-one: "value-one" + name: sqlinstance-${uniqueId} +spec: + region: us-central1 + databaseVersion: MYSQL_8_0 + settings: + tier: db-n1-standard-1 diff --git a/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasesismerge/update.yaml b/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasesismerge/update.yaml new file mode 100644 index 0000000000..6088d22ace --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/sql/v1beta1/sqldatabase/sqldatabasesismerge/update.yaml @@ -0,0 +1,26 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: sql.cnrm.cloud.google.com/v1beta1 +kind: SQLDatabase +metadata: + annotations: + cnrm.cloud.google.com/state-into-spec: merge + name: sqldatabase-${uniqueId} +spec: + charset: utf8mb4 + collation: utf8mb4_bin + deletionPolicy: DELETE + instanceRef: + name: sqlinstance-${uniqueId}