diff --git a/mockgcp/mockcompute/targetgrpcproxyv1.go b/mockgcp/mockcompute/targetgrpcproxyv1.go index bf7d65a31f..81db89bbcb 100644 --- a/mockgcp/mockcompute/targetgrpcproxyv1.go +++ b/mockgcp/mockcompute/targetgrpcproxyv1.go @@ -16,6 +16,7 @@ package mockcompute import ( "context" + "fmt" "strings" "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/common/projects" @@ -60,6 +61,7 @@ func (s *TargetGrpcProxyV1) Insert(ctx context.Context, req *pb.InsertTargetGrpc obj := proto.Clone(req.GetTargetGrpcProxyResource()).(*pb.TargetGrpcProxy) obj.SelfLink = PtrTo("https://www.googleapis.com/compute/v1/" + name.String()) + obj.SelfLinkWithId = PtrTo(fmt.Sprintf("https://www.googleapis.com/compute/v1/projects/%s/global/targetGrpcProxies/%d", name.Project.ID, id)) obj.CreationTimestamp = PtrTo(s.nowString()) obj.Id = &id obj.Kind = PtrTo("compute#targetGrpcProxy") diff --git a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computeforwardingrule/globalcomputeforwardingrulegrpcproxy/_generated_object_globalcomputeforwardingrulegrpcproxy.golden.yaml b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computeforwardingrule/globalcomputeforwardingrulegrpcproxy/_generated_object_globalcomputeforwardingrulegrpcproxy.golden.yaml index 984e7b4b54..4b17919d59 100644 --- a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computeforwardingrule/globalcomputeforwardingrulegrpcproxy/_generated_object_globalcomputeforwardingrulegrpcproxy.golden.yaml +++ b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computeforwardingrule/globalcomputeforwardingrulegrpcproxy/_generated_object_globalcomputeforwardingrulegrpcproxy.golden.yaml @@ -7,10 +7,10 @@ metadata: finalizers: - cnrm.cloud.google.com/finalizer - cnrm.cloud.google.com/deletion-defender - generation: 1 + generation: 2 labels: cnrm-test: "true" - label-one: value-one + label-one: value-two name: computeregionalforwardingrule-${uniqueId} namespace: ${uniqueId} spec: @@ -23,7 +23,7 @@ spec: portRange: "100" target: targetGRPCProxyRef: - name: computetargetgrpcproxy-${uniqueId} + name: computetargetgrpcproxy-2-${uniqueId} status: conditions: - lastTransitionTime: "1970-01-01T00:00:00Z" @@ -34,5 +34,5 @@ status: creationTimestamp: "1970-01-01T00:00:00Z" externalRef: //compute.googleapis.com/projects/${projectId}/global/forwardingrules/computeregionalforwardingrule-${uniqueId} labelFingerprint: abcdef0123A= - observedGeneration: 1 + observedGeneration: 2 selfLink: https://www.googleapis.com/compute/v1/projects/${projectId}/global/forwardingRules/computeregionalforwardingrule-${uniqueId} diff --git a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computeforwardingrule/globalcomputeforwardingrulegrpcproxy/_http.log b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computeforwardingrule/globalcomputeforwardingrulegrpcproxy/_http.log index a72b970f5c..10cae29376 100644 --- a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computeforwardingrule/globalcomputeforwardingrulegrpcproxy/_http.log +++ b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computeforwardingrule/globalcomputeforwardingrulegrpcproxy/_http.log @@ -321,6 +321,139 @@ X-Xss-Protection: 0 "kind": "compute#targetGrpcProxy", "name": "computetargetgrpcproxy-${uniqueId}", "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies/computetargetgrpcproxy-${uniqueId}", + "selfLinkWithId": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies/${targetGrpcProxiesId}", + "urlMap": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/urlMaps/computeurlmap-${uniqueId}", + "validateForProxyless": true +} + +--- + +GET https://compute.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies/computetargetgrpcproxy-2-${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": "The resource 'projects/${projectId}/global/targetGrpcProxies/computetargetgrpcproxy-2-${uniqueId}' was not found", + "reason": "notFound" + } + ], + "message": "The resource 'projects/${projectId}/global/targetGrpcProxies/computetargetgrpcproxy-2-${uniqueId}' was not found" + } +} + +--- + +POST https://compute.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies?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 + +{ + "description": "Another target gRPC proxy intended for load balancing gRPC traffic, referenced by global forwarding rules. References a URL map which specifies how traffic routes to gRPC backend services.", + "name": "computetargetgrpcproxy-2-${uniqueId}", + "urlMap": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/urlMaps/computeurlmap-${uniqueId}", + "validateForProxyless": 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 + +{ + "id": "000000000000000000000", + "insertTime": "2024-04-01T12:34:56.123456Z", + "kind": "compute#operation", + "name": "${operationID}", + "operationType": "compute.targetGrpcProxies.insert", + "progress": 0, + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "RUNNING", + "targetId": "${targetGrpcProxiesId}", + "targetLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies/computetargetgrpcproxy-2-${uniqueId}", + "user": "user@example.com" +} + +--- + +GET https://compute.googleapis.com/compute/v1/projects/${projectId}/global/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", + "id": "000000000000000000000", + "insertTime": "2024-04-01T12:34:56.123456Z", + "kind": "compute#operation", + "name": "${operationID}", + "operationType": "compute.targetGrpcProxies.insert", + "progress": 100, + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "DONE", + "targetId": "${targetGrpcProxiesId}", + "targetLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies/computetargetgrpcproxy-2-${uniqueId}", + "user": "user@example.com" +} + +--- + +GET https://compute.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies/computetargetgrpcproxy-2-${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 + +{ + "creationTimestamp": "2024-04-01T12:34:56.123456Z", + "description": "Another target gRPC proxy intended for load balancing gRPC traffic, referenced by global forwarding rules. References a URL map which specifies how traffic routes to gRPC backend services.", + "fingerprint": "abcdef0123A=", + "id": "000000000000000000000", + "kind": "compute#targetGrpcProxy", + "name": "computetargetgrpcproxy-2-${uniqueId}", + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies/computetargetgrpcproxy-2-${uniqueId}", + "selfLinkWithId": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies/${targetGrpcProxiesId}", "urlMap": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/urlMaps/computeurlmap-${uniqueId}", "validateForProxyless": true } @@ -561,6 +694,161 @@ X-Xss-Protection: 0 --- +POST https://compute.googleapis.com/compute/v1/projects/${projectId}/global/forwardingRules/${forwardingRuleID}/setLabels +Content-Type: application/json +User-Agent: kcc/controller-manager +x-goog-request-params: project=${projectId}&resource=computeregionalforwardingrule-${uniqueId} + +{ + "labelFingerprint": "abcdef0123A=", + "labels": { + "cnrm-test": "true", + "label-one": "value-two", + "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 + +{ + "endTime": "2024-04-01T12:34:56.123456Z", + "id": "000000000000000000000", + "insertTime": "2024-04-01T12:34:56.123456Z", + "kind": "compute#operation", + "name": "${operationID}", + "operationType": "setLabels", + "progress": 100, + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "DONE", + "targetId": "${forwardingRulesId}", + "targetLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/forwardingRules/computeregionalforwardingrule-${uniqueId}", + "user": "user@example.com" +} + +--- + +POST https://compute.googleapis.com/compute/v1/projects/${projectId}/global/forwardingRules/${forwardingRuleID}/setTarget +Content-Type: application/json +User-Agent: kcc/controller-manager +x-goog-request-params: project=${projectId}&forwarding_rule=computeregionalforwardingrule-${uniqueId} + +{ + "target": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies/computetargetgrpcproxy-2-${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 + +{ + "id": "000000000000000000000", + "insertTime": "2024-04-01T12:34:56.123456Z", + "kind": "compute#operation", + "name": "${operationID}", + "operationType": "SetTarget", + "progress": 0, + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "RUNNING", + "targetId": "${forwardingRulesId}", + "targetLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/forwardingRules/computeregionalforwardingrule-${uniqueId}", + "user": "user@example.com" +} + +--- + +GET https://compute.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID} +Content-Type: application/json +User-Agent: kcc/controller-manager +x-goog-request-params: project=${projectId}&operation=${operationID} + +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", + "id": "000000000000000000000", + "insertTime": "2024-04-01T12:34:56.123456Z", + "kind": "compute#operation", + "name": "${operationID}", + "operationType": "SetTarget", + "progress": 100, + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "DONE", + "targetId": "${forwardingRulesId}", + "targetLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/forwardingRules/computeregionalforwardingrule-${uniqueId}", + "user": "user@example.com" +} + +--- + +GET https://compute.googleapis.com/compute/v1/projects/${projectId}/global/forwardingRules/${forwardingRuleID} +Content-Type: application/json +User-Agent: kcc/controller-manager +x-goog-request-params: project=${projectId}&forwarding_rule=computeregionalforwardingrule-${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 + +{ + "IPAddress": "8.8.8.8", + "IPProtocol": "TCP", + "creationTimestamp": "2024-04-01T12:34:56.123456Z", + "description": "A global forwarding rule", + "fingerprint": "abcdef0123A=", + "id": "000000000000000000000", + "kind": "compute#forwardingRule", + "labelFingerprint": "abcdef0123A=", + "labels": { + "cnrm-test": "true", + "label-one": "value-two", + "managed-by-cnrm": "true" + }, + "loadBalancingScheme": "INTERNAL_SELF_MANAGED", + "name": "computeregionalforwardingrule-${uniqueId}", + "network": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/networks/default", + "networkTier": "PREMIUM", + "portRange": "100-100", + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/forwardingRules/computeregionalforwardingrule-${uniqueId}", + "target": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies/computetargetgrpcproxy-2-${uniqueId}" +} + +--- + DELETE https://compute.googleapis.com/compute/v1/projects/${projectId}/global/forwardingRules/${forwardingRuleID} Content-Type: application/json User-Agent: kcc/controller-manager @@ -628,6 +916,100 @@ X-Xss-Protection: 0 --- +GET https://compute.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies/computetargetgrpcproxy-2-${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 + +{ + "creationTimestamp": "2024-04-01T12:34:56.123456Z", + "description": "Another target gRPC proxy intended for load balancing gRPC traffic, referenced by global forwarding rules. References a URL map which specifies how traffic routes to gRPC backend services.", + "fingerprint": "abcdef0123A=", + "id": "000000000000000000000", + "kind": "compute#targetGrpcProxy", + "name": "computetargetgrpcproxy-2-${uniqueId}", + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies/computetargetgrpcproxy-2-${uniqueId}", + "selfLinkWithId": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies/${targetGrpcProxiesId}", + "urlMap": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/urlMaps/computeurlmap-${uniqueId}", + "validateForProxyless": true +} + +--- + +DELETE https://compute.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies/computetargetgrpcproxy-2-${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 + +{ + "id": "000000000000000000000", + "insertTime": "2024-04-01T12:34:56.123456Z", + "kind": "compute#operation", + "name": "${operationID}", + "operationType": "compute.targetGrpcProxies.delete", + "progress": 0, + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "RUNNING", + "targetId": "${targetGrpcProxiesId}", + "targetLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies/computetargetgrpcproxy-2-${uniqueId}", + "user": "user@example.com" +} + +--- + +GET https://compute.googleapis.com/compute/v1/projects/${projectId}/global/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", + "id": "000000000000000000000", + "insertTime": "2024-04-01T12:34:56.123456Z", + "kind": "compute#operation", + "name": "${operationID}", + "operationType": "compute.targetGrpcProxies.delete", + "progress": 100, + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "DONE", + "targetId": "${targetGrpcProxiesId}", + "targetLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies/computetargetgrpcproxy-2-${uniqueId}", + "user": "user@example.com" +} + +--- + GET https://compute.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies/computetargetgrpcproxy-${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 @@ -651,6 +1033,7 @@ X-Xss-Protection: 0 "kind": "compute#targetGrpcProxy", "name": "computetargetgrpcproxy-${uniqueId}", "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies/computetargetgrpcproxy-${uniqueId}", + "selfLinkWithId": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/targetGrpcProxies/${targetGrpcProxiesId}", "urlMap": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/urlMaps/computeurlmap-${uniqueId}", "validateForProxyless": true } diff --git a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computeforwardingrule/globalcomputeforwardingrulegrpcproxy/dependencies.yaml b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computeforwardingrule/globalcomputeforwardingrulegrpcproxy/dependencies.yaml index f1721b6996..f607d06e45 100644 --- a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computeforwardingrule/globalcomputeforwardingrulegrpcproxy/dependencies.yaml +++ b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computeforwardingrule/globalcomputeforwardingrulegrpcproxy/dependencies.yaml @@ -40,4 +40,14 @@ spec: urlMapRef: name: computeurlmap-${uniqueId} validateForProxyless: true +--- +apiVersion: compute.cnrm.cloud.google.com/v1beta1 +kind: ComputeTargetGRPCProxy +metadata: + name: computetargetgrpcproxy-2-${uniqueId} +spec: + description: Another target gRPC proxy intended for load balancing gRPC traffic, referenced by global forwarding rules. References a URL map which specifies how traffic routes to gRPC backend services. + urlMapRef: + name: computeurlmap-${uniqueId} + validateForProxyless: true diff --git a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computeforwardingrule/globalcomputeforwardingrulegrpcproxy/update.yaml b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computeforwardingrule/globalcomputeforwardingrulegrpcproxy/update.yaml index 3c8ada2663..d3dea8077f 100644 --- a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computeforwardingrule/globalcomputeforwardingrulegrpcproxy/update.yaml +++ b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computeforwardingrule/globalcomputeforwardingrulegrpcproxy/update.yaml @@ -16,13 +16,13 @@ apiVersion: compute.cnrm.cloud.google.com/v1beta1 kind: ComputeForwardingRule metadata: labels: - label-one: "value-one" + label-one: "value-two" name: computeregionalforwardingrule-${uniqueId} spec: description: "A global forwarding rule" target: targetGRPCProxyRef: - name: computetargetgrpcproxy-${uniqueId} + name: computetargetgrpcproxy-2-${uniqueId} ipProtocol: "TCP" # targetGrpcProxy cannot be used with load balancing scheme EXTERNAL loadBalancingScheme: INTERNAL_SELF_MANAGED