Skip to content

Commit

Permalink
Merge pull request GoogleCloudPlatform#2352 from gemmahou/refs
Browse files Browse the repository at this point in the history
fix: Update direct forwarding rule API to use v1beta1 refs
  • Loading branch information
google-oss-prow[bot] authored Jul 25, 2024
2 parents d7c4dba + 85e62fd commit f0bda23
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 95 deletions.
23 changes: 12 additions & 11 deletions apis/compute/v1beta1/computeforwardingrule_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1beta1

import (
refs "github.com/GoogleCloudPlatform/k8s-config-connector/apis/refs/v1beta1"
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/k8s/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down Expand Up @@ -50,7 +51,7 @@ type ForwardingruleFilterLabels struct {

type ForwardingruleIpAddress struct {
// +optional
AddressRef *v1alpha1.ResourceRef `json:"addressRef,omitempty"`
AddressRef *refs.ComputeAddressRef `json:"addressRef,omitempty"`

// +optional
Ip *string `json:"ip,omitempty"`
Expand Down Expand Up @@ -87,25 +88,25 @@ type ForwardingruleServiceDirectoryRegistrations struct {

type ForwardingruleTarget struct {
// +optional
ServiceAttachmentRef *v1alpha1.ResourceRef `json:"serviceAttachmentRef,omitempty"`
ServiceAttachmentRef *refs.ComputeServiceAttachmentRef `json:"serviceAttachmentRef,omitempty"`

// +optional
TargetGRPCProxyRef *v1alpha1.ResourceRef `json:"targetGRPCProxyRef,omitempty"`
TargetGRPCProxyRef *refs.ComputeTargetGrpcProxyRef `json:"targetGRPCProxyRef,omitempty"`

// +optional
TargetHTTPProxyRef *v1alpha1.ResourceRef `json:"targetHTTPProxyRef,omitempty"`
TargetHTTPProxyRef *refs.ComputeTargetHTTPProxyRef `json:"targetHTTPProxyRef,omitempty"`

// +optional
TargetHTTPSProxyRef *v1alpha1.ResourceRef `json:"targetHTTPSProxyRef,omitempty"`
TargetHTTPSProxyRef *refs.ComputeTargetHTTPSProxyRef `json:"targetHTTPSProxyRef,omitempty"`

// +optional
TargetSSLProxyRef *v1alpha1.ResourceRef `json:"targetSSLProxyRef,omitempty"`
TargetSSLProxyRef *refs.ComputeTargetSSLProxyRef `json:"targetSSLProxyRef,omitempty"`

// +optional
TargetTCPProxyRef *v1alpha1.ResourceRef `json:"targetTCPProxyRef,omitempty"`
TargetTCPProxyRef *refs.ComputeTargetTCPProxyRef `json:"targetTCPProxyRef,omitempty"`

// +optional
TargetVPNGatewayRef *v1alpha1.ResourceRef `json:"targetVPNGatewayRef,omitempty"`
TargetVPNGatewayRef *refs.ComputeTargetVPNGatewayRef `json:"targetVPNGatewayRef,omitempty"`
}

// +kcc:proto=google.cloud.compute.v1.ForwardingRule
Expand Down Expand Up @@ -147,7 +148,7 @@ type ComputeForwardingRuleSpec struct {
/* A ComputeBackendService to receive the matched traffic. This is
used only for internal load balancing. */
// +optional
BackendServiceRef *v1alpha1.ResourceRef `json:"backendServiceRef,omitempty"`
BackendServiceRef *refs.ComputeBackendServiceRef `json:"backendServiceRef,omitempty"`

/* Immutable. An optional description of this resource. Provide this property when
you create the resource. */
Expand Down Expand Up @@ -245,7 +246,7 @@ type ComputeForwardingRuleSpec struct {
balanced IP should belong to for this forwarding rule. If this
field is not specified, the default network will be used. */
// +optional
NetworkRef *v1alpha1.ResourceRef `json:"networkRef,omitempty"`
NetworkRef *refs.ComputeNetworkRef `json:"networkRef,omitempty"`

/* Immutable. This signifies the networking tier used for configuring
this load balancer and can only take the following values:
Expand Down Expand Up @@ -352,7 +353,7 @@ type ComputeForwardingRuleSpec struct {
optional. However, if the network is in custom subnet mode, a
subnetwork must be specified. */
// +optional
SubnetworkRef *v1alpha1.ResourceRef `json:"subnetworkRef,omitempty"`
SubnetworkRef *refs.ComputeSubnetworkRef `json:"subnetworkRef,omitempty"`

/* The target resource to receive the matched traffic. The forwarded
traffic must be of a type appropriate to the target object. For
Expand Down
23 changes: 12 additions & 11 deletions apis/compute/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

114 changes: 114 additions & 0 deletions apis/refs/v1beta1/computerefs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// 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 v1beta1

type ComputeNetworkRef struct {
/* The compute network selflink of form "projects/<project>/global/networks/<network>", when not managed by KCC. */
External string `json:"external,omitempty"`
/* The `name` field of a `ComputeNetwork` resource. */
Name string `json:"name,omitempty"`
/* The `namespace` field of a `ComputeNetwork` resource. */
Namespace string `json:"namespace,omitempty"`
}

type ComputeSubnetworkRef struct {
/* The ComputeSubnetwork selflink of form "projects/{{project}}/regions/{{region}}/subnetworks/{{name}}", when not managed by KCC. */
External string `json:"external,omitempty"`
/* The `name` field of a `ComputeSubnetwork` resource. */
Name string `json:"name,omitempty"`
/* The `namespace` field of a `ComputeSubnetwork` resource. */
Namespace string `json:"namespace,omitempty"`
}

type ComputeAddressRef struct {
/* The ComputeAddress selflink in the form "projects/{{project}}/regions/{{region}}/addresses/{{name}}" when not managed by KCC. */
External string `json:"external,omitempty"`
/* The `name` field of a `ComputeAddress` resource. */
Name string `json:"name,omitempty"`
/* The `namespace` field of a `ComputeAddress` resource. */
Namespace string `json:"namespace,omitempty"`
}

type ComputeBackendServiceRef struct {
/* The ComputeBackendService selflink in the form "projects/{{project}}/global/backendServices/{{name}}" or "projects/{{project}}/regions/{{region}}/backendServices/{{name}}" when not managed by KCC. */
External string `json:"external,omitempty"`
/* The `name` field of a `ComputeBackendService` resource. */
Name string `json:"name,omitempty"`
/* The `namespace` field of a `ComputeBackendService` resource. */
Namespace string `json:"namespace,omitempty"`
}

type ComputeServiceAttachmentRef struct {
/* The ComputeServiceAttachment selflink in the form "projects/{{project}}/regions/{{region}}/serviceAttachments/{{name}}" when not managed by KCC. */
External string `json:"external,omitempty"`
/* The `name` field of a `ComputeServiceAttachment` resource. */
Name string `json:"name,omitempty"`
/* The `namespace` field of a `ComputeServiceAttachment` resource. */
Namespace string `json:"namespace,omitempty"`
}

type ComputeTargetGrpcProxyRef struct {
/* The ComputeTargetGrpcProxy selflink in the form "projects/{{project}}/global/targetGrpcProxies/{{name}}" when not managed by KCC. */
External string `json:"external,omitempty"`
/* The `name` field of a `ComputeTargetGrpcProxy` resource. */
Name string `json:"name,omitempty"`
/* The `namespace` field of a `ComputeTargetGrpcProxy` resource. */
Namespace string `json:"namespace,omitempty"`
}

type ComputeTargetHTTPProxyRef struct {
/* The ComputeTargetHTTPProxy selflink in the form "projects/{{project}}/global/targetHttpProxies/{{name}}" or "projects/{{project}}/regions/{{region}}/targetHttpProxies/{{name}}" when not managed by KCC. */
External string `json:"external,omitempty"`
/* The `name` field of a `ComputeTargetHTTPProxy` resource. */
Name string `json:"name,omitempty"`
/* The `namespace` field of a `ComputeTargetHTTPProxy` resource. */
Namespace string `json:"namespace,omitempty"`
}

type ComputeTargetHTTPSProxyRef struct {
/* The ComputeTargetHTTPSProxy selflink in the form "projects/{{project}}/global/targetHttpProxies/{{name}}" or "projects/{{project}}/regions/{{region}}/targetHttpProxies/{{name}}" when not managed by KCC. */
External string `json:"external,omitempty"`
/* The `name` field of a `ComputeTargetHTTPSProxy` resource. */
Name string `json:"name,omitempty"`
/* The `namespace` field of a `ComputeTargetHTTPSProxy` resource. */
Namespace string `json:"namespace,omitempty"`
}

type ComputeTargetSSLProxyRef struct {
/* The ComputeTargetSSLProxy selflink in the form "projects/{{project}}/global/targetSslProxies/{{name}}" when not managed by KCC. */
External string `json:"external,omitempty"`
/* The `name` field of a `ComputeTargetSSLProxy` resource. */
Name string `json:"name,omitempty"`
/* The `namespace` field of a `ComputeTargetSSLProxy` resource. */
Namespace string `json:"namespace,omitempty"`
}

type ComputeTargetTCPProxyRef struct {
/* The ComputeTargetTCPProxy selflink in the form "projects/{{project}}/global/targetTcpProxies/{{name}}" or "projects/{{project}}/regions/{{region}}/targetTcpProxies/{{name}}" when not managed by KCC. */
External string `json:"external,omitempty"`
/* The `name` field of a `ComputeTargetTCPProxy` resource. */
Name string `json:"name,omitempty"`
/* The `namespace` field of a `ComputeTargetTCPProxy` resource. */
Namespace string `json:"namespace,omitempty"`
}

type ComputeTargetVPNGatewayRef struct {
/* The ComputeTargetVPNGateway selflink in the form "projects/{{project}}/regions/{{region}}/targetVpnGateways/{{name}}" when not managed by KCC. */
External string `json:"external,omitempty"`
/* The `name` field of a `ComputeTargetVPNGateway` resource. */
Name string `json:"name,omitempty"`
/* The `namespace` field of a `ComputeTargetVPNGateway` resource. */
Namespace string `json:"namespace,omitempty"`
}
24 changes: 0 additions & 24 deletions apis/refs/v1beta1/networkref.go

This file was deleted.

12 changes: 6 additions & 6 deletions pkg/controller/direct/compute/mapper.generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func ComputeForwardingRuleSpec_FromProto(mapCtx *direct.MapContext, in *pb.Forwa
out.AllPorts = direct.LazyPtr(in.GetAllPorts())
out.AllowGlobalAccess = direct.LazyPtr(in.GetAllowGlobalAccess())
out.AllowPscGlobalAccess = direct.LazyPtr(in.GetAllowPscGlobalAccess())
out.BackendServiceRef = direct.ResourceRef_FromProto(mapCtx, in.GetBackendService())
out.BackendServiceRef = ComputeForwardingRuleSpec_BackendSeriviceRef_FromProto(mapCtx, in.GetBackendService())
// MISSING: BaseForwardingRule
// MISSING: CreationTimestamp
out.Description = direct.LazyPtr(in.GetDescription())
Expand All @@ -46,7 +46,7 @@ func ComputeForwardingRuleSpec_FromProto(mapCtx *direct.MapContext, in *pb.Forwa
out.LoadBalancingScheme = direct.LazyPtr(in.GetLoadBalancingScheme())
out.MetadataFilters = direct.Slice_FromProto(mapCtx, in.MetadataFilters, ForwardingruleMetadataFilters_FromProto)
// MISSING: Name
out.NetworkRef = direct.ResourceRef_FromProto(mapCtx, in.GetNetwork())
out.NetworkRef = ComputeForwardingRuleSpec_NetworkRef_FromProto(mapCtx, in.GetNetwork())
out.NetworkTier = direct.LazyPtr(in.GetNetworkTier())
out.NoAutomateDnsZone = direct.LazyPtr(in.GetNoAutomateDnsZone())
out.PortRange = direct.LazyPtr(in.GetPortRange())
Expand All @@ -59,7 +59,7 @@ func ComputeForwardingRuleSpec_FromProto(mapCtx *direct.MapContext, in *pb.Forwa
out.ServiceLabel = direct.LazyPtr(in.GetServiceLabel())
// MISSING: ServiceName
out.SourceIpRanges = in.SourceIpRanges
out.SubnetworkRef = direct.ResourceRef_FromProto(mapCtx, in.GetSubnetwork())
out.SubnetworkRef = ComputeForwardingRuleSpec_SubnetworkRef_FromProto(mapCtx, in.GetSubnetwork())
out.Target = ComputeForwardingRuleSpec_Target_FromProto(mapCtx, in.GetTarget())
return out
}
Expand All @@ -73,7 +73,7 @@ func ComputeForwardingRuleSpec_ToProto(mapCtx *direct.MapContext, in *krm.Comput
out.AllPorts = in.AllPorts
out.AllowGlobalAccess = in.AllowGlobalAccess
out.AllowPscGlobalAccess = in.AllowPscGlobalAccess
out.BackendService = direct.ResourceRef_ToProto(mapCtx, in.BackendServiceRef)
out.BackendService = ComputeForwardingRuleSpec_BackendSeriviceRef_ToProto(mapCtx, in.BackendServiceRef)
// MISSING: BaseForwardingRule
// MISSING: CreationTimestamp
out.Description = in.Description
Expand All @@ -88,7 +88,7 @@ func ComputeForwardingRuleSpec_ToProto(mapCtx *direct.MapContext, in *krm.Comput
out.LoadBalancingScheme = in.LoadBalancingScheme
out.MetadataFilters = direct.Slice_ToProto(mapCtx, in.MetadataFilters, ForwardingruleMetadataFilters_ToProto)
// MISSING: Name
out.Network = direct.ResourceRef_ToProto(mapCtx, in.NetworkRef)
out.Network = ComputeForwardingRuleSpec_NetworkRef_ToProto(mapCtx, in.NetworkRef)
out.NetworkTier = in.NetworkTier
out.NoAutomateDnsZone = in.NoAutomateDnsZone
out.PortRange = in.PortRange
Expand All @@ -101,7 +101,7 @@ func ComputeForwardingRuleSpec_ToProto(mapCtx *direct.MapContext, in *krm.Comput
out.ServiceLabel = in.ServiceLabel
// MISSING: ServiceName
out.SourceIpRanges = in.SourceIpRanges
out.Subnetwork = direct.ResourceRef_ToProto(mapCtx, in.SubnetworkRef)
out.Subnetwork = ComputeForwardingRuleSpec_SubnetworkRef_ToProto(mapCtx, in.SubnetworkRef)
out.Target = ComputeForwardingRuleSpec_Target_ToProto(mapCtx, in.Target)
return out
}
Expand Down
Loading

0 comments on commit f0bda23

Please sign in to comment.