diff --git a/apis/compute/v1beta1/targettcpproxy_reference.go b/apis/compute/v1beta1/targettcpproxy_reference.go index 42f9a522a4..1e28b254fd 100644 --- a/apis/compute/v1beta1/targettcpproxy_reference.go +++ b/apis/compute/v1beta1/targettcpproxy_reference.go @@ -19,6 +19,8 @@ import ( "fmt" "strings" + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct" + refsv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/apis/refs/v1beta1" "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/k8s" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -33,7 +35,8 @@ var _ refsv1beta1.ExternalNormalizer = &ComputeTargetTCPProxyRef{} // holds the GCP identifier for the KRM object. type ComputeTargetTCPProxyRef struct { // A reference to an externally managed ComputeTargetTCPProxy resource. - // Should be in the format "projects//regions//targetTcpProxies/". + // Should be in the format "projects//global/targetTcpProxies/" + // or "projects//regions//targetTcpProxies/". External string `json:"external,omitempty"` // The name of a ComputeTargetTCPProxy resource. @@ -95,7 +98,13 @@ func NewComputeTargetTCPProxyRef(ctx context.Context, reader client.Reader, obj return nil, fmt.Errorf("cannot resolve project") } - id.parent = &ComputeTargetTCPProxyParent{ProjectID: projectID} + // Get Region + if obj.Spec.Location == nil { + id.parent = &ComputeTargetTCPProxyParent{ProjectID: projectID, Region: "global"} + } else { + region := direct.ValueOf(obj.Spec.Location) + id.parent = &ComputeTargetTCPProxyParent{ProjectID: projectID, Region: region} + } // Get desired ID resourceID := valueOf(obj.Spec.ResourceID) @@ -127,7 +136,6 @@ func NewComputeTargetTCPProxyRef(ctx context.Context, reader client.Reader, obj resourceID, actualResourceID) } id.External = externalRef - id.parent = &ComputeTargetTCPProxyParent{ProjectID: projectID} return id, nil } @@ -147,19 +155,15 @@ func (r *ComputeTargetTCPProxyRef) Parent() (*ComputeTargetTCPProxyParent, error type ComputeTargetTCPProxyParent struct { ProjectID string -} - -type RegionalComputeTargetTCPProxyParent struct { - ProjectID string Region string } func (p *ComputeTargetTCPProxyParent) String() string { - return "projects/" + p.ProjectID + "/global" -} - -func (p *RegionalComputeTargetTCPProxyParent) String() string { - return "projects/" + p.ProjectID + "/regions/" + p.Region + if p.Region == "global" { + return "projects/" + p.ProjectID + "/global" + } else { + return "projects/" + p.ProjectID + "/regions/" + p.Region + } } func asComputeTargetTCPProxyExternal(parent *ComputeTargetTCPProxyParent, resourceID string) (external string) { @@ -169,28 +173,22 @@ func asComputeTargetTCPProxyExternal(parent *ComputeTargetTCPProxyParent, resour func parseComputeTargetTCPProxyExternal(external string) (parent *ComputeTargetTCPProxyParent, resourceID string, err error) { external = strings.TrimPrefix(external, "/") tokens := strings.Split(external, "/") - if len(tokens) != 5 || tokens[0] != "projects" || tokens[3] != "targetTcpProxies" { - return nil, "", fmt.Errorf("format of ComputeTargetTCPProxy external=%q was not known (use projects//global/targetTcpProxies/)", external) - } - parent = &ComputeTargetTCPProxyParent{ - ProjectID: tokens[1], + if len(tokens) == 5 && tokens[0] == "projects" && tokens[3] == "targetTcpProxies" { + parent = &ComputeTargetTCPProxyParent{ + ProjectID: tokens[1], + } + resourceID = tokens[4] + return parent, resourceID, nil + } else if len(tokens) == 6 && tokens[0] == "projects" && tokens[2] == "regions" && tokens[4] == "targetTcpProxies" { + parent = &ComputeTargetTCPProxyParent{ + ProjectID: tokens[1], + Region: tokens[3], + } + resourceID = tokens[5] + return parent, resourceID, nil } - resourceID = tokens[4] - return parent, resourceID, nil -} + return nil, "", fmt.Errorf("ExternalRef format invalid: %s", external) -func parseRegionalComputeTargetTCPProxyExternal(external string) (parent *RegionalComputeTargetTCPProxyParent, resourceID string, err error) { - external = strings.TrimPrefix(external, "/") - tokens := strings.Split(external, "/") - if len(tokens) != 6 || tokens[0] != "projects" || tokens[2] != "regions" || tokens[4] != "targetTcpProxies" { - return nil, "", fmt.Errorf("format of ComputeTargetTCPProxy external=%q was not known (use projects//regions//targetTcpProxies/)", external) - } - parent = &RegionalComputeTargetTCPProxyParent{ - ProjectID: tokens[1], - Region: tokens[3], - } - resourceID = tokens[5] - return parent, resourceID, nil } func valueOf[T any](t *T) T { diff --git a/apis/compute/v1beta1/zz_generated.deepcopy.go b/apis/compute/v1beta1/zz_generated.deepcopy.go index 6b066735c6..ca24003cfc 100644 --- a/apis/compute/v1beta1/zz_generated.deepcopy.go +++ b/apis/compute/v1beta1/zz_generated.deepcopy.go @@ -875,18 +875,3 @@ func (in *ForwardingruleTarget) DeepCopy() *ForwardingruleTarget { in.DeepCopyInto(out) return out } - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RegionalComputeTargetTCPProxyParent) DeepCopyInto(out *RegionalComputeTargetTCPProxyParent) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RegionalComputeTargetTCPProxyParent. -func (in *RegionalComputeTargetTCPProxyParent) DeepCopy() *RegionalComputeTargetTCPProxyParent { - if in == nil { - return nil - } - out := new(RegionalComputeTargetTCPProxyParent) - in.DeepCopyInto(out) - return out -} diff --git a/mockgcp/mockcompute/regionaltargettcpproxyv1.go b/mockgcp/mockcompute/regionaltargettcpproxyv1.go new file mode 100644 index 0000000000..f7b03da014 --- /dev/null +++ b/mockgcp/mockcompute/regionaltargettcpproxyv1.go @@ -0,0 +1,138 @@ +// 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. + +package mockcompute + +import ( + "context" + "strings" + + "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/common/projects" + pb "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/generated/mockgcp/cloud/compute/v1" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +type RegionalTargetTcpProxyV1 struct { + *MockService + pb.UnimplementedRegionTargetTcpProxiesServer +} + +func (s *RegionalTargetTcpProxyV1) Get(ctx context.Context, req *pb.GetRegionTargetTcpProxyRequest) (*pb.TargetTcpProxy, error) { + reqName := "projects/" + req.GetProject() + "/regions/" + req.GetRegion() + "/targetTcpProxies/" + req.GetTargetTcpProxy() + name, err := s.parseRegionalTargetTcpProxyName(reqName) + if err != nil { + return nil, err + } + + fqn := name.String() + + obj := &pb.TargetTcpProxy{} + if err := s.storage.Get(ctx, fqn, obj); err != nil { + return nil, status.Errorf(codes.NotFound, "The resource '%s' was not found", fqn) + } + + return obj, nil +} + +func (s *RegionalTargetTcpProxyV1) Insert(ctx context.Context, req *pb.InsertRegionTargetTcpProxyRequest) (*pb.Operation, error) { + reqName := "projects/" + req.GetProject() + "/regions/" + req.GetRegion() + "/targetTcpProxies/" + req.GetTargetTcpProxyResource().GetName() + name, err := s.parseRegionalTargetTcpProxyName(reqName) + if err != nil { + return nil, err + } + + fqn := name.String() + + id := s.generateID() + + obj := proto.Clone(req.GetTargetTcpProxyResource()).(*pb.TargetTcpProxy) + obj.SelfLink = PtrTo("https://www.googleapis.com/compute/v1/" + name.String()) + obj.CreationTimestamp = PtrTo(s.nowString()) + obj.Id = &id + obj.Kind = PtrTo("compute#targetTcpProxy") + obj.Region = PtrTo("https://www.googleapis.com/compute/v1/projects/${projectId}/regions/" + req.GetRegion()) + + if err := s.storage.Create(ctx, fqn, obj); err != nil { + return nil, err + } + + op := &pb.Operation{ + TargetId: obj.Id, + TargetLink: obj.SelfLink, + OperationType: PtrTo("insert"), + User: PtrTo("user@example.com"), + } + return s.startRegionalLRO(ctx, name.Project.ID, name.Region, op, func() (proto.Message, error) { + return obj, nil + }) +} + +func (s *RegionalTargetTcpProxyV1) Delete(ctx context.Context, req *pb.DeleteRegionTargetTcpProxyRequest) (*pb.Operation, error) { + reqName := "projects/" + req.GetProject() + "/regions/" + req.GetRegion() + "/targetTcpProxies/" + req.GetTargetTcpProxy() + name, err := s.parseRegionalTargetTcpProxyName(reqName) + if err != nil { + return nil, err + } + + fqn := name.String() + + deleted := &pb.TargetTcpProxy{} + if err := s.storage.Delete(ctx, fqn, deleted); err != nil { + return nil, err + } + + op := &pb.Operation{ + TargetId: deleted.Id, + TargetLink: deleted.SelfLink, + OperationType: PtrTo("delete"), + User: PtrTo("user@example.com"), + } + return s.startRegionalLRO(ctx, name.Project.ID, name.Region, op, func() (proto.Message, error) { + return deleted, nil + }) +} + +type regionalTargetTcpProxyName struct { + Project *projects.ProjectData + Region string + Name string +} + +func (n *regionalTargetTcpProxyName) String() string { + return "projects/" + n.Project.ID + "/regions/" + n.Region + "/targetTcpProxies/" + n.Name +} + +// parseRegionalTargetTcpProxyName parses a string into a targetTcpProxyName. +// The expected form is `projects/*/regions/*/targetTcpProxies/*`. +func (s *MockService) parseRegionalTargetTcpProxyName(name string) (*regionalTargetTcpProxyName, error) { + tokens := strings.Split(name, "/") + + if len(tokens) == 6 && tokens[0] == "projects" && tokens[2] == "regions" && tokens[4] == "targetTcpProxies" { + project, err := s.Projects.GetProjectByID(tokens[1]) + if err != nil { + return nil, err + } + name := ®ionalTargetTcpProxyName{ + Project: project, + Region: tokens[3], + Name: tokens[5], + } + + return name, nil + } else { + return nil, status.Errorf(codes.InvalidArgument, "name %q is not valid", name) + } +} diff --git a/mockgcp/mockcompute/service.go b/mockgcp/mockcompute/service.go index 083577f79b..bde2e8d14e 100644 --- a/mockgcp/mockcompute/service.go +++ b/mockgcp/mockcompute/service.go @@ -88,6 +88,7 @@ func (s *MockService) Register(grpcServer *grpc.Server) { pb.RegisterRegionSslCertificatesServer(grpcServer, &RegionalSSLCertificatesV1{MockService: s}) pb.RegisterTargetSslProxiesServer(grpcServer, &TargetSslProxyV1{MockService: s}) pb.RegisterTargetTcpProxiesServer(grpcServer, &GlobalTargetTcpProxyV1{MockService: s}) + pb.RegisterRegionTargetTcpProxiesServer(grpcServer, &RegionalTargetTcpProxyV1{MockService: s}) pb.RegisterServiceAttachmentsServer(grpcServer, &RegionalServiceAttachmentV1{MockService: s}) diff --git a/pkg/controller/direct/compute/targettcpproxy/targettcpproxy_controller.go b/pkg/controller/direct/compute/targettcpproxy/targettcpproxy_controller.go index 2de289414f..ab5ef08d9e 100644 --- a/pkg/controller/direct/compute/targettcpproxy/targettcpproxy_controller.go +++ b/pkg/controller/direct/compute/targettcpproxy/targettcpproxy_controller.go @@ -53,11 +53,12 @@ type targetTCPProxyModel struct { var _ directbase.Model = &targetTCPProxyModel{} type targetTCPProxyAdapter struct { - id *krm.ComputeTargetTCPProxyRef - targetTcpProxiesClient *gcp.TargetTcpProxiesClient - desired *krm.ComputeTargetTCPProxy - actual *computepb.TargetTcpProxy - reader client.Reader + id *krm.ComputeTargetTCPProxyRef + targetTcpProxiesClient *gcp.TargetTcpProxiesClient + regionalTargetTcpProxiesClient *gcp.RegionTargetTcpProxiesClient + desired *krm.ComputeTargetTCPProxy + actual *computepb.TargetTcpProxy + reader client.Reader } var _ directbase.Adapter = &targetTCPProxyAdapter{} @@ -75,15 +76,25 @@ func (m *targetTCPProxyModel) client(ctx context.Context) (*gcp.TargetTcpProxies return gcpClient, err } +func (m *targetTCPProxyModel) regionalClient(ctx context.Context) (*gcp.RegionTargetTcpProxiesClient, error) { + var opts []option.ClientOption + opts, err := m.config.RESTClientOptions() + if err != nil { + return nil, err + } + gcpClient, err := gcp.NewRegionTargetTcpProxiesRESTClient(ctx, opts...) + if err != nil { + return nil, fmt.Errorf("building TargetTcpProxy client: %w", err) + } + return gcpClient, err +} + func (m *targetTCPProxyModel) AdapterForObject(ctx context.Context, reader client.Reader, u *unstructured.Unstructured) (directbase.Adapter, error) { obj := &krm.ComputeTargetTCPProxy{} if err := runtime.DefaultUnstructuredConverter.FromUnstructured(u.Object, &obj); err != nil { return nil, fmt.Errorf("error converting to %T: %w", obj, err) } - // Set label managed-by-cnrm: true - obj.ObjectMeta.Labels["managed-by-cnrm"] = "true" - computeTargetTCPProxyRef, err := krm.NewComputeTargetTCPProxyRef(ctx, reader, obj, u) if err != nil { return nil, err @@ -95,13 +106,27 @@ func (m *targetTCPProxyModel) AdapterForObject(ctx context.Context, reader clien reader: reader, } - // Get GCP client - gcpClient, err := m.client(ctx) + // Get location + parent, err := computeTargetTCPProxyRef.Parent() if err != nil { - return nil, fmt.Errorf("building gcp client: %w", err) + return nil, fmt.Errorf("get ComputeTargetTCPProxyAdapter parent %s: %w", computeTargetTCPProxyRef.External, err) } - targetTCPProxyAdapter.targetTcpProxiesClient = gcpClient + location := parent.Region + // Get GCP client + if location == "global" { + gcpClient, err := m.client(ctx) + if err != nil { + return nil, fmt.Errorf("building gcp client: %w", err) + } + targetTCPProxyAdapter.targetTcpProxiesClient = gcpClient + } else { + gcpClient, err := m.regionalClient(ctx) + if err != nil { + return nil, fmt.Errorf("building gcp client: %w", err) + } + targetTCPProxyAdapter.regionalTargetTcpProxiesClient = gcpClient + } return targetTCPProxyAdapter, nil } @@ -111,7 +136,7 @@ func (m *targetTCPProxyModel) AdapterForURL(ctx context.Context, url string) (di } func (a *targetTCPProxyAdapter) Find(ctx context.Context) (bool, error) { - log := klog.FromContext(ctx).WithName(ctrlName) + log := klog.FromContext(ctx) log.V(2).Info("getting ComputeTargetTCPProxy", "name", a.id.External) targetTCPProxy, err := a.get(ctx) @@ -133,7 +158,7 @@ func (a *targetTCPProxyAdapter) Create(ctx context.Context, createOp *directbase return err } - log := klog.FromContext(ctx).WithName(ctrlName) + log := klog.FromContext(ctx) log.V(2).Info("creating ComputeTargetTCPProxy", "name", a.id.External) mapCtx := &direct.MapContext{} @@ -148,15 +173,26 @@ func (a *targetTCPProxyAdapter) Create(ctx context.Context, createOp *directbase if err != nil { return fmt.Errorf("get ComputeTargetTCPProxy parent %s: %w", a.id.External, err) } + region := parent.Region tokens := strings.Split(a.id.External, "/") targetTCPProxy.Name = direct.LazyPtr(tokens[len(tokens)-1]) - req := &computepb.InsertTargetTcpProxyRequest{ - Project: parent.ProjectID, - TargetTcpProxyResource: targetTCPProxy, + op := &gcp.Operation{} + if region == "global" { + req := &computepb.InsertTargetTcpProxyRequest{ + Project: parent.ProjectID, + TargetTcpProxyResource: targetTCPProxy, + } + op, err = a.targetTcpProxiesClient.Insert(ctx, req) + } else { + req := &computepb.InsertRegionTargetTcpProxyRequest{ + Project: parent.ProjectID, + Region: region, + TargetTcpProxyResource: targetTCPProxy, + } + op, err = a.regionalTargetTcpProxiesClient.Insert(ctx, req) } - op, err := a.targetTcpProxiesClient.Insert(ctx, req) if err != nil { return fmt.Errorf("creating ComputeTargetTCPProxy %s: %w", a.id.External, err) @@ -214,10 +250,13 @@ func (a *targetTCPProxyAdapter) Update(ctx context.Context, updateOp *directbase if err != nil { return fmt.Errorf("get ComputeTargetTCPProxy parent %s: %w", a.id.External, err) } + region := parent.Region + tokens := strings.Split(a.id.External, "/") targetTCPProxy.Name = direct.LazyPtr(tokens[len(tokens)-1]) - if !reflect.DeepEqual(targetTCPProxy.Service, a.actual.Service) { + // Regional API does not support Update + if !reflect.DeepEqual(targetTCPProxy.Service, a.actual.Service) && region == "global" { setBackendServiceReq := &computepb.SetBackendServiceTargetTcpProxyRequest{ Project: parent.ProjectID, TargetTcpProxiesSetBackendServiceRequestResource: &computepb.TargetTcpProxiesSetBackendServiceRequest{Service: targetTCPProxy.Service}, @@ -228,7 +267,7 @@ func (a *targetTCPProxyAdapter) Update(ctx context.Context, updateOp *directbase return fmt.Errorf("updating ComputeTargetTCPProxy backend service %s: %w", a.id.External, err) } } - if !reflect.DeepEqual(targetTCPProxy.ProxyHeader, a.actual.ProxyHeader) { + if !reflect.DeepEqual(targetTCPProxy.ProxyHeader, a.actual.ProxyHeader) && region == "global" { setProxyHeaderReq := &computepb.SetProxyHeaderTargetTcpProxyRequest{ Project: parent.ProjectID, TargetTcpProxiesSetProxyHeaderRequestResource: &computepb.TargetTcpProxiesSetProxyHeaderRequest{ProxyHeader: targetTCPProxy.ProxyHeader}, @@ -285,21 +324,31 @@ func (a *targetTCPProxyAdapter) Export(ctx context.Context) (*unstructured.Unstr // Delete implements the Adapter interface. func (a *targetTCPProxyAdapter) Delete(ctx context.Context, deleteOp *directbase.DeleteOperation) (bool, error) { - log := klog.FromContext(ctx).WithName(ctrlName) + log := klog.FromContext(ctx) log.V(2).Info("deleting ComputeTargetTcpProxy", "name", a.id.External) parent, err := a.id.Parent() if err != nil { return false, fmt.Errorf("get ComputeTargetTcpProxy parent %s: %w", a.id.External, err) } + region := parent.Region + op := &gcp.Operation{} tokens := strings.Split(a.id.External, "/") - - delReq := &computepb.DeleteTargetTcpProxyRequest{ - Project: parent.ProjectID, - TargetTcpProxy: tokens[len(tokens)-1], + if region == "global" { + delReq := &computepb.DeleteTargetTcpProxyRequest{ + Project: parent.ProjectID, + TargetTcpProxy: tokens[len(tokens)-1], + } + op, err = a.targetTcpProxiesClient.Delete(ctx, delReq) + } else { + delReq := &computepb.DeleteRegionTargetTcpProxyRequest{ + Project: parent.ProjectID, + Region: region, + TargetTcpProxy: tokens[len(tokens)-1], + } + op, err = a.regionalTargetTcpProxiesClient.Delete(ctx, delReq) } - op, err := a.targetTcpProxiesClient.Delete(ctx, delReq) if err != nil { return false, fmt.Errorf("deleting ComputeTargetTcpProxy %s: %w", a.id.External, err) @@ -319,12 +368,21 @@ func (a *targetTCPProxyAdapter) get(ctx context.Context) (*computepb.TargetTcpPr if err != nil { return nil, fmt.Errorf("get ComputeTargetTcpProxy parent %s: %w", a.id.External, err) } + region := parent.Region tokens := strings.Split(a.id.External, "/") - - getReq := &computepb.GetTargetTcpProxyRequest{ - Project: parent.ProjectID, - TargetTcpProxy: tokens[len(tokens)-1], + if region == "global" { + getReq := &computepb.GetTargetTcpProxyRequest{ + Project: parent.ProjectID, + TargetTcpProxy: tokens[len(tokens)-1], + } + return a.targetTcpProxiesClient.Get(ctx, getReq) + } else { + getReq := &computepb.GetRegionTargetTcpProxyRequest{ + Project: parent.ProjectID, + Region: region, + TargetTcpProxy: tokens[len(tokens)-1], + } + return a.regionalTargetTcpProxiesClient.Get(ctx, getReq) } - return a.targetTcpProxiesClient.Get(ctx, getReq) } diff --git a/pkg/test/resourcefixture/contexts/compute_context.go b/pkg/test/resourcefixture/contexts/compute_context.go index 49b5be197b..4007a22e9b 100644 --- a/pkg/test/resourcefixture/contexts/compute_context.go +++ b/pkg/test/resourcefixture/contexts/compute_context.go @@ -189,6 +189,11 @@ func init() { SkipUpdate: true, } + resourceContextMap["regionalcomputetargettcpproxy"] = ResourceContext{ + ResourceKind: "ComputeTargetTCPProxy", + SkipUpdate: true, // API does not support UPDATE/PATCH. + } + resourceContextMap["computetargettcpproxy"] = ResourceContext{ ResourceKind: "ComputeTargetTCPProxy", } diff --git a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic-direct/create.yaml b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic-direct/create.yaml index 4fa897d040..a0a6cfca7b 100644 --- a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic-direct/create.yaml +++ b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic-direct/create.yaml @@ -1,4 +1,4 @@ -# Copyright 2022 Google LLC +# 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. diff --git a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic-direct/dependencies.yaml b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic-direct/dependencies.yaml index 41e379a2fe..479fc938a0 100644 --- a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic-direct/dependencies.yaml +++ b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic-direct/dependencies.yaml @@ -1,4 +1,4 @@ -# Copyright 2022 Google LLC +# 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. @@ -32,4 +32,3 @@ spec: name: computehealthcheck-${uniqueId} location: global protocol: TCP - diff --git a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic-direct/update.yaml b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic-direct/update.yaml index 4fa897d040..a0a6cfca7b 100644 --- a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic-direct/update.yaml +++ b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic-direct/update.yaml @@ -1,4 +1,4 @@ -# Copyright 2022 Google LLC +# 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. diff --git a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic/_generated_object_globalcomputetargettcpproxy-basic.golden.yaml b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic/_generated_object_globalcomputetargettcpproxy-basic.golden.yaml index 86e2070b44..0666f344ce 100644 --- a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic/_generated_object_globalcomputetargettcpproxy-basic.golden.yaml +++ b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic/_generated_object_globalcomputetargettcpproxy-basic.golden.yaml @@ -2,13 +2,13 @@ apiVersion: compute.cnrm.cloud.google.com/v1beta1 kind: ComputeTargetTCPProxy metadata: annotations: + alpha.cnrm.cloud.google.com/reconciler: direct cnrm.cloud.google.com/management-conflict-prevention-policy: none cnrm.cloud.google.com/project-id: ${projectId} - cnrm.cloud.google.com/state-into-spec: absent finalizers: - cnrm.cloud.google.com/finalizer - cnrm.cloud.google.com/deletion-defender - generation: 2 + generation: 1 labels: cnrm-test: "true" name: computetargettcpproxy-${uniqueId} @@ -16,7 +16,6 @@ metadata: spec: backendServiceRef: name: computebackendservice-${uniqueId} - resourceID: computetargettcpproxy-${uniqueId} status: conditions: - lastTransitionTime: "1970-01-01T00:00:00Z" @@ -25,6 +24,7 @@ status: status: "True" type: Ready creationTimestamp: "1970-01-01T00:00:00Z" - observedGeneration: 2 + externalRef: projects/${projectId}/global/targetTcpProxies/computetargettcpproxy-${uniqueId} + observedGeneration: 1 proxyId: 1111111111111111 selfLink: https://www.googleapis.com/compute/v1/projects/${projectId}/global/targetTcpProxies/computetargettcpproxy-${uniqueId} diff --git a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic/_http.log b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic/_http.log index dcb387066d..13129433c9 100644 --- a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic/_http.log +++ b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic/_http.log @@ -218,9 +218,10 @@ X-Xss-Protection: 0 --- -GET https://compute.googleapis.com/compute/v1/projects/${projectId}/global/targetTcpProxies/${targetTcpProxyID}?alt=json +GET https://compute.googleapis.com/compute/v1/projects/${projectId}/global/targetTcpProxies/${targetTcpProxyID} Content-Type: application/json -User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager +User-Agent: kcc/controller-manager +x-goog-request-params: project=${projectId}&target_tcp_proxy=computetargettcpproxy-${uniqueId} 404 Not Found Cache-Control: private @@ -249,14 +250,14 @@ X-Xss-Protection: 0 --- -POST https://compute.googleapis.com/compute/v1/projects/${projectId}/global/targetTcpProxies?alt=json +POST https://compute.googleapis.com/compute/v1/projects/${projectId}/global/targetTcpProxies Content-Type: application/json -User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager +User-Agent: kcc/controller-manager +x-goog-request-params: project=${projectId} { "name": "computetargettcpproxy-${uniqueId}", - "proxyHeader": "NONE", - "service": "projects/${projectId}/global/backendServices/computebackendservice-${uniqueId}" + "service": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/backendServices/computebackendservice-${uniqueId}" } 200 OK @@ -287,8 +288,10 @@ X-Xss-Protection: 0 --- -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 +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 @@ -319,9 +322,10 @@ X-Xss-Protection: 0 --- -GET https://compute.googleapis.com/compute/v1/projects/${projectId}/global/targetTcpProxies/${targetTcpProxyID}?alt=json +GET https://compute.googleapis.com/compute/v1/projects/${projectId}/global/targetTcpProxies/${targetTcpProxyID} Content-Type: application/json -User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager +User-Agent: kcc/controller-manager +x-goog-request-params: project=${projectId}&target_tcp_proxy=computetargettcpproxy-${uniqueId} 200 OK Cache-Control: private @@ -341,14 +345,15 @@ X-Xss-Protection: 0 "name": "computetargettcpproxy-${uniqueId}", "proxyHeader": "NONE", "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/targetTcpProxies/computetargettcpproxy-${uniqueId}", - "service": "projects/${projectId}/global/backendServices/computebackendservice-${uniqueId}" + "service": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/backendServices/computebackendservice-${uniqueId}" } --- -DELETE https://compute.googleapis.com/compute/v1/projects/${projectId}/global/targetTcpProxies/${targetTcpProxyID}?alt=json +DELETE https://compute.googleapis.com/compute/v1/projects/${projectId}/global/targetTcpProxies/${targetTcpProxyID} Content-Type: application/json -User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager +User-Agent: kcc/controller-manager +x-goog-request-params: project=${projectId}&target_tcp_proxy=computetargettcpproxy-${uniqueId} 200 OK Cache-Control: private @@ -378,8 +383,10 @@ X-Xss-Protection: 0 --- -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 +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 diff --git a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic/dependencies.yaml b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic/dependencies.yaml index 41e379a2fe..fdc8db7396 100644 --- a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic/dependencies.yaml +++ b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-basic/dependencies.yaml @@ -32,4 +32,3 @@ spec: name: computehealthcheck-${uniqueId} location: global protocol: TCP - diff --git a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-full-direct/create.yaml b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-full-direct/create.yaml index 502a07ed29..ac752438cd 100644 --- a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-full-direct/create.yaml +++ b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-full-direct/create.yaml @@ -1,4 +1,4 @@ -# Copyright 2022 Google LLC +# 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. diff --git a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-full-direct/dependencies.yaml b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-full-direct/dependencies.yaml index 41e379a2fe..479fc938a0 100644 --- a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-full-direct/dependencies.yaml +++ b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-full-direct/dependencies.yaml @@ -1,4 +1,4 @@ -# Copyright 2022 Google LLC +# 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. @@ -32,4 +32,3 @@ spec: name: computehealthcheck-${uniqueId} location: global protocol: TCP - diff --git a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-full-direct/update.yaml b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-full-direct/update.yaml index 34f627e368..a55980feac 100644 --- a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-full-direct/update.yaml +++ b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/globalcomputetargettcpproxy-full-direct/update.yaml @@ -1,4 +1,4 @@ -# Copyright 2022 Google LLC +# 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. diff --git a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/regionalcomputetargettcpproxy-direct/_generated_object_regionalcomputetargettcpproxy-direct.golden.yaml b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/regionalcomputetargettcpproxy-direct/_generated_object_regionalcomputetargettcpproxy-direct.golden.yaml new file mode 100644 index 0000000000..3aebc9be5f --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/regionalcomputetargettcpproxy-direct/_generated_object_regionalcomputetargettcpproxy-direct.golden.yaml @@ -0,0 +1,34 @@ +apiVersion: compute.cnrm.cloud.google.com/v1beta1 +kind: ComputeTargetTCPProxy +metadata: + annotations: + alpha.cnrm.cloud.google.com/reconciler: direct + cnrm.cloud.google.com/management-conflict-prevention-policy: none + cnrm.cloud.google.com/project-id: ${projectId} + finalizers: + - cnrm.cloud.google.com/finalizer + - cnrm.cloud.google.com/deletion-defender + generation: 1 + labels: + cnrm-test: "true" + name: computetargettcpproxy-${uniqueId} + namespace: ${uniqueId} +spec: + backendServiceRef: + name: computebackendservice-${uniqueId} + description: test target tcp proxy + location: europe-west4 + proxyBind: false + proxyHeader: NONE +status: + conditions: + - lastTransitionTime: "1970-01-01T00:00:00Z" + message: The resource is up to date + reason: UpToDate + status: "True" + type: Ready + creationTimestamp: "1970-01-01T00:00:00Z" + externalRef: projects/${projectId}/regions/europe-west4/targetTcpProxies/computetargettcpproxy-${uniqueId} + observedGeneration: 1 + proxyId: 1111111111111111 + selfLink: https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/targetTcpProxies/computetargettcpproxy-${uniqueId} diff --git a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/regionalcomputetargettcpproxy-direct/_http.log b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/regionalcomputetargettcpproxy-direct/_http.log new file mode 100644 index 0000000000..1c70b18a1d --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/regionalcomputetargettcpproxy-direct/_http.log @@ -0,0 +1,561 @@ +GET https://compute.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/healthChecks/computehealthcheck-${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": "healthCheck \"projects/${projectId}/regions/europe-west4/healthChecks/computehealthcheck-${uniqueId}\" not found", + "reason": "notFound" + } + ], + "message": "healthCheck \"projects/${projectId}/regions/europe-west4/healthChecks/computehealthcheck-${uniqueId}\" not found" + } +} + +--- + +POST https://compute.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/healthChecks?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 + +{ + "checkIntervalSec": 10, + "healthyThreshold": 2, + "name": "computehealthcheck-${uniqueId}", + "region": "projects/${projectId}/global/regions/europe-west4", + "tcpHealthCheck": { + "port": 443, + "proxyHeader": "NONE" + }, + "timeoutSec": 5, + "type": "TCP", + "unhealthyThreshold": 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 + +{ + "id": "000000000000000000000", + "insertTime": "2024-04-01T12:34:56.123456Z", + "kind": "compute#operation", + "name": "${operationID}", + "progress": 0, + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "DONE" +} + +--- + +GET https://compute.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/healthChecks/computehealthcheck-${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 + +{ + "checkIntervalSec": 10, + "creationTimestamp": "2024-04-01T12:34:56.123456Z", + "healthyThreshold": 2, + "id": "000000000000000000000", + "kind": "compute#healthCheck", + "name": "computehealthcheck-${uniqueId}", + "region": "projects/${projectId}/global/regions/europe-west4", + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/healthChecks/computehealthcheck-${uniqueId}", + "tcpHealthCheck": { + "port": 443, + "proxyHeader": "NONE" + }, + "timeoutSec": 5, + "type": "TCP", + "unhealthyThreshold": 2 +} + +--- + +GET https://compute.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/backendServices/computebackendservice-${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}/regions/europe-west4/backendServices/computebackendservice-${uniqueId}' was not found", + "reason": "notFound" + } + ], + "message": "The resource 'projects/${projectId}/regions/europe-west4/backendServices/computebackendservice-${uniqueId}' was not found" + } +} + +--- + +POST https://compute.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/backendServices?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 + +{ + "connectionDraining": { + "drainingTimeoutSec": 0 + }, + "healthChecks": [ + "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/healthChecks/computehealthcheck-${uniqueId}" + ], + "iap": { + "enabled": false, + "oauth2ClientId": "", + "oauth2ClientSecret": "" + }, + "loadBalancingScheme": "INTERNAL_MANAGED", + "name": "computebackendservice-${uniqueId}", + "protocol": "TCP", + "region": "projects/${projectId}/global/regions/europe-west4" +} + +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}", + "progress": 0, + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "DONE" +} + +--- + +GET https://compute.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/backendServices/computebackendservice-${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 + +{ + "connectionDraining": { + "drainingTimeoutSec": 0 + }, + "creationTimestamp": "2024-04-01T12:34:56.123456Z", + "healthChecks": [ + "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/healthChecks/computehealthcheck-${uniqueId}" + ], + "iap": { + "enabled": false, + "oauth2ClientId": "", + "oauth2ClientSecret": "" + }, + "id": "000000000000000000000", + "kind": "compute#backendService", + "loadBalancingScheme": "INTERNAL_MANAGED", + "name": "computebackendservice-${uniqueId}", + "protocol": "TCP", + "region": "projects/${projectId}/global/regions/europe-west4", + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/backendServices/computebackendservice-${uniqueId}" +} + +--- + +GET https://compute.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/targetTcpProxies/${targetTcpProxyID} +Content-Type: application/json +User-Agent: kcc/controller-manager +x-goog-request-params: project=${projectId}®ion=europe-west4&target_tcp_proxy=computetargettcpproxy-${uniqueId} + +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}/regions/europe-west4/targetTcpProxies/computetargettcpproxy-${uniqueId}' was not found", + "reason": "notFound" + } + ], + "message": "The resource 'projects/${projectId}/regions/europe-west4/targetTcpProxies/computetargettcpproxy-${uniqueId}' was not found" + } +} + +--- + +POST https://compute.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/targetTcpProxies +Content-Type: application/json +User-Agent: kcc/controller-manager +x-goog-request-params: project=${projectId}®ion=europe-west4 + +{ + "description": "test target tcp proxy", + "name": "computetargettcpproxy-${uniqueId}", + "proxyBind": false, + "proxyHeader": "NONE", + "region": "europe-west4", + "service": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/backendServices/computebackendservice-${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": "insert", + "progress": 0, + "region": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4", + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "RUNNING", + "targetId": "${targetTcpProxyID}", + "targetLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/targetTcpProxies/computetargettcpproxy-${uniqueId}", + "user": "user@example.com" +} + +--- + +GET https://compute.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/operations/${operationID} +Content-Type: application/json +User-Agent: kcc/controller-manager +x-goog-request-params: project=${projectId}®ion=europe-west4&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": "insert", + "progress": 100, + "region": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4", + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "DONE", + "targetId": "${targetTcpProxyID}", + "targetLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/targetTcpProxies/computetargettcpproxy-${uniqueId}", + "user": "user@example.com" +} + +--- + +GET https://compute.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/targetTcpProxies/${targetTcpProxyID} +Content-Type: application/json +User-Agent: kcc/controller-manager +x-goog-request-params: project=${projectId}®ion=europe-west4&target_tcp_proxy=computetargettcpproxy-${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 + +{ + "creationTimestamp": "2024-04-01T12:34:56.123456Z", + "description": "test target tcp proxy", + "id": "000000000000000000000", + "kind": "compute#targetTcpProxy", + "name": "computetargettcpproxy-${uniqueId}", + "proxyBind": false, + "proxyHeader": "NONE", + "region": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4", + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/targetTcpProxies/computetargettcpproxy-${uniqueId}", + "service": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/backendServices/computebackendservice-${uniqueId}" +} + +--- + +DELETE https://compute.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/targetTcpProxies/${targetTcpProxyID} +Content-Type: application/json +User-Agent: kcc/controller-manager +x-goog-request-params: project=${projectId}®ion=europe-west4&target_tcp_proxy=computetargettcpproxy-${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": "delete", + "progress": 0, + "region": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4", + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "RUNNING", + "targetId": "${targetTcpProxyID}", + "targetLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/targetTcpProxies/computetargettcpproxy-${uniqueId}", + "user": "user@example.com" +} + +--- + +GET https://compute.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/operations/${operationID} +Content-Type: application/json +User-Agent: kcc/controller-manager +x-goog-request-params: project=${projectId}®ion=europe-west4&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": "delete", + "progress": 100, + "region": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4", + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "DONE", + "targetId": "${targetTcpProxyID}", + "targetLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/targetTcpProxies/computetargettcpproxy-${uniqueId}", + "user": "user@example.com" +} + +--- + +GET https://compute.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/backendServices/computebackendservice-${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 + +{ + "connectionDraining": { + "drainingTimeoutSec": 0 + }, + "creationTimestamp": "2024-04-01T12:34:56.123456Z", + "healthChecks": [ + "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/healthChecks/computehealthcheck-${uniqueId}" + ], + "iap": { + "enabled": false, + "oauth2ClientId": "", + "oauth2ClientSecret": "" + }, + "id": "000000000000000000000", + "kind": "compute#backendService", + "loadBalancingScheme": "INTERNAL_MANAGED", + "name": "computebackendservice-${uniqueId}", + "protocol": "TCP", + "region": "projects/${projectId}/global/regions/europe-west4", + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/backendServices/computebackendservice-${uniqueId}" +} + +--- + +DELETE https://compute.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/backendServices/computebackendservice-${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}", + "progress": 0, + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "DONE" +} + +--- + +GET https://compute.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/healthChecks/computehealthcheck-${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 + +{ + "checkIntervalSec": 10, + "creationTimestamp": "2024-04-01T12:34:56.123456Z", + "healthyThreshold": 2, + "id": "000000000000000000000", + "kind": "compute#healthCheck", + "name": "computehealthcheck-${uniqueId}", + "region": "projects/${projectId}/global/regions/europe-west4", + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/healthChecks/computehealthcheck-${uniqueId}", + "tcpHealthCheck": { + "port": 443, + "proxyHeader": "NONE" + }, + "timeoutSec": 5, + "type": "TCP", + "unhealthyThreshold": 2 +} + +--- + +DELETE https://compute.googleapis.com/compute/v1/projects/${projectId}/regions/europe-west4/healthChecks/computehealthcheck-${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}", + "progress": 0, + "selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}", + "startTime": "2024-04-01T12:34:56.123456Z", + "status": "DONE" +} \ No newline at end of file diff --git a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/regionalcomputetargettcpproxy-direct/create.yaml b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/regionalcomputetargettcpproxy-direct/create.yaml new file mode 100644 index 0000000000..7e384eaa4f --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/regionalcomputetargettcpproxy-direct/create.yaml @@ -0,0 +1,28 @@ +# 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: compute.cnrm.cloud.google.com/v1beta1 +kind: ComputeTargetTCPProxy +metadata: + annotations: + cnrm.cloud.google.com/project-id: ${projectId} + alpha.cnrm.cloud.google.com/reconciler: "direct" + name: computetargettcpproxy-${uniqueId} +spec: + description: "test target tcp proxy" + backendServiceRef: + name: computebackendservice-${uniqueId} + proxyBind: false + proxyHeader: NONE + location: europe-west4 diff --git a/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/regionalcomputetargettcpproxy-direct/dependencies.yaml b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/regionalcomputetargettcpproxy-direct/dependencies.yaml new file mode 100644 index 0000000000..870c8c0c3b --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computetargettcpproxy/regionalcomputetargettcpproxy-direct/dependencies.yaml @@ -0,0 +1,38 @@ +# 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: compute.cnrm.cloud.google.com/v1beta1 +kind: ComputeHealthCheck +metadata: + name: computehealthcheck-${uniqueId} +spec: + checkIntervalSec: 10 + tcpHealthCheck: + port: 443 + location: europe-west4 +--- +apiVersion: compute.cnrm.cloud.google.com/v1beta1 +kind: ComputeBackendService +metadata: + name: computebackendservice-${uniqueId} +spec: + healthChecks: + - healthCheckRef: + name: computehealthcheck-${uniqueId} + location: europe-west4 + protocol: TCP + # Default loadBalancingScheme for regional backend service is INTERNAL + # Set to INTERNAL_MANAGED when being referenced by Regional Target TCP Proxy + # googleapi error: Regional Target TCP Proxy cannot be used with BackendServices with schema INTERNAL + loadBalancingScheme: INTERNAL_MANAGED