Skip to content

Commit

Permalink
update backend service in compute tcp proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
gemmahou committed Nov 21, 2024
1 parent fdb12cb commit d040e19
Show file tree
Hide file tree
Showing 18 changed files with 2,151 additions and 60 deletions.
30 changes: 30 additions & 0 deletions mockgcp/mockcompute/globaltargettcpproxyv1.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,36 @@ func (s *GlobalTargetTcpProxyV1) Delete(ctx context.Context, req *pb.DeleteTarge
})
}

func (s *GlobalTargetTcpProxyV1) SetBackendService(ctx context.Context, req *pb.SetBackendServiceTargetTcpProxyRequest) (*pb.Operation, error) {
reqName := "projects/" + req.GetProject() + "/global/targetTcpProxies/" + req.GetTargetTcpProxy()
name, err := s.parseTargetTcpProxyName(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, err
}

obj.Service = req.GetTargetTcpProxiesSetBackendServiceRequestResource().Service
if err := s.storage.Update(ctx, fqn, obj); err != nil {
return nil, err
}

op := &pb.Operation{
TargetId: obj.Id,
TargetLink: obj.SelfLink,
OperationType: PtrTo("TargetTcpProxySetBackendService"),
User: PtrTo("[email protected]"),
}
return s.startGlobalLRO(ctx, name.Project.ID, op, func() (proto.Message, error) {
return obj, nil
})
}

func (s *GlobalTargetTcpProxyV1) SetProxyHeader(ctx context.Context, req *pb.SetProxyHeaderTargetTcpProxyRequest) (*pb.Operation, error) {
reqName := "projects/" + req.GetProject() + "/global/targetTcpProxies/" + req.GetTargetTcpProxy()
name, err := s.parseTargetTcpProxyName(reqName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ func (m *targetTCPProxyModel) AdapterForObject(ctx context.Context, reader clien
}
location := parent.Region

// Handle TF default values
if obj.Spec.ProxyHeader == nil {
obj.Spec.ProxyHeader = direct.PtrTo("NONE")
}

// Get GCP client
if location == "global" {
gcpClient, err := m.client(ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ metadata:
finalizers:
- cnrm.cloud.google.com/finalizer
- cnrm.cloud.google.com/deletion-defender
generation: 1
generation: 2
labels:
cnrm-test: "true"
name: computetargettcpproxy-${uniqueId}
namespace: ${uniqueId}
spec:
backendServiceRef:
name: computebackendservice-${uniqueId}
name: computebackendservice-2-${uniqueId}
status:
conditions:
- lastTransitionTime: "1970-01-01T00:00:00Z"
Expand All @@ -25,6 +25,6 @@ status:
type: Ready
creationTimestamp: "1970-01-01T00:00:00Z"
externalRef: projects/${projectId}/global/targetTcpProxies/computetargettcpproxy-${uniqueId}
observedGeneration: 1
observedGeneration: 2
proxyId: 1111111111111111
selfLink: https://www.googleapis.com/compute/v1/projects/${projectId}/global/targetTcpProxies/computetargettcpproxy-${uniqueId}
Loading

0 comments on commit d040e19

Please sign in to comment.