From fe4edd5713e44eb36467a617b18e75e0214be02e Mon Sep 17 00:00:00 2001 From: misakazhou Date: Wed, 10 Mar 2021 17:20:46 +0800 Subject: [PATCH] add the pointer for optional fields. Signed-off-by: HongYu Zhou --- apis/v1alpha1/gateway_types.go | 16 ++-- apis/v1alpha1/gatewayclass_types.go | 4 +- apis/v1alpha1/httproute_types.go | 8 +- apis/v1alpha1/shared_types.go | 4 +- apis/v1alpha1/tcproute_types.go | 2 +- apis/v1alpha1/tlsroute_types.go | 2 +- apis/v1alpha1/udproute_types.go | 2 +- apis/v1alpha1/zz_generated.deepcopy.go | 114 ++++++++++++++++++++++--- 8 files changed, 122 insertions(+), 30 deletions(-) diff --git a/apis/v1alpha1/gateway_types.go b/apis/v1alpha1/gateway_types.go index 87fb9b66ae..794afb09fe 100644 --- a/apis/v1alpha1/gateway_types.go +++ b/apis/v1alpha1/gateway_types.go @@ -293,7 +293,7 @@ type TLSOverridePolicy struct { // // +optional // +kubebuilder:default=Deny - Certificate TLSRouteOverrideType `json:"certificate,omitempty"` + Certificate *TLSRouteOverrideType `json:"certificate,omitempty"` } // GatewayTLSConfig describes a TLS configuration. @@ -321,7 +321,7 @@ type GatewayTLSConfig struct { // // +optional // +kubebuilder:default=Terminate - Mode TLSModeType `json:"mode,omitempty"` + Mode *TLSModeType `json:"mode,omitempty"` // CertificateRef is the reference to Kubernetes object that contain a // TLS certificate and private key. This certificate MUST be used for @@ -353,7 +353,7 @@ type GatewayTLSConfig struct { // // +optional // +kubebuilder:default={certificate:Deny} - RouteOverride TLSOverridePolicy `json:"routeOverride,omitempty"` + RouteOverride *TLSOverridePolicy `json:"routeOverride,omitempty"` // Options are a list of key/value pairs to give extended options // to the provider. @@ -396,7 +396,7 @@ type RouteBindingSelector struct { // // +optional // +kubebuilder:default={from: Same} - Namespaces RouteNamespaces `json:"namespaces,omitempty"` + Namespaces *RouteNamespaces `json:"namespaces,omitempty"` // Selector specifies a set of route labels used for selecting // routes to associate with the Gateway. If this Selector is defined, // only routes matching the Selector are associated with the Gateway. @@ -426,7 +426,7 @@ type RouteBindingSelector struct { // +kubebuilder:default=networking.x-k8s.io // +kubebuilder:validation:MinLength=1 // +kubebuilder:validation:MaxLength=253 - Group string `json:"group,omitempty"` + Group *string `json:"group,omitempty"` // Kind is the kind of the route resource to select. // // Kind MUST correspond to kinds of routes that are compatible with the @@ -467,7 +467,7 @@ type RouteNamespaces struct { // // +optional // +kubebuilder:default=Same - From RouteSelectType `json:"from,omitempty"` + From *RouteSelectType `json:"from,omitempty"` // Selector must be specified when From is set to "Selector". In that case, // only Routes in Namespaces matching this Selector will be selected by this @@ -476,7 +476,7 @@ type RouteNamespaces struct { // Support: Core // // +optional - Selector metav1.LabelSelector `json:"selector,omitempty"` + Selector *metav1.LabelSelector `json:"selector,omitempty"` } // GatewayAddress describes an address that can be bound to a Gateway. @@ -487,7 +487,7 @@ type GatewayAddress struct { // // +optional // +kubebuilder:default=IPAddress - Type AddressType `json:"type,omitempty"` + Type *AddressType `json:"type,omitempty"` // Value of the address. The validity of the values will depend // on the type and support by the controller. diff --git a/apis/v1alpha1/gatewayclass_types.go b/apis/v1alpha1/gatewayclass_types.go index 2d4f351fa5..0eb55d6b94 100644 --- a/apis/v1alpha1/gatewayclass_types.go +++ b/apis/v1alpha1/gatewayclass_types.go @@ -105,7 +105,7 @@ type ParametersReference struct { // +kubebuilder:validation:Enum=Cluster;Namespace // +kubebuilder:default=Cluster // +optional - Scope string `json:"scope,omitempty"` + Scope *string `json:"scope,omitempty"` // Namespace is the namespace of the referent. // This field is required when scope is set to "Namespace" and ignored when @@ -114,7 +114,7 @@ type ParametersReference struct { // +kubebuilder:validation:MinLength=1 // +kubebuilder:validation:MaxLength=253 // +optional - Namespace string `json:"namespace,omitempty"` + Namespace *string `json:"namespace,omitempty"` } // GatewayClassConditionType is the type for status conditions on diff --git a/apis/v1alpha1/httproute_types.go b/apis/v1alpha1/httproute_types.go index 035932b5b8..6b5640c04a 100644 --- a/apis/v1alpha1/httproute_types.go +++ b/apis/v1alpha1/httproute_types.go @@ -52,7 +52,7 @@ type HTTPRouteSpec struct { // // +optional // +kubebuilder:default={allow: "SameNamespace"} - Gateways RouteGateways `json:"gateways,omitempty"` + Gateways *RouteGateways `json:"gateways,omitempty"` // Hostnames defines a set of hostname that should match against // the HTTP Host header to select a HTTPRoute to process the request. @@ -276,7 +276,7 @@ type HTTPPathMatch struct { // // +optional // +kubebuilder:default=Prefix - Type PathMatchType `json:"type,omitempty"` + Type *PathMatchType `json:"type,omitempty"` // Value of the HTTP path to match against. // @@ -302,7 +302,7 @@ type HTTPHeaderMatch struct { // // +optional // +kubebuilder:default=Exact - Type HeaderMatchType `json:"type,omitempty"` + Type *HeaderMatchType `json:"type,omitempty"` // Values is a map of HTTP Headers to be matched. // It MUST contain at least one entry. @@ -631,7 +631,7 @@ type HTTPRouteForwardTo struct { // +kubebuilder:default=1 // +kubebuilder:validation:Minimum=0 // +kubebuilder:validation:Maximum=1000000 - Weight int32 `json:"weight,omitempty"` + Weight *int32 `json:"weight,omitempty"` // Filters defined at this-level should be executed if and only if the // request is being forwarded to the backend defined here. diff --git a/apis/v1alpha1/shared_types.go b/apis/v1alpha1/shared_types.go index 772d9d42fd..3f2f71b81c 100644 --- a/apis/v1alpha1/shared_types.go +++ b/apis/v1alpha1/shared_types.go @@ -63,7 +63,7 @@ type RouteGateways struct { // +optional // +kubebuilder:validation:Enum=All;FromList;SameNamespace // +kubebuilder:default=SameNamespace - Allow GatewayAllowType `json:"allow,omitempty"` + Allow *GatewayAllowType `json:"allow,omitempty"` // GatewayRefs must be specified when Allow is set to "FromList". In that // case, only Gateways referenced in this list will be allowed to use this @@ -163,7 +163,7 @@ type RouteForwardTo struct { // +kubebuilder:default=1 // +kubebuilder:validation:Minimum=0 // +kubebuilder:validation:Maximum=1000000 - Weight int32 `json:"weight,omitempty"` + Weight *int32 `json:"weight,omitempty"` } // RouteConditionType is a type of condition for a route. diff --git a/apis/v1alpha1/tcproute_types.go b/apis/v1alpha1/tcproute_types.go index 40485d74f9..88dc89a5a2 100644 --- a/apis/v1alpha1/tcproute_types.go +++ b/apis/v1alpha1/tcproute_types.go @@ -48,7 +48,7 @@ type TCPRouteSpec struct { // // +optional // +kubebuilder:default={allow: "SameNamespace"} - Gateways RouteGateways `json:"gateways,omitempty"` + Gateways *RouteGateways `json:"gateways,omitempty"` } // TCPRouteStatus defines the observed state of TCPRoute diff --git a/apis/v1alpha1/tlsroute_types.go b/apis/v1alpha1/tlsroute_types.go index 5ee1a4f410..876877861e 100644 --- a/apis/v1alpha1/tlsroute_types.go +++ b/apis/v1alpha1/tlsroute_types.go @@ -53,7 +53,7 @@ type TLSRouteSpec struct { // // +optional // +kubebuilder:default={allow: "SameNamespace"} - Gateways RouteGateways `json:"gateways,omitempty"` + Gateways *RouteGateways `json:"gateways,omitempty"` } // TLSRouteStatus defines the observed state of TLSRoute diff --git a/apis/v1alpha1/udproute_types.go b/apis/v1alpha1/udproute_types.go index a23ddfd3ba..82ac99928c 100644 --- a/apis/v1alpha1/udproute_types.go +++ b/apis/v1alpha1/udproute_types.go @@ -48,7 +48,7 @@ type UDPRouteSpec struct { // // +optional // +kubebuilder:default={allow: "SameNamespace"} - Gateways RouteGateways `json:"gateways,omitempty"` + Gateways *RouteGateways `json:"gateways,omitempty"` } // UDPRouteStatus defines the observed state of UDPRoute. diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index a1dd2eb1b4..d26dfc3b33 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -210,6 +210,11 @@ func (in *Gateway) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GatewayAddress) DeepCopyInto(out *GatewayAddress) { *out = *in + if in.Type != nil { + in, out := &in.Type, &out.Type + *out = new(AddressType) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GatewayAddress. @@ -287,7 +292,7 @@ func (in *GatewayClassSpec) DeepCopyInto(out *GatewayClassSpec) { if in.ParametersRef != nil { in, out := &in.ParametersRef, &out.ParametersRef *out = new(ParametersReference) - **out = **in + (*in).DeepCopyInto(*out) } } @@ -383,7 +388,9 @@ func (in *GatewaySpec) DeepCopyInto(out *GatewaySpec) { if in.Addresses != nil { in, out := &in.Addresses, &out.Addresses *out = make([]GatewayAddress, len(*in)) - copy(*out, *in) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } } @@ -403,7 +410,9 @@ func (in *GatewayStatus) DeepCopyInto(out *GatewayStatus) { if in.Addresses != nil { in, out := &in.Addresses, &out.Addresses *out = make([]GatewayAddress, len(*in)) - copy(*out, *in) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions @@ -434,12 +443,21 @@ func (in *GatewayStatus) DeepCopy() *GatewayStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GatewayTLSConfig) DeepCopyInto(out *GatewayTLSConfig) { *out = *in + if in.Mode != nil { + in, out := &in.Mode, &out.Mode + *out = new(TLSModeType) + **out = **in + } if in.CertificateRef != nil { in, out := &in.CertificateRef, &out.CertificateRef *out = new(LocalObjectReference) **out = **in } - out.RouteOverride = in.RouteOverride + if in.RouteOverride != nil { + in, out := &in.RouteOverride, &out.RouteOverride + *out = new(TLSOverridePolicy) + (*in).DeepCopyInto(*out) + } if in.Options != nil { in, out := &in.Options, &out.Options *out = make(map[string]string, len(*in)) @@ -462,6 +480,11 @@ func (in *GatewayTLSConfig) DeepCopy() *GatewayTLSConfig { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HTTPHeaderMatch) DeepCopyInto(out *HTTPHeaderMatch) { *out = *in + if in.Type != nil { + in, out := &in.Type, &out.Type + *out = new(HeaderMatchType) + **out = **in + } if in.Values != nil { in, out := &in.Values, &out.Values *out = make(map[string]string, len(*in)) @@ -484,6 +507,11 @@ func (in *HTTPHeaderMatch) DeepCopy() *HTTPHeaderMatch { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HTTPPathMatch) DeepCopyInto(out *HTTPPathMatch) { *out = *in + if in.Type != nil { + in, out := &in.Type, &out.Type + *out = new(PathMatchType) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPPathMatch. @@ -635,6 +663,11 @@ func (in *HTTPRouteForwardTo) DeepCopyInto(out *HTTPRouteForwardTo) { *out = new(PortNumber) **out = **in } + if in.Weight != nil { + in, out := &in.Weight, &out.Weight + *out = new(int32) + **out = **in + } if in.Filters != nil { in, out := &in.Filters, &out.Filters *out = make([]HTTPRouteFilter, len(*in)) @@ -692,7 +725,7 @@ func (in *HTTPRouteMatch) DeepCopyInto(out *HTTPRouteMatch) { if in.Path != nil { in, out := &in.Path, &out.Path *out = new(HTTPPathMatch) - **out = **in + (*in).DeepCopyInto(*out) } if in.Headers != nil { in, out := &in.Headers, &out.Headers @@ -755,7 +788,11 @@ func (in *HTTPRouteRule) DeepCopy() *HTTPRouteRule { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HTTPRouteSpec) DeepCopyInto(out *HTTPRouteSpec) { *out = *in - in.Gateways.DeepCopyInto(&out.Gateways) + if in.Gateways != nil { + in, out := &in.Gateways, &out.Gateways + *out = new(RouteGateways) + (*in).DeepCopyInto(*out) + } if in.Hostnames != nil { in, out := &in.Hostnames, &out.Hostnames *out = make([]Hostname, len(*in)) @@ -872,6 +909,16 @@ func (in *LocalObjectReference) DeepCopy() *LocalObjectReference { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ParametersReference) DeepCopyInto(out *ParametersReference) { *out = *in + if in.Scope != nil { + in, out := &in.Scope, &out.Scope + *out = new(string) + **out = **in + } + if in.Namespace != nil { + in, out := &in.Namespace, &out.Namespace + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ParametersReference. @@ -887,12 +934,21 @@ func (in *ParametersReference) DeepCopy() *ParametersReference { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RouteBindingSelector) DeepCopyInto(out *RouteBindingSelector) { *out = *in - in.Namespaces.DeepCopyInto(&out.Namespaces) + if in.Namespaces != nil { + in, out := &in.Namespaces, &out.Namespaces + *out = new(RouteNamespaces) + (*in).DeepCopyInto(*out) + } if in.Selector != nil { in, out := &in.Selector, &out.Selector *out = new(v1.LabelSelector) (*in).DeepCopyInto(*out) } + if in.Group != nil { + in, out := &in.Group, &out.Group + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteBindingSelector. @@ -923,6 +979,11 @@ func (in *RouteForwardTo) DeepCopyInto(out *RouteForwardTo) { *out = new(PortNumber) **out = **in } + if in.Weight != nil { + in, out := &in.Weight, &out.Weight + *out = new(int32) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteForwardTo. @@ -961,6 +1022,11 @@ func (in *RouteGatewayStatus) DeepCopy() *RouteGatewayStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RouteGateways) DeepCopyInto(out *RouteGateways) { *out = *in + if in.Allow != nil { + in, out := &in.Allow, &out.Allow + *out = new(GatewayAllowType) + **out = **in + } if in.GatewayRefs != nil { in, out := &in.GatewayRefs, &out.GatewayRefs *out = make([]GatewayReference, len(*in)) @@ -981,7 +1047,16 @@ func (in *RouteGateways) DeepCopy() *RouteGateways { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RouteNamespaces) DeepCopyInto(out *RouteNamespaces) { *out = *in - in.Selector.DeepCopyInto(&out.Selector) + if in.From != nil { + in, out := &in.From, &out.From + *out = new(RouteSelectType) + **out = **in + } + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteNamespaces. @@ -1150,7 +1225,11 @@ func (in *TCPRouteSpec) DeepCopyInto(out *TCPRouteSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - in.Gateways.DeepCopyInto(&out.Gateways) + if in.Gateways != nil { + in, out := &in.Gateways, &out.Gateways + *out = new(RouteGateways) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TCPRouteSpec. @@ -1182,6 +1261,11 @@ func (in *TCPRouteStatus) DeepCopy() *TCPRouteStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TLSOverridePolicy) DeepCopyInto(out *TLSOverridePolicy) { *out = *in + if in.Certificate != nil { + in, out := &in.Certificate, &out.Certificate + *out = new(TLSRouteOverrideType) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TLSOverridePolicy. @@ -1317,7 +1401,11 @@ func (in *TLSRouteSpec) DeepCopyInto(out *TLSRouteSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - in.Gateways.DeepCopyInto(&out.Gateways) + if in.Gateways != nil { + in, out := &in.Gateways, &out.Gateways + *out = new(RouteGateways) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TLSRouteSpec. @@ -1464,7 +1552,11 @@ func (in *UDPRouteSpec) DeepCopyInto(out *UDPRouteSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - in.Gateways.DeepCopyInto(&out.Gateways) + if in.Gateways != nil { + in, out := &in.Gateways, &out.Gateways + *out = new(RouteGateways) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UDPRouteSpec.