From 3dee86f70f607f0c5e49347c96868ac5a8b2fad2 Mon Sep 17 00:00:00 2001 From: Hank Freund Date: Fri, 13 Sep 2024 09:34:36 -0700 Subject: [PATCH] Update mockgcp and tests for attached clusters. - Updated the mockgkemulticloud service to conform with current LRO handlign guidelines - Added all currently supported update mask paths to the mock service - Added a "full" test fixture with all currently supported fields and updates --- mockgcp/mockgkemulticloud/attachedcluster.go | 64 +- mockgcp/mockgkemulticloud/service.go | 16 +- ...containerattachedclusterbasic.golden.yaml} | 17 +- .../_http.log | 264 +++++-- .../create.yaml | 0 .../dependencies.yaml | 0 .../update.yaml | 2 +- ...t_containerattachedclusterfull.golden.yaml | 55 ++ .../containerattachedclusterfull/_http.log | 691 ++++++++++++++++++ .../containerattachedclusterfull/create.yaml | 46 ++ .../dependencies.yaml | 25 + .../containerattachedclusterfull/update.yaml | 47 ++ 12 files changed, 1138 insertions(+), 89 deletions(-) rename pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/{containerattachedcluster/_generated_object_containerattachedcluster.golden.yaml => containerattachedclusterbasic/_generated_object_containerattachedclusterbasic.golden.yaml} (63%) rename pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/{containerattachedcluster => containerattachedclusterbasic}/_http.log (59%) rename pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/{containerattachedcluster => containerattachedclusterbasic}/create.yaml (100%) rename pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/{containerattachedcluster => containerattachedclusterbasic}/dependencies.yaml (100%) rename pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/{containerattachedcluster => containerattachedclusterbasic}/update.yaml (97%) create mode 100644 pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/_generated_object_containerattachedclusterfull.golden.yaml create mode 100644 pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/_http.log create mode 100644 pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/create.yaml create mode 100644 pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/dependencies.yaml create mode 100644 pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/update.yaml diff --git a/mockgcp/mockgkemulticloud/attachedcluster.go b/mockgcp/mockgkemulticloud/attachedcluster.go index b85b29e84f..4c1be6bafa 100644 --- a/mockgcp/mockgkemulticloud/attachedcluster.go +++ b/mockgcp/mockgkemulticloud/attachedcluster.go @@ -16,11 +16,15 @@ package mockgkemulticloud import ( "context" + "fmt" + "time" "google.golang.org/genproto/googleapis/longrunning" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/emptypb" + "google.golang.org/protobuf/types/known/timestamppb" pb "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/generated/mockgcp/cloud/gkemulticloud/v1" ) @@ -40,6 +44,9 @@ func (s *GKEMulticloudV1) GetAttachedCluster(ctx context.Context, req *pb.GetAtt obj := &pb.AttachedCluster{} if err := s.storage.Get(ctx, fqn, obj); err != nil { + if status.Code(err) == codes.NotFound { + return nil, status.Errorf(codes.NotFound, "Resource '%s' was not found", fqn) + } return nil, err } @@ -53,6 +60,7 @@ func (s *GKEMulticloudV1) CreateAttachedCluster(ctx context.Context, req *pb.Cre return nil, err } + now := time.Now() fqn := name.String() obj := proto.Clone(req.AttachedCluster).(*pb.AttachedCluster) @@ -62,7 +70,18 @@ func (s *GKEMulticloudV1) CreateAttachedCluster(ctx context.Context, req *pb.Cre return nil, err } - return s.operations.NewLRO(ctx) + opMetadata := &pb.OperationMetadata{ + CreateTime: timestamppb.New(now), + Verb: "create", + RequestedCancellation: false, + Target: fqn, + } + opPrefix := fmt.Sprintf("projects/%s/locations/%s", name.Project.ID, name.Location) + return s.operations.StartLRO(ctx, opPrefix, opMetadata, func() (proto.Message, error) { + opMetadata.EndTime = timestamppb.Now() + obj.State = pb.AttachedCluster_RUNNING + return obj, nil + }) } func (s *GKEMulticloudV1) UpdateAttachedCluster(ctx context.Context, req *pb.UpdateAttachedClusterRequest) (*longrunning.Operation, error) { @@ -71,6 +90,7 @@ func (s *GKEMulticloudV1) UpdateAttachedCluster(ctx context.Context, req *pb.Upd return nil, err } + now := time.Now() fqn := name.String() obj := &pb.AttachedCluster{} if err := s.storage.Get(ctx, fqn, obj); err != nil { @@ -81,12 +101,13 @@ func (s *GKEMulticloudV1) UpdateAttachedCluster(ctx context.Context, req *pb.Upd // fields from // [AttachedCluster][mockgcp.cloud.gkemulticloud.v1.AttachedCluster]: // - // - `description`. // - `annotations`. - // - `platform_version`. // - `authorization.admin_users`. + // - `binary_authorization.evaluation_mode`. + // - `description`. // - `logging_config.component_config.enable_components`. // - `monitoring_config.managed_prometheus_config.enabled`. + // - `platform_version`. paths := req.GetUpdateMask().GetPaths() if len(paths) == 0 { @@ -96,8 +117,20 @@ func (s *GKEMulticloudV1) UpdateAttachedCluster(ctx context.Context, req *pb.Upd // TODO: Some sort of helper for fieldmask? for _, path := range paths { switch path { + case "annotations": + obj.Annotations = req.GetAttachedCluster().GetAnnotations() + case "authorization.admin_users": + obj.Authorization.AdminUsers = req.GetAttachedCluster().GetAuthorization().GetAdminUsers() + case "binary_authorization.evaluation_mode": + obj.BinaryAuthorization.EvaluationMode = req.GetAttachedCluster().GetBinaryAuthorization().GetEvaluationMode() case "description": obj.Description = req.GetAttachedCluster().GetDescription() + case "logging_config.component_config.enable_components": + obj.LoggingConfig.ComponentConfig.EnableComponents = req.GetAttachedCluster().GetLoggingConfig().GetComponentConfig().GetEnableComponents() + case "monitoring_config.managed_prometheus_config.enabled": + obj.MonitoringConfig = req.GetAttachedCluster().GetMonitoringConfig() + case "platformVersion": + obj.PlatformVersion = req.GetAttachedCluster().GetPlatformVersion() default: return nil, status.Errorf(codes.InvalidArgument, "update_mask path %q not valid", path) } @@ -106,7 +139,17 @@ func (s *GKEMulticloudV1) UpdateAttachedCluster(ctx context.Context, req *pb.Upd if err := s.storage.Update(ctx, fqn, obj); err != nil { return nil, err } - return s.operations.NewLRO(ctx) + opMetadata := &pb.OperationMetadata{ + CreateTime: timestamppb.New(now), + Verb: "update", + RequestedCancellation: false, + Target: fqn, + } + opPrefix := fmt.Sprintf("projects/%s/locations/%s", name.Project.ID, name.Location) + return s.operations.StartLRO(ctx, opPrefix, opMetadata, func() (proto.Message, error) { + opMetadata.EndTime = timestamppb.Now() + return obj, nil + }) } func (s *GKEMulticloudV1) DeleteAttachedCluster(ctx context.Context, req *pb.DeleteAttachedClusterRequest) (*longrunning.Operation, error) { @@ -115,6 +158,7 @@ func (s *GKEMulticloudV1) DeleteAttachedCluster(ctx context.Context, req *pb.Del return nil, err } + now := time.Now() fqn := name.String() oldObj := &pb.AttachedCluster{} @@ -122,5 +166,15 @@ func (s *GKEMulticloudV1) DeleteAttachedCluster(ctx context.Context, req *pb.Del return nil, err } - return s.operations.NewLRO(ctx) + opMetadata := &pb.OperationMetadata{ + CreateTime: timestamppb.New(now), + Verb: "delete", + RequestedCancellation: false, + Target: fqn, + } + opPrefix := fmt.Sprintf("projects/%s/locations/%s", name.Project.ID, name.Location) + return s.operations.StartLRO(ctx, opPrefix, opMetadata, func() (proto.Message, error) { + opMetadata.EndTime = timestamppb.Now() + return &emptypb.Empty{}, nil + }) } diff --git a/mockgcp/mockgkemulticloud/service.go b/mockgcp/mockgkemulticloud/service.go index 958bac10fc..9971b840dc 100644 --- a/mockgcp/mockgkemulticloud/service.go +++ b/mockgcp/mockgkemulticloud/service.go @@ -18,10 +18,10 @@ import ( "context" "net/http" - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "google.golang.org/grpc" "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/common" + "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/common/httpmux" "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/common/operations" pb "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/generated/mockgcp/cloud/gkemulticloud/v1" "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/pkg/storage" @@ -57,11 +57,19 @@ func (s *MockService) Register(grpcServer *grpc.Server) { } func (s *MockService) NewHTTPMux(ctx context.Context, conn *grpc.ClientConn) (http.Handler, error) { - mux := runtime.NewServeMux() - - if err := pb.RegisterAttachedClustersHandler(ctx, mux, conn); err != nil { + mux, err := httpmux.NewServeMux(ctx, conn, httpmux.Options{}, + pb.RegisterAttachedClustersHandler, + s.operations.RegisterOperationsPath("/v1/{prefix=**}/operations/{name}")) + if err != nil { return nil, err } + // Returns slightly non-standard errors + mux.RewriteError = func(ctx context.Context, error *httpmux.ErrorResponse) { + if error.Code == 404 { + error.Errors = nil + } + } + return mux, nil } diff --git a/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedcluster/_generated_object_containerattachedcluster.golden.yaml b/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterbasic/_generated_object_containerattachedclusterbasic.golden.yaml similarity index 63% rename from pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedcluster/_generated_object_containerattachedcluster.golden.yaml rename to pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterbasic/_generated_object_containerattachedclusterbasic.golden.yaml index 965f5c725a..a89a831909 100644 --- a/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedcluster/_generated_object_containerattachedcluster.golden.yaml +++ b/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterbasic/_generated_object_containerattachedclusterbasic.golden.yaml @@ -1,17 +1,3 @@ -# 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: containerattached.cnrm.cloud.google.com/v1beta1 kind: ContainerAttachedCluster metadata: @@ -37,7 +23,7 @@ spec: location: us-west1 oidcConfig: issuerUrl: https://oidc.eks.us-west-2.amazonaws.com/id/A115FE1C770C2452C75219524036FC0F - platformVersion: 1.27.0-gke.2 + platformVersion: 1.28.0-gke.2 projectRef: external: ${projectId} resourceID: kcc-attached-cluster-127 @@ -49,4 +35,3 @@ status: status: "True" type: Ready observedGeneration: 2 - state: STATE_UNSPECIFIED diff --git a/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedcluster/_http.log b/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterbasic/_http.log similarity index 59% rename from pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedcluster/_http.log rename to pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterbasic/_http.log index a5348ec650..6b4ca67bf0 100644 --- a/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedcluster/_http.log +++ b/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterbasic/_http.log @@ -234,12 +234,22 @@ 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 -Content-Type: application/json +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 { - "code": 5, - "details": [], - "message": "attachedCluster \"projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127\" not found" + "error": { + "code": 404, + "message": "Resource 'projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127' was not found", + "status": "NOT_FOUND" + } } --- @@ -263,13 +273,68 @@ User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 t } 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 + +{ + "metadata": { + "@type": "type.googleapis.com/google.cloud.gkemulticloud.v1.OperationMetadata", + "createTime": "2024-04-01T12:34:56.123456Z", + "target": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", + "verb": "create" + }, + "name": "projects/${projectId}/locations/us-west1/operations/${operationID}" +} + +--- + +GET https://us-west1-gkemulticloud.googleapis.com/v1/projects/${projectId}/locations/us-west1/operations/${operationID}?alt=json Content-Type: application/json -Grpc-Metadata-Content-Type: application/grpc +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 { "done": true, - "metadata": null, - "name": "operations/${operationID}" + "metadata": { + "@type": "type.googleapis.com/google.cloud.gkemulticloud.v1.OperationMetadata", + "createTime": "2024-04-01T12:34:56.123456Z", + "endTime": "2024-04-01T12:34:56.123456Z", + "target": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", + "verb": "create" + }, + "name": "projects/${projectId}/locations/us-west1/operations/${operationID}", + "response": { + "@type": "type.googleapis.com/google.cloud.gkemulticloud.v1.AttachedCluster", + "description": "Test attached cluster", + "distribution": "eks", + "fleet": { + "project": "projects/${projectNumber}" + }, + "loggingConfig": {}, + "name": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", + "oidcConfig": { + "issuerUrl": "https://oidc.eks.us-west-2.amazonaws.com/id/A115FE1C770C2452C75219524036FC0F" + }, + "platformVersion": "1.27.0-gke.2", + "state": "RUNNING" + } } --- @@ -279,45 +344,33 @@ 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 -Content-Type: application/json -Grpc-Metadata-Content-Type: application/grpc +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 { - "annotations": {}, - "authorization": null, - "binaryAuthorization": null, - "clusterRegion": "", - "createTime": null, "description": "Test attached cluster", "distribution": "eks", - "errors": [], - "etag": "abcdef0123A=", "fleet": { - "membership": "", "project": "projects/${projectNumber}" }, - "kubernetesVersion": "", - "loggingConfig": { - "componentConfig": null - }, - "monitoringConfig": null, + "loggingConfig": {}, "name": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", "oidcConfig": { - "issuerUrl": "https://oidc.eks.us-west-2.amazonaws.com/id/A115FE1C770C2452C75219524036FC0F", - "jwks": "" + "issuerUrl": "https://oidc.eks.us-west-2.amazonaws.com/id/A115FE1C770C2452C75219524036FC0F" }, - "platformVersion": "1.27.0-gke.2", - "proxyConfig": null, - "reconciling": false, - "state": "STATE_UNSPECIFIED", - "uid": "111111111111111111111", - "updateTime": null, - "workloadIdentityConfig": null + "platformVersion": "1.27.0-gke.2" } --- -PATCH https://us-west1-gkemulticloud.googleapis.com/v1/projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127?alt=json&updateMask=description +PATCH https://us-west1-gkemulticloud.googleapis.com/v1/projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127?alt=json&updateMask=description%2CplatformVersion Content-Type: application/json User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager @@ -332,17 +385,71 @@ User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 t "oidcConfig": { "issuerUrl": "https://oidc.eks.us-west-2.amazonaws.com/id/A115FE1C770C2452C75219524036FC0F" }, - "platformVersion": "1.27.0-gke.2" + "platformVersion": "1.28.0-gke.2" } 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 + +{ + "metadata": { + "@type": "type.googleapis.com/google.cloud.gkemulticloud.v1.OperationMetadata", + "createTime": "2024-04-01T12:34:56.123456Z", + "target": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", + "verb": "update" + }, + "name": "projects/${projectId}/locations/us-west1/operations/${operationID}" +} + +--- + +GET https://us-west1-gkemulticloud.googleapis.com/v1/projects/${projectId}/locations/us-west1/operations/${operationID}?alt=json Content-Type: application/json -Grpc-Metadata-Content-Type: application/grpc +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 { "done": true, - "metadata": null, - "name": "operations/${operationID}" + "metadata": { + "@type": "type.googleapis.com/google.cloud.gkemulticloud.v1.OperationMetadata", + "createTime": "2024-04-01T12:34:56.123456Z", + "endTime": "2024-04-01T12:34:56.123456Z", + "target": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", + "verb": "update" + }, + "name": "projects/${projectId}/locations/us-west1/operations/${operationID}", + "response": { + "@type": "type.googleapis.com/google.cloud.gkemulticloud.v1.AttachedCluster", + "description": "Test attached cluster update", + "distribution": "eks", + "fleet": { + "project": "projects/${projectNumber}" + }, + "loggingConfig": {}, + "name": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", + "oidcConfig": { + "issuerUrl": "https://oidc.eks.us-west-2.amazonaws.com/id/A115FE1C770C2452C75219524036FC0F" + }, + "platformVersion": "1.28.0-gke.2" + } } --- @@ -352,40 +459,28 @@ 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 -Content-Type: application/json -Grpc-Metadata-Content-Type: application/grpc +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 { - "annotations": {}, - "authorization": null, - "binaryAuthorization": null, - "clusterRegion": "", - "createTime": null, "description": "Test attached cluster update", "distribution": "eks", - "errors": [], - "etag": "abcdef0123A=", "fleet": { - "membership": "", "project": "projects/${projectNumber}" }, - "kubernetesVersion": "", - "loggingConfig": { - "componentConfig": null - }, - "monitoringConfig": null, + "loggingConfig": {}, "name": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", "oidcConfig": { - "issuerUrl": "https://oidc.eks.us-west-2.amazonaws.com/id/A115FE1C770C2452C75219524036FC0F", - "jwks": "" + "issuerUrl": "https://oidc.eks.us-west-2.amazonaws.com/id/A115FE1C770C2452C75219524036FC0F" }, - "platformVersion": "1.27.0-gke.2", - "proxyConfig": null, - "reconciling": false, - "state": "STATE_UNSPECIFIED", - "uid": "111111111111111111111", - "updateTime": null, - "workloadIdentityConfig": null + "platformVersion": "1.28.0-gke.2" } --- @@ -395,11 +490,54 @@ 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 + +{ + "metadata": { + "@type": "type.googleapis.com/google.cloud.gkemulticloud.v1.OperationMetadata", + "createTime": "2024-04-01T12:34:56.123456Z", + "target": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", + "verb": "delete" + }, + "name": "projects/${projectId}/locations/us-west1/operations/${operationID}" +} + +--- + +GET https://us-west1-gkemulticloud.googleapis.com/v1/projects/${projectId}/locations/us-west1/operations/${operationID}?alt=json Content-Type: application/json -Grpc-Metadata-Content-Type: application/grpc +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 { "done": true, - "metadata": null, - "name": "operations/${operationID}" + "metadata": { + "@type": "type.googleapis.com/google.cloud.gkemulticloud.v1.OperationMetadata", + "createTime": "2024-04-01T12:34:56.123456Z", + "endTime": "2024-04-01T12:34:56.123456Z", + "target": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", + "verb": "delete" + }, + "name": "projects/${projectId}/locations/us-west1/operations/${operationID}", + "response": { + "@type": "type.googleapis.com/google.protobuf.Empty" + } } \ No newline at end of file diff --git a/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedcluster/create.yaml b/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterbasic/create.yaml similarity index 100% rename from pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedcluster/create.yaml rename to pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterbasic/create.yaml diff --git a/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedcluster/dependencies.yaml b/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterbasic/dependencies.yaml similarity index 100% rename from pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedcluster/dependencies.yaml rename to pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterbasic/dependencies.yaml diff --git a/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedcluster/update.yaml b/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterbasic/update.yaml similarity index 97% rename from pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedcluster/update.yaml rename to pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterbasic/update.yaml index 14440fc06e..378f0ec868 100644 --- a/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedcluster/update.yaml +++ b/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterbasic/update.yaml @@ -26,7 +26,7 @@ spec: distribution: "eks" oidcConfig: issuerUrl: https://oidc.eks.us-west-2.amazonaws.com/id/A115FE1C770C2452C75219524036FC0F - platformVersion: 1.27.0-gke.2 + platformVersion: 1.28.0-gke.2 fleet: projectRef: name: project-${uniqueId} diff --git a/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/_generated_object_containerattachedclusterfull.golden.yaml b/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/_generated_object_containerattachedclusterfull.golden.yaml new file mode 100644 index 0000000000..49ea4179dc --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/_generated_object_containerattachedclusterfull.golden.yaml @@ -0,0 +1,55 @@ +apiVersion: containerattached.cnrm.cloud.google.com/v1beta1 +kind: ContainerAttachedCluster +metadata: + annotations: + cnrm.cloud.google.com/management-conflict-prevention-policy: none + cnrm.cloud.google.com/mutable-but-unreadable-fields: '{"spec":{"deletionPolicy":"DELETE_IGNORE_ERRORS"}}' + cnrm.cloud.google.com/state-into-spec: absent + finalizers: + - cnrm.cloud.google.com/finalizer + - cnrm.cloud.google.com/deletion-defender + generation: 2 + labels: + cnrm-test: "true" + name: containerattachedcluster-${uniqueId} + namespace: ${uniqueId} +spec: + annotations: + key1: value1a + key2: value2 + key3: value3 + authorization: + adminUsers: + - user1@company.com + - user2@company.com + binaryAuthorization: + evaluationMode: DISABLED + deletionPolicy: DELETE_IGNORE_ERRORS + description: Test attached cluster update + distribution: eks + fleet: + projectRef: + name: project-${uniqueId} + location: us-west1 + loggingConfig: + componentConfig: + enableComponents: + - SYSTEM_COMPONENTS + - WORKLOADS + monitoringConfig: + managedPrometheusConfig: + enabled: true + oidcConfig: + issuerUrl: https://oidc.eks.us-west-2.amazonaws.com/id/A115FE1C770C2452C75219524036FC0F + platformVersion: 1.28.0-gke.2 + projectRef: + external: ${projectId} + resourceID: kcc-attached-cluster-127 +status: + conditions: + - lastTransitionTime: "1970-01-01T00:00:00Z" + message: The resource is up to date + reason: UpToDate + status: "True" + type: Ready + observedGeneration: 2 diff --git a/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/_http.log b/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/_http.log new file mode 100644 index 0000000000..73b506b8a7 --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/_http.log @@ -0,0 +1,691 @@ +GET https://cloudresourcemanager.googleapis.com/v1/projects/${projectId}?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 + +{ + "createTime": "2024-04-01T12:34:56.123456Z", + "lifecycleState": "ACTIVE", + "projectId": "${projectId}", + "projectNumber": "${projectNumber}" +} + +--- + +GET https://cloudbilling.googleapis.com/v1/projects/${projectId}/billingInfo?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 + +{ + "billingAccountName": "", + "billingEnabled": false, + "name": "projects/${projectId}/billingInfo", + "projectId": "${projectId}" +} + +--- + +GET https://cloudresourcemanager.googleapis.com/v1/projects/${projectId}?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 + +{ + "createTime": "2024-04-01T12:34:56.123456Z", + "lifecycleState": "ACTIVE", + "projectId": "${projectId}", + "projectNumber": "${projectNumber}" +} + +--- + +PUT https://cloudresourcemanager.googleapis.com/v1/projects/${projectId}?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 + +{ + "createTime": "2024-04-01T12:34:56.123456Z", + "lifecycleState": "ACTIVE", + "name": "${projectId}", + "projectId": "${projectId}", + "projectNumber": "${projectNumber}" +} + +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 + +{ + "createTime": "2024-04-01T12:34:56.123456Z", + "lifecycleState": "ACTIVE", + "name": "projects/${projectId}", + "projectId": "${projectId}", + "projectNumber": "${projectNumber}" +} + +--- + +PUT https://cloudresourcemanager.googleapis.com/v1/projects/${projectId}?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 + +{ + "createTime": "2024-04-01T12:34:56.123456Z", + "lifecycleState": "ACTIVE", + "name": "projects/${projectId}", + "parent": { + "id": "123450001", + "type": "organization" + }, + "projectId": "${projectId}", + "projectNumber": "${projectNumber}" +} + +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 + +{ + "createTime": "2024-04-01T12:34:56.123456Z", + "lifecycleState": "ACTIVE", + "name": "projects/${projectId}", + "projectId": "${projectId}", + "projectNumber": "${projectNumber}" +} + +--- + +PUT https://cloudresourcemanager.googleapis.com/v1/projects/${projectId}?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 + +{ + "createTime": "2024-04-01T12:34:56.123456Z", + "labels": { + "cnrm-test": "true", + "managed-by-cnrm": "true" + }, + "lifecycleState": "ACTIVE", + "name": "projects/${projectId}", + "projectId": "${projectId}", + "projectNumber": "${projectNumber}" +} + +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 + +{ + "createTime": "2024-04-01T12:34:56.123456Z", + "labels": { + "cnrm-test": "true", + "managed-by-cnrm": "true" + }, + "lifecycleState": "ACTIVE", + "name": "projects/${projectId}", + "projectId": "${projectId}", + "projectNumber": "${projectNumber}" +} + +--- + +GET https://cloudresourcemanager.googleapis.com/v1/projects/${projectId}?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 + +{ + "createTime": "2024-04-01T12:34:56.123456Z", + "labels": { + "cnrm-test": "true", + "managed-by-cnrm": "true" + }, + "lifecycleState": "ACTIVE", + "name": "projects/${projectId}", + "projectId": "${projectId}", + "projectNumber": "${projectNumber}" +} + +--- + +GET https://cloudbilling.googleapis.com/v1/projects/${projectId}/billingInfo?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 + +{ + "billingAccountName": "", + "billingEnabled": false, + "name": "projects/${projectId}/billingInfo", + "projectId": "${projectId}" +} + +--- + +GET https://us-west1-gkemulticloud.googleapis.com/v1/projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127?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, + "message": "Resource 'projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127' was not found", + "status": "NOT_FOUND" + } +} + +--- + +POST https://us-west1-gkemulticloud.googleapis.com/v1/projects/${projectId}/locations/us-west1/attachedClusters?alt=json&attached_cluster_id=kcc-attached-cluster-127 +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +{ + "annotations": { + "key1": "value1", + "key2": "value2" + }, + "authorization": { + "admin_users": [ + { + "username": "user@company.com" + } + ] + }, + "binaryAuthorization": { + "evaluationMode": "PROJECT_SINGLETON_POLICY_ENFORCE" + }, + "description": "Test attached cluster", + "distribution": "eks", + "fleet": { + "project": "projects/${projectNumber}" + }, + "loggingConfig": { + "componentConfig": { + "enableComponents": [ + "SYSTEM_COMPONENTS" + ] + } + }, + "name": "kcc-attached-cluster-127", + "oidcConfig": { + "issuerUrl": "https://oidc.eks.us-west-2.amazonaws.com/id/A115FE1C770C2452C75219524036FC0F" + }, + "platformVersion": "1.27.0-gke.2" +} + +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 + +{ + "metadata": { + "@type": "type.googleapis.com/google.cloud.gkemulticloud.v1.OperationMetadata", + "createTime": "2024-04-01T12:34:56.123456Z", + "target": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", + "verb": "create" + }, + "name": "projects/${projectId}/locations/us-west1/operations/${operationID}" +} + +--- + +GET https://us-west1-gkemulticloud.googleapis.com/v1/projects/${projectId}/locations/us-west1/operations/${operationID}?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 + +{ + "done": true, + "metadata": { + "@type": "type.googleapis.com/google.cloud.gkemulticloud.v1.OperationMetadata", + "createTime": "2024-04-01T12:34:56.123456Z", + "endTime": "2024-04-01T12:34:56.123456Z", + "target": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", + "verb": "create" + }, + "name": "projects/${projectId}/locations/us-west1/operations/${operationID}", + "response": { + "@type": "type.googleapis.com/google.cloud.gkemulticloud.v1.AttachedCluster", + "annotations": { + "key1": "value1", + "key2": "value2" + }, + "authorization": { + "adminUsers": [ + { + "username": "user@company.com" + } + ] + }, + "binaryAuthorization": { + "evaluationMode": "PROJECT_SINGLETON_POLICY_ENFORCE" + }, + "description": "Test attached cluster", + "distribution": "eks", + "fleet": { + "project": "projects/${projectNumber}" + }, + "loggingConfig": { + "componentConfig": { + "enableComponents": [ + "SYSTEM_COMPONENTS" + ] + } + }, + "name": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", + "oidcConfig": { + "issuerUrl": "https://oidc.eks.us-west-2.amazonaws.com/id/A115FE1C770C2452C75219524036FC0F" + }, + "platformVersion": "1.27.0-gke.2", + "state": "RUNNING" + } +} + +--- + +GET https://us-west1-gkemulticloud.googleapis.com/v1/projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127?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 + +{ + "annotations": { + "key1": "value1", + "key2": "value2" + }, + "authorization": { + "adminUsers": [ + { + "username": "user@company.com" + } + ] + }, + "binaryAuthorization": { + "evaluationMode": "PROJECT_SINGLETON_POLICY_ENFORCE" + }, + "description": "Test attached cluster", + "distribution": "eks", + "fleet": { + "project": "projects/${projectNumber}" + }, + "loggingConfig": { + "componentConfig": { + "enableComponents": [ + "SYSTEM_COMPONENTS" + ] + } + }, + "name": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", + "oidcConfig": { + "issuerUrl": "https://oidc.eks.us-west-2.amazonaws.com/id/A115FE1C770C2452C75219524036FC0F" + }, + "platformVersion": "1.27.0-gke.2" +} + +--- + +PATCH https://us-west1-gkemulticloud.googleapis.com/v1/projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127?alt=json&updateMask=authorization.admin_users%2Clogging_config.component_config.enable_components%2Cmonitoring_config.managed_prometheus_config.enabled%2Cbinary_authorization.evaluation_mode%2Cdescription%2CplatformVersion%2Cannotations +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +{ + "annotations": { + "key1": "value1a", + "key2": "value2", + "key3": "value3" + }, + "authorization": { + "admin_users": [ + { + "username": "user1@company.com" + }, + { + "username": "user2@company.com" + } + ] + }, + "binaryAuthorization": { + "evaluationMode": "DISABLED" + }, + "description": "Test attached cluster update", + "fleet": { + "project": "projects/${projectNumber}" + }, + "loggingConfig": { + "componentConfig": { + "enableComponents": [ + "SYSTEM_COMPONENTS", + "WORKLOADS" + ] + } + }, + "monitoringConfig": { + "managedPrometheusConfig": { + "enabled": true + } + }, + "oidcConfig": { + "issuerUrl": "https://oidc.eks.us-west-2.amazonaws.com/id/A115FE1C770C2452C75219524036FC0F" + }, + "platformVersion": "1.28.0-gke.2" +} + +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 + +{ + "metadata": { + "@type": "type.googleapis.com/google.cloud.gkemulticloud.v1.OperationMetadata", + "createTime": "2024-04-01T12:34:56.123456Z", + "target": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", + "verb": "update" + }, + "name": "projects/${projectId}/locations/us-west1/operations/${operationID}" +} + +--- + +GET https://us-west1-gkemulticloud.googleapis.com/v1/projects/${projectId}/locations/us-west1/operations/${operationID}?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 + +{ + "done": true, + "metadata": { + "@type": "type.googleapis.com/google.cloud.gkemulticloud.v1.OperationMetadata", + "createTime": "2024-04-01T12:34:56.123456Z", + "endTime": "2024-04-01T12:34:56.123456Z", + "target": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", + "verb": "update" + }, + "name": "projects/${projectId}/locations/us-west1/operations/${operationID}", + "response": { + "@type": "type.googleapis.com/google.cloud.gkemulticloud.v1.AttachedCluster", + "annotations": { + "key1": "value1a", + "key2": "value2", + "key3": "value3" + }, + "authorization": { + "adminUsers": [ + { + "username": "user1@company.com" + }, + { + "username": "user2@company.com" + } + ] + }, + "binaryAuthorization": { + "evaluationMode": "DISABLED" + }, + "description": "Test attached cluster update", + "distribution": "eks", + "fleet": { + "project": "projects/${projectNumber}" + }, + "loggingConfig": { + "componentConfig": { + "enableComponents": [ + "SYSTEM_COMPONENTS", + "WORKLOADS" + ] + } + }, + "monitoringConfig": { + "managedPrometheusConfig": { + "enabled": true + } + }, + "name": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", + "oidcConfig": { + "issuerUrl": "https://oidc.eks.us-west-2.amazonaws.com/id/A115FE1C770C2452C75219524036FC0F" + }, + "platformVersion": "1.28.0-gke.2" + } +} + +--- + +GET https://us-west1-gkemulticloud.googleapis.com/v1/projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127?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 + +{ + "annotations": { + "key1": "value1a", + "key2": "value2", + "key3": "value3" + }, + "authorization": { + "adminUsers": [ + { + "username": "user1@company.com" + }, + { + "username": "user2@company.com" + } + ] + }, + "binaryAuthorization": { + "evaluationMode": "DISABLED" + }, + "description": "Test attached cluster update", + "distribution": "eks", + "fleet": { + "project": "projects/${projectNumber}" + }, + "loggingConfig": { + "componentConfig": { + "enableComponents": [ + "SYSTEM_COMPONENTS", + "WORKLOADS" + ] + } + }, + "monitoringConfig": { + "managedPrometheusConfig": { + "enabled": true + } + }, + "name": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", + "oidcConfig": { + "issuerUrl": "https://oidc.eks.us-west-2.amazonaws.com/id/A115FE1C770C2452C75219524036FC0F" + }, + "platformVersion": "1.28.0-gke.2" +} + +--- + +DELETE https://us-west1-gkemulticloud.googleapis.com/v1/projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127?alt=json&ignore_errors=true +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 + +{ + "metadata": { + "@type": "type.googleapis.com/google.cloud.gkemulticloud.v1.OperationMetadata", + "createTime": "2024-04-01T12:34:56.123456Z", + "target": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", + "verb": "delete" + }, + "name": "projects/${projectId}/locations/us-west1/operations/${operationID}" +} + +--- + +GET https://us-west1-gkemulticloud.googleapis.com/v1/projects/${projectId}/locations/us-west1/operations/${operationID}?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 + +{ + "done": true, + "metadata": { + "@type": "type.googleapis.com/google.cloud.gkemulticloud.v1.OperationMetadata", + "createTime": "2024-04-01T12:34:56.123456Z", + "endTime": "2024-04-01T12:34:56.123456Z", + "target": "projects/${projectId}/locations/us-west1/attachedClusters/kcc-attached-cluster-127", + "verb": "delete" + }, + "name": "projects/${projectId}/locations/us-west1/operations/${operationID}", + "response": { + "@type": "type.googleapis.com/google.protobuf.Empty" + } +} \ No newline at end of file diff --git a/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/create.yaml b/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/create.yaml new file mode 100644 index 0000000000..0d169198cb --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/create.yaml @@ -0,0 +1,46 @@ +# Copyright 2023 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: containerattached.cnrm.cloud.google.com/v1beta1 +kind: ContainerAttachedCluster +metadata: + name: containerattachedcluster-${uniqueId} +spec: + # The resourceID needs to match the name of the eks cluster to be attached + resourceID: kcc-attached-cluster-127 + annotations: + key1: "value1" + key2: "value2" + authorization: + adminUsers: ["user@company.com"] + binaryAuthorization: + evaluationMode: "PROJECT_SINGLETON_POLICY_ENFORCE" + location: us-west1 + projectRef: + external: ${KCC_ATTACHED_CLUSTER_TEST_PROJECT} + description: "Test attached cluster" + distribution: "eks" + oidcConfig: + issuerUrl: https://oidc.eks.us-west-2.amazonaws.com/id/A115FE1C770C2452C75219524036FC0F + platformVersion: 1.27.0-gke.2 + fleet: + projectRef: + name: project-${uniqueId} + loggingConfig: + componentConfig: + enableComponents: ["SYSTEM_COMPONENTS"] + monitoringConfig: + managedPrometheusConfig: + enabled: false + deletionPolicy: "DELETE_IGNORE_ERRORS" \ No newline at end of file diff --git a/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/dependencies.yaml b/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/dependencies.yaml new file mode 100644 index 0000000000..c71925074f --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/dependencies.yaml @@ -0,0 +1,25 @@ +# Copyright 2023 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: resourcemanager.cnrm.cloud.google.com/v1beta1 +kind: Project +metadata: + name: project-${uniqueId} + annotations: + cnrm.cloud.google.com/deletion-policy: abandon +spec: + resourceID: ${KCC_ATTACHED_CLUSTER_TEST_PROJECT} + organizationRef: + external: ${TEST_ORG_ID} + name: ${KCC_ATTACHED_CLUSTER_TEST_PROJECT} \ No newline at end of file diff --git a/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/update.yaml b/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/update.yaml new file mode 100644 index 0000000000..3ffa8aece9 --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/containerattached/v1beta1/containerattachedclusterfull/update.yaml @@ -0,0 +1,47 @@ +# Copyright 2023 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: containerattached.cnrm.cloud.google.com/v1beta1 +kind: ContainerAttachedCluster +metadata: + name: containerattachedcluster-${uniqueId} +spec: + # The resourceID needs to match the name of the eks cluster to be attached + resourceID: kcc-attached-cluster-127 + annotations: + key1: "value1a" + key2: "value2" + key3: "value3" + authorization: + adminUsers: ["user1@company.com", "user2@company.com"] + binaryAuthorization: + evaluationMode: "DISABLED" + location: us-west1 + projectRef: + external: ${KCC_ATTACHED_CLUSTER_TEST_PROJECT} + description: "Test attached cluster update" + distribution: "eks" + oidcConfig: + issuerUrl: https://oidc.eks.us-west-2.amazonaws.com/id/A115FE1C770C2452C75219524036FC0F + platformVersion: 1.28.0-gke.2 + fleet: + projectRef: + name: project-${uniqueId} + loggingConfig: + componentConfig: + enableComponents: ["SYSTEM_COMPONENTS", "WORKLOADS"] + monitoringConfig: + managedPrometheusConfig: + enabled: true + deletionPolicy: "DELETE_IGNORE_ERRORS" \ No newline at end of file