diff --git a/apis/v1alpha2/clusternetworkpolicy_types.go b/apis/v1alpha2/clusternetworkpolicy_types.go index dafb4b18..1c8618f8 100644 --- a/apis/v1alpha2/clusternetworkpolicy_types.go +++ b/apis/v1alpha2/clusternetworkpolicy_types.go @@ -202,16 +202,15 @@ type ClusterNetworkPolicyIngressRule struct { // +kubebuilder:validation:MaxItems=25 From []ClusterNetworkPolicyIngressPeer `json:"from"` - // Ports allows for matching traffic based on port and protocols. - // This field is a list of ports which should be matched on - // the pods selected for this policy i.e the subject of the policy. - // So it matches on the destination port for the ingress traffic. - // If Ports is not set then the rule does not filter traffic via port. + // Protocols this rule matches. This rule matches if any of + // the elements in the list match the incoming traffic. + // + // This field must contain at least one item. // // +optional // +kubebuilder:validation:MinItems=1 - // +kubebuilder:validation:MaxItems=25 - Ports *[]ClusterNetworkPolicyPort `json:"ports,omitempty"` + // +kubebuilder:validation:MaxItems=100 + Protocols *[]ClusterNetworkPolicyProtocol `json:"protocols,omitempty"` } // ClusterNetworkPolicyEgressRule describes an action to take on a particular @@ -316,29 +315,49 @@ type ClusterNetworkPolicyIngressPeer struct { Pods *NamespacedPod `json:"pods,omitempty"` } -// ClusterNetworkPolicyPort describes how to select destination network ports. -// Exactly one field must be set. +// ClusterNetworkPolicyProtocol describes how to select traffic by +// protocol-specific attributes. +// +// +kubebuilder:validation:XValidation:rule="!(self.protocol in ['TCP', 'UDP', 'SCTP']) || has(self.port)",message="port must be specified for protocols that support ports" +type ClusterNetworkPolicyProtocol struct { + // Protocol is the network protocol (TCP, UDP, or SCTP) which + // traffic must match. If not specified, this field defaults + // to TCP. + // + // +kubebuilder:default=TCP + Protocol corev1.Protocol `json:"protocol,omitempty"` + + // Specific port to match against. + // + // +optional + Port *ClusterNetworkPolicyPort `json:"port,omitempty"` +} + +// ClusterNetworkPolicyPort describes how to match by port. This can +// only be used with protocols that use port numbers (e.g. TCP, UDP). +// +// Exactly one of the fields in this struct must be set. +// // +kubebuilder:validation:MaxProperties=1 // +kubebuilder:validation:MinProperties=1 type ClusterNetworkPolicyPort struct { - // Port selects a destination port based on protocol and port number. + // Port selects the port by number. // // +optional - PortNumber *Port `json:"portNumber,omitempty"` + Number *int32 `json:"number,omitempty"` - // PortRange selects a destination port range based on protocol and - // start and end port numbers. + // PortRange selects the port by range. // // +optional - PortRange *PortRange `json:"portRange,omitempty"` + Range *PortRange `json:"range,omitempty"` - // NamedPort selects a destination port on a pod based on the ContainerPort - // name. You can't use this in a rule with Nodes or Networks peers, - // because they do not have named ports. + // NamedPort selects a destination port on a pod based on the + // ContainerPort name. You can't use this in a rule with Nodes + // or Networks peers, because they do not have named ports. // // // +optional - NamedPort *string `json:"namedPort,omitempty"` + Name *string `json:"name,omitempty"` } // ClusterNetworkPolicyEgressPeer defines a peer to allow traffic to. @@ -424,32 +443,13 @@ type NamespacedPod struct { PodSelector metav1.LabelSelector `json:"podSelector"` } -type Port struct { - // Protocol is the network protocol (TCP, UDP, or SCTP) which traffic must - // match. If not specified, this field defaults to TCP. - // +kubebuilder:default=TCP - // - Protocol corev1.Protocol `json:"protocol"` - - // Number defines a network port value. - // +kubebuilder:validation:Minimum=1 - // +kubebuilder:validation:Maximum=65535 - // - Port int32 `json:"port"` -} - // PortRange defines an inclusive range of ports from the assigned // Start value to End value. // +kubebuilder:validation:XValidation:rule="self.start < self.end", message="Start port must be less than End port" type PortRange struct { - // Protocol is the network protocol (TCP, UDP, or SCTP) which traffic must - // match. If not specified, this field defaults to TCP. - // +kubebuilder:default=TCP - // - Protocol corev1.Protocol `json:"protocol,omitempty"` - // Start defines a network port that is the start of a port range, the Start // value must be less than End. + // // +kubebuilder:validation:Minimum=1 // +kubebuilder:validation:Maximum=65535 // @@ -457,6 +457,7 @@ type PortRange struct { // End defines a network port that is the end of a port range, the End value // must be greater than Start. + // // +kubebuilder:validation:Minimum=1 // +kubebuilder:validation:Maximum=65535 // diff --git a/apis/v1alpha2/zz_generated.deepcopy.go b/apis/v1alpha2/zz_generated.deepcopy.go index df671c5b..dbd24c31 100644 --- a/apis/v1alpha2/zz_generated.deepcopy.go +++ b/apis/v1alpha2/zz_generated.deepcopy.go @@ -160,12 +160,12 @@ func (in *ClusterNetworkPolicyIngressRule) DeepCopyInto(out *ClusterNetworkPolic (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.Ports != nil { - in, out := &in.Ports, &out.Ports - *out = new([]ClusterNetworkPolicyPort) + if in.Protocols != nil { + in, out := &in.Protocols, &out.Protocols + *out = new([]ClusterNetworkPolicyProtocol) if **in != nil { in, out := *in, *out - *out = make([]ClusterNetworkPolicyPort, len(*in)) + *out = make([]ClusterNetworkPolicyProtocol, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -218,18 +218,18 @@ func (in *ClusterNetworkPolicyList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterNetworkPolicyPort) DeepCopyInto(out *ClusterNetworkPolicyPort) { *out = *in - if in.PortNumber != nil { - in, out := &in.PortNumber, &out.PortNumber - *out = new(Port) + if in.Number != nil { + in, out := &in.Number, &out.Number + *out = new(int32) **out = **in } - if in.PortRange != nil { - in, out := &in.PortRange, &out.PortRange + if in.Range != nil { + in, out := &in.Range, &out.Range *out = new(PortRange) **out = **in } - if in.NamedPort != nil { - in, out := &in.NamedPort, &out.NamedPort + if in.Name != nil { + in, out := &in.Name, &out.Name *out = new(string) **out = **in } @@ -245,6 +245,26 @@ func (in *ClusterNetworkPolicyPort) DeepCopy() *ClusterNetworkPolicyPort { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterNetworkPolicyProtocol) DeepCopyInto(out *ClusterNetworkPolicyProtocol) { + *out = *in + if in.Port != nil { + in, out := &in.Port, &out.Port + *out = new(ClusterNetworkPolicyPort) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterNetworkPolicyProtocol. +func (in *ClusterNetworkPolicyProtocol) DeepCopy() *ClusterNetworkPolicyProtocol { + if in == nil { + return nil + } + out := new(ClusterNetworkPolicyProtocol) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterNetworkPolicySpec) DeepCopyInto(out *ClusterNetworkPolicySpec) { *out = *in @@ -339,21 +359,6 @@ func (in *NamespacedPod) DeepCopy() *NamespacedPod { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Port) DeepCopyInto(out *Port) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Port. -func (in *Port) DeepCopy() *Port { - if in == nil { - return nil - } - out := new(Port) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PortRange) DeepCopyInto(out *PortRange) { *out = *in diff --git a/config/crd/experimental/policy.networking.k8s.io_clusternetworkpolicies.yaml b/config/crd/experimental/policy.networking.k8s.io_clusternetworkpolicies.yaml index 6ff61a65..9b503ed1 100644 --- a/config/crd/experimental/policy.networking.k8s.io_clusternetworkpolicies.yaml +++ b/config/crd/experimental/policy.networking.k8s.io_clusternetworkpolicies.yaml @@ -105,43 +105,27 @@ spec: If Ports is not set then the rule does not filter traffic via port. items: description: |- - ClusterNetworkPolicyPort describes how to select destination network ports. - Exactly one field must be set. + ClusterNetworkPolicyPort describes how to match by port. This can + only be used with protocols that use port numbers (e.g. TCP, UDP). + + Exactly one of the fields in this struct must be set. maxProperties: 1 minProperties: 1 properties: - namedPort: + name: description: |- - NamedPort selects a destination port on a pod based on the ContainerPort - name. You can't use this in a rule with Nodes or Networks peers, - because they do not have named ports. + NamedPort selects a destination port on a pod based on the + ContainerPort name. You can't use this in a rule with Nodes + or Networks peers, because they do not have named ports. type: string - portNumber: - description: Port selects a destination port based on - protocol and port number. - properties: - port: - description: Number defines a network port value. - format: int32 - maximum: 65535 - minimum: 1 - type: integer - protocol: - default: TCP - description: |- - Protocol is the network protocol (TCP, UDP, or SCTP) which traffic must - match. If not specified, this field defaults to TCP. - type: string - required: - - port - - protocol - type: object - portRange: - description: |- - PortRange selects a destination port range based on protocol and - start and end port numbers. + number: + description: Port selects the port by number. + format: int32 + type: integer + range: + description: PortRange selects the port by range. properties: end: description: |- @@ -151,12 +135,6 @@ spec: maximum: 65535 minimum: 1 type: integer - protocol: - default: TCP - description: |- - Protocol is the network protocol (TCP, UDP, or SCTP) which traffic must - match. If not specified, this field defaults to TCP. - type: string start: description: |- Start defines a network port that is the start of a port range, the Start @@ -719,84 +697,75 @@ spec: for any applied AdminNetworkPolicies. maxLength: 100 type: string - ports: + protocols: description: |- - Ports allows for matching traffic based on port and protocols. - This field is a list of ports which should be matched on - the pods selected for this policy i.e the subject of the policy. - So it matches on the destination port for the ingress traffic. - If Ports is not set then the rule does not filter traffic via port. + Protocols this rule matches. This rule matches if any of + the elements in the list match the incoming traffic. + + This field must contain at least one item. items: description: |- - ClusterNetworkPolicyPort describes how to select destination network ports. - Exactly one field must be set. - maxProperties: 1 - minProperties: 1 + ClusterNetworkPolicyProtocol describes how to select traffic by + protocol-specific attributes. properties: - namedPort: - description: |- - NamedPort selects a destination port on a pod based on the ContainerPort - name. You can't use this in a rule with Nodes or Networks peers, - because they do not have named ports. - - - type: string - portNumber: - description: Port selects a destination port based on - protocol and port number. + port: + description: Specific port to match against. + maxProperties: 1 + minProperties: 1 properties: - port: - description: Number defines a network port value. - format: int32 - maximum: 65535 - minimum: 1 - type: integer - protocol: - default: TCP + name: description: |- - Protocol is the network protocol (TCP, UDP, or SCTP) which traffic must - match. If not specified, this field defaults to TCP. - type: string - required: - - port - - protocol - type: object - portRange: - description: |- - PortRange selects a destination port range based on protocol and - start and end port numbers. - properties: - end: - description: |- - End defines a network port that is the end of a port range, the End value - must be greater than Start. - format: int32 - maximum: 65535 - minimum: 1 - type: integer - protocol: - default: TCP - description: |- - Protocol is the network protocol (TCP, UDP, or SCTP) which traffic must - match. If not specified, this field defaults to TCP. + NamedPort selects a destination port on a pod based on the + ContainerPort name. You can't use this in a rule with Nodes + or Networks peers, because they do not have named ports. + + type: string - start: - description: |- - Start defines a network port that is the start of a port range, the Start - value must be less than End. + number: + description: Port selects the port by number. format: int32 - maximum: 65535 - minimum: 1 type: integer - required: - - end - - start + range: + description: PortRange selects the port by range. + properties: + end: + description: |- + End defines a network port that is the end of a port range, the End value + must be greater than Start. + format: int32 + maximum: 65535 + minimum: 1 + type: integer + start: + description: |- + Start defines a network port that is the start of a port range, the Start + value must be less than End. + format: int32 + maximum: 65535 + minimum: 1 + type: integer + required: + - end + - start + type: object + x-kubernetes-validations: + - message: Start port must be less than End port + rule: self.start < self.end type: object - x-kubernetes-validations: - - message: Start port must be less than End port - rule: self.start < self.end + protocol: + default: TCP + description: |- + Protocol is the network protocol (TCP, UDP, or SCTP) which + traffic must match. If not specified, this field defaults + to TCP. + type: string type: object - maxItems: 25 + x-kubernetes-validations: + - message: port must be specified for protocols that support + ports + rule: '!(self.protocol in [''TCP'', ''UDP'', ''SCTP'']) + || has(self.port)' + maxItems: 100 minItems: 1 type: array required: diff --git a/config/crd/standard/policy.networking.k8s.io_clusternetworkpolicies.yaml b/config/crd/standard/policy.networking.k8s.io_clusternetworkpolicies.yaml index 325f13bd..481728fd 100644 --- a/config/crd/standard/policy.networking.k8s.io_clusternetworkpolicies.yaml +++ b/config/crd/standard/policy.networking.k8s.io_clusternetworkpolicies.yaml @@ -105,35 +105,19 @@ spec: If Ports is not set then the rule does not filter traffic via port. items: description: |- - ClusterNetworkPolicyPort describes how to select destination network ports. - Exactly one field must be set. + ClusterNetworkPolicyPort describes how to match by port. This can + only be used with protocols that use port numbers (e.g. TCP, UDP). + + Exactly one of the fields in this struct must be set. maxProperties: 1 minProperties: 1 properties: - portNumber: - description: Port selects a destination port based on - protocol and port number. - properties: - port: - description: Number defines a network port value. - format: int32 - maximum: 65535 - minimum: 1 - type: integer - protocol: - default: TCP - description: |- - Protocol is the network protocol (TCP, UDP, or SCTP) which traffic must - match. If not specified, this field defaults to TCP. - type: string - required: - - port - - protocol - type: object - portRange: - description: |- - PortRange selects a destination port range based on protocol and - start and end port numbers. + number: + description: Port selects the port by number. + format: int32 + type: integer + range: + description: PortRange selects the port by range. properties: end: description: |- @@ -143,12 +127,6 @@ spec: maximum: 65535 minimum: 1 type: integer - protocol: - default: TCP - description: |- - Protocol is the network protocol (TCP, UDP, or SCTP) which traffic must - match. If not specified, this field defaults to TCP. - type: string start: description: |- Start defines a network port that is the start of a port range, the Start @@ -613,76 +591,67 @@ spec: for any applied AdminNetworkPolicies. maxLength: 100 type: string - ports: + protocols: description: |- - Ports allows for matching traffic based on port and protocols. - This field is a list of ports which should be matched on - the pods selected for this policy i.e the subject of the policy. - So it matches on the destination port for the ingress traffic. - If Ports is not set then the rule does not filter traffic via port. + Protocols this rule matches. This rule matches if any of + the elements in the list match the incoming traffic. + + This field must contain at least one item. items: description: |- - ClusterNetworkPolicyPort describes how to select destination network ports. - Exactly one field must be set. - maxProperties: 1 - minProperties: 1 + ClusterNetworkPolicyProtocol describes how to select traffic by + protocol-specific attributes. properties: - portNumber: - description: Port selects a destination port based on - protocol and port number. + port: + description: Specific port to match against. + maxProperties: 1 + minProperties: 1 properties: - port: - description: Number defines a network port value. + number: + description: Port selects the port by number. format: int32 - maximum: 65535 - minimum: 1 type: integer - protocol: - default: TCP - description: |- - Protocol is the network protocol (TCP, UDP, or SCTP) which traffic must - match. If not specified, this field defaults to TCP. - type: string - required: - - port - - protocol + range: + description: PortRange selects the port by range. + properties: + end: + description: |- + End defines a network port that is the end of a port range, the End value + must be greater than Start. + format: int32 + maximum: 65535 + minimum: 1 + type: integer + start: + description: |- + Start defines a network port that is the start of a port range, the Start + value must be less than End. + format: int32 + maximum: 65535 + minimum: 1 + type: integer + required: + - end + - start + type: object + x-kubernetes-validations: + - message: Start port must be less than End port + rule: self.start < self.end type: object - portRange: + protocol: + default: TCP description: |- - PortRange selects a destination port range based on protocol and - start and end port numbers. - properties: - end: - description: |- - End defines a network port that is the end of a port range, the End value - must be greater than Start. - format: int32 - maximum: 65535 - minimum: 1 - type: integer - protocol: - default: TCP - description: |- - Protocol is the network protocol (TCP, UDP, or SCTP) which traffic must - match. If not specified, this field defaults to TCP. - type: string - start: - description: |- - Start defines a network port that is the start of a port range, the Start - value must be less than End. - format: int32 - maximum: 65535 - minimum: 1 - type: integer - required: - - end - - start - type: object - x-kubernetes-validations: - - message: Start port must be less than End port - rule: self.start < self.end + Protocol is the network protocol (TCP, UDP, or SCTP) which + traffic must match. If not specified, this field defaults + to TCP. + type: string type: object - maxItems: 25 + x-kubernetes-validations: + - message: port must be specified for protocols that support + ports + rule: '!(self.protocol in [''TCP'', ''UDP'', ''SCTP'']) + || has(self.port)' + maxItems: 100 minItems: 1 type: array required: diff --git a/pkg/client/applyconfiguration/apis/v1alpha2/clusternetworkpolicyingressrule.go b/pkg/client/applyconfiguration/apis/v1alpha2/clusternetworkpolicyingressrule.go index b1885ab4..830c99b5 100644 --- a/pkg/client/applyconfiguration/apis/v1alpha2/clusternetworkpolicyingressrule.go +++ b/pkg/client/applyconfiguration/apis/v1alpha2/clusternetworkpolicyingressrule.go @@ -25,10 +25,10 @@ import ( // ClusterNetworkPolicyIngressRuleApplyConfiguration represents a declarative configuration of the ClusterNetworkPolicyIngressRule type for use // with apply. type ClusterNetworkPolicyIngressRuleApplyConfiguration struct { - Name *string `json:"name,omitempty"` - Action *apisv1alpha2.ClusterNetworkPolicyRuleAction `json:"action,omitempty"` - From []ClusterNetworkPolicyIngressPeerApplyConfiguration `json:"from,omitempty"` - Ports *[]ClusterNetworkPolicyPortApplyConfiguration `json:"ports,omitempty"` + Name *string `json:"name,omitempty"` + Action *apisv1alpha2.ClusterNetworkPolicyRuleAction `json:"action,omitempty"` + From []ClusterNetworkPolicyIngressPeerApplyConfiguration `json:"from,omitempty"` + Protocols *[]ClusterNetworkPolicyProtocolApplyConfiguration `json:"protocols,omitempty"` } // ClusterNetworkPolicyIngressRuleApplyConfiguration constructs a declarative configuration of the ClusterNetworkPolicyIngressRule type for use with @@ -66,22 +66,22 @@ func (b *ClusterNetworkPolicyIngressRuleApplyConfiguration) WithFrom(values ...* return b } -func (b *ClusterNetworkPolicyIngressRuleApplyConfiguration) ensureClusterNetworkPolicyPortApplyConfigurationExists() { - if b.Ports == nil { - b.Ports = &[]ClusterNetworkPolicyPortApplyConfiguration{} +func (b *ClusterNetworkPolicyIngressRuleApplyConfiguration) ensureClusterNetworkPolicyProtocolApplyConfigurationExists() { + if b.Protocols == nil { + b.Protocols = &[]ClusterNetworkPolicyProtocolApplyConfiguration{} } } -// WithPorts adds the given value to the Ports field in the declarative configuration +// WithProtocols adds the given value to the Protocols field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. -// If called multiple times, values provided by each call will be appended to the Ports field. -func (b *ClusterNetworkPolicyIngressRuleApplyConfiguration) WithPorts(values ...*ClusterNetworkPolicyPortApplyConfiguration) *ClusterNetworkPolicyIngressRuleApplyConfiguration { - b.ensureClusterNetworkPolicyPortApplyConfigurationExists() +// If called multiple times, values provided by each call will be appended to the Protocols field. +func (b *ClusterNetworkPolicyIngressRuleApplyConfiguration) WithProtocols(values ...*ClusterNetworkPolicyProtocolApplyConfiguration) *ClusterNetworkPolicyIngressRuleApplyConfiguration { + b.ensureClusterNetworkPolicyProtocolApplyConfigurationExists() for i := range values { if values[i] == nil { - panic("nil value passed to WithPorts") + panic("nil value passed to WithProtocols") } - *b.Ports = append(*b.Ports, *values[i]) + *b.Protocols = append(*b.Protocols, *values[i]) } return b } diff --git a/pkg/client/applyconfiguration/apis/v1alpha2/clusternetworkpolicyport.go b/pkg/client/applyconfiguration/apis/v1alpha2/clusternetworkpolicyport.go index d0831978..7d8f7ba1 100644 --- a/pkg/client/applyconfiguration/apis/v1alpha2/clusternetworkpolicyport.go +++ b/pkg/client/applyconfiguration/apis/v1alpha2/clusternetworkpolicyport.go @@ -21,9 +21,9 @@ package v1alpha2 // ClusterNetworkPolicyPortApplyConfiguration represents a declarative configuration of the ClusterNetworkPolicyPort type for use // with apply. type ClusterNetworkPolicyPortApplyConfiguration struct { - PortNumber *PortApplyConfiguration `json:"portNumber,omitempty"` - PortRange *PortRangeApplyConfiguration `json:"portRange,omitempty"` - NamedPort *string `json:"namedPort,omitempty"` + Number *int32 `json:"number,omitempty"` + Range *PortRangeApplyConfiguration `json:"range,omitempty"` + Name *string `json:"name,omitempty"` } // ClusterNetworkPolicyPortApplyConfiguration constructs a declarative configuration of the ClusterNetworkPolicyPort type for use with @@ -32,26 +32,26 @@ func ClusterNetworkPolicyPort() *ClusterNetworkPolicyPortApplyConfiguration { return &ClusterNetworkPolicyPortApplyConfiguration{} } -// WithPortNumber sets the PortNumber field in the declarative configuration to the given value +// WithNumber sets the Number field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the PortNumber field is set to the value of the last call. -func (b *ClusterNetworkPolicyPortApplyConfiguration) WithPortNumber(value *PortApplyConfiguration) *ClusterNetworkPolicyPortApplyConfiguration { - b.PortNumber = value +// If called multiple times, the Number field is set to the value of the last call. +func (b *ClusterNetworkPolicyPortApplyConfiguration) WithNumber(value int32) *ClusterNetworkPolicyPortApplyConfiguration { + b.Number = &value return b } -// WithPortRange sets the PortRange field in the declarative configuration to the given value +// WithRange sets the Range field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the PortRange field is set to the value of the last call. -func (b *ClusterNetworkPolicyPortApplyConfiguration) WithPortRange(value *PortRangeApplyConfiguration) *ClusterNetworkPolicyPortApplyConfiguration { - b.PortRange = value +// If called multiple times, the Range field is set to the value of the last call. +func (b *ClusterNetworkPolicyPortApplyConfiguration) WithRange(value *PortRangeApplyConfiguration) *ClusterNetworkPolicyPortApplyConfiguration { + b.Range = value return b } -// WithNamedPort sets the NamedPort field in the declarative configuration to the given value +// WithName sets the Name field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the NamedPort field is set to the value of the last call. -func (b *ClusterNetworkPolicyPortApplyConfiguration) WithNamedPort(value string) *ClusterNetworkPolicyPortApplyConfiguration { - b.NamedPort = &value +// If called multiple times, the Name field is set to the value of the last call. +func (b *ClusterNetworkPolicyPortApplyConfiguration) WithName(value string) *ClusterNetworkPolicyPortApplyConfiguration { + b.Name = &value return b } diff --git a/pkg/client/applyconfiguration/apis/v1alpha2/clusternetworkpolicyprotocol.go b/pkg/client/applyconfiguration/apis/v1alpha2/clusternetworkpolicyprotocol.go new file mode 100644 index 00000000..2506f055 --- /dev/null +++ b/pkg/client/applyconfiguration/apis/v1alpha2/clusternetworkpolicyprotocol.go @@ -0,0 +1,52 @@ +/* +Copyright The Kubernetes Authors. + +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. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + v1 "k8s.io/api/core/v1" +) + +// ClusterNetworkPolicyProtocolApplyConfiguration represents a declarative configuration of the ClusterNetworkPolicyProtocol type for use +// with apply. +type ClusterNetworkPolicyProtocolApplyConfiguration struct { + Protocol *v1.Protocol `json:"protocol,omitempty"` + Port *ClusterNetworkPolicyPortApplyConfiguration `json:"port,omitempty"` +} + +// ClusterNetworkPolicyProtocolApplyConfiguration constructs a declarative configuration of the ClusterNetworkPolicyProtocol type for use with +// apply. +func ClusterNetworkPolicyProtocol() *ClusterNetworkPolicyProtocolApplyConfiguration { + return &ClusterNetworkPolicyProtocolApplyConfiguration{} +} + +// WithProtocol sets the Protocol field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Protocol field is set to the value of the last call. +func (b *ClusterNetworkPolicyProtocolApplyConfiguration) WithProtocol(value v1.Protocol) *ClusterNetworkPolicyProtocolApplyConfiguration { + b.Protocol = &value + return b +} + +// WithPort sets the Port field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Port field is set to the value of the last call. +func (b *ClusterNetworkPolicyProtocolApplyConfiguration) WithPort(value *ClusterNetworkPolicyPortApplyConfiguration) *ClusterNetworkPolicyProtocolApplyConfiguration { + b.Port = value + return b +} diff --git a/pkg/client/applyconfiguration/apis/v1alpha2/portrange.go b/pkg/client/applyconfiguration/apis/v1alpha2/portrange.go index 1accaad9..63521957 100644 --- a/pkg/client/applyconfiguration/apis/v1alpha2/portrange.go +++ b/pkg/client/applyconfiguration/apis/v1alpha2/portrange.go @@ -18,16 +18,11 @@ limitations under the License. package v1alpha2 -import ( - v1 "k8s.io/api/core/v1" -) - // PortRangeApplyConfiguration represents a declarative configuration of the PortRange type for use // with apply. type PortRangeApplyConfiguration struct { - Protocol *v1.Protocol `json:"protocol,omitempty"` - Start *int32 `json:"start,omitempty"` - End *int32 `json:"end,omitempty"` + Start *int32 `json:"start,omitempty"` + End *int32 `json:"end,omitempty"` } // PortRangeApplyConfiguration constructs a declarative configuration of the PortRange type for use with @@ -36,14 +31,6 @@ func PortRange() *PortRangeApplyConfiguration { return &PortRangeApplyConfiguration{} } -// WithProtocol sets the Protocol field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the Protocol field is set to the value of the last call. -func (b *PortRangeApplyConfiguration) WithProtocol(value v1.Protocol) *PortRangeApplyConfiguration { - b.Protocol = &value - return b -} - // WithStart sets the Start field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the Start field is set to the value of the last call. diff --git a/pkg/client/applyconfiguration/utils.go b/pkg/client/applyconfiguration/utils.go index 3a13c94a..8db91783 100644 --- a/pkg/client/applyconfiguration/utils.go +++ b/pkg/client/applyconfiguration/utils.go @@ -84,6 +84,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &apisv1alpha2.ClusterNetworkPolicyIngressRuleApplyConfiguration{} case v1alpha2.SchemeGroupVersion.WithKind("ClusterNetworkPolicyPort"): return &apisv1alpha2.ClusterNetworkPolicyPortApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("ClusterNetworkPolicyProtocol"): + return &apisv1alpha2.ClusterNetworkPolicyProtocolApplyConfiguration{} case v1alpha2.SchemeGroupVersion.WithKind("ClusterNetworkPolicySpec"): return &apisv1alpha2.ClusterNetworkPolicySpecApplyConfiguration{} case v1alpha2.SchemeGroupVersion.WithKind("ClusterNetworkPolicyStatus"): @@ -92,8 +94,6 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &apisv1alpha2.ClusterNetworkPolicySubjectApplyConfiguration{} case v1alpha2.SchemeGroupVersion.WithKind("NamespacedPod"): return &apisv1alpha2.NamespacedPodApplyConfiguration{} - case v1alpha2.SchemeGroupVersion.WithKind("Port"): - return &apisv1alpha2.PortApplyConfiguration{} case v1alpha2.SchemeGroupVersion.WithKind("PortRange"): return &apisv1alpha2.PortRangeApplyConfiguration{}