From 831103aa5ccca871324dc9e81d331c40da3770ca Mon Sep 17 00:00:00 2001 From: Dario Tranchitella Date: Thu, 25 May 2023 09:53:08 +0200 Subject: [PATCH] refactor(golint): removing deprecated functions --- api/v1alpha1/conversion_hub.go | 6 +- api/v1alpha1/conversion_hub_test.go | 6 +- api/v1beta2/tenantresource_global.go | 5 +- .../crd/bases/capsule.clastix.io_tenants.yaml | 842 +++++++++--------- controllers/resources/global.go | 2 +- controllers/resources/namespaced.go | 2 +- controllers/resources/processor.go | 2 +- controllers/tls/manager.go | 4 +- e2e/disable_externalname_test.go | 2 +- e2e/disable_loadbalancer_test.go | 2 +- e2e/disable_node_ports_test.go | 2 +- e2e/enable_loadbalancer_test.go | 2 +- e2e/ingress_class_extensions_test.go | 2 +- e2e/ingress_class_networking_test.go | 2 +- e2e/overquota_namespace_test.go | 2 +- e2e/resource_quota_exceeded_test.go | 3 +- e2e/service_metadata_test.go | 8 +- e2e/storage_class_test.go | 2 +- pkg/indexer/ingress/hostname_path.go | 2 +- pkg/indexer/ingress/utils.go | 18 +- pkg/webhook/ingress/types.go | 20 +- pkg/webhook/ingress/validate_hostnames.go | 8 +- 22 files changed, 472 insertions(+), 472 deletions(-) diff --git a/api/v1alpha1/conversion_hub.go b/api/v1alpha1/conversion_hub.go index e482ebb7..1332ff07 100644 --- a/api/v1alpha1/conversion_hub.go +++ b/api/v1alpha1/conversion_hub.go @@ -294,7 +294,7 @@ func (in *Tenant) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.ServiceOptions.AllowedServices = &api.AllowedServices{} } - dst.Spec.ServiceOptions.AllowedServices.NodePort = pointer.BoolPtr(val) + dst.Spec.ServiceOptions.AllowedServices.NodePort = pointer.Bool(val) } enableExternalName, ok := annotations[enableExternalNameAnnotation] @@ -312,7 +312,7 @@ func (in *Tenant) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.ServiceOptions.AllowedServices = &api.AllowedServices{} } - dst.Spec.ServiceOptions.AllowedServices.ExternalName = pointer.BoolPtr(val) + dst.Spec.ServiceOptions.AllowedServices.ExternalName = pointer.Bool(val) } loadBalancerService, ok := annotations[enableLoadBalancerAnnotation] @@ -330,7 +330,7 @@ func (in *Tenant) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.ServiceOptions.AllowedServices = &api.AllowedServices{} } - dst.Spec.ServiceOptions.AllowedServices.LoadBalancer = pointer.BoolPtr(val) + dst.Spec.ServiceOptions.AllowedServices.LoadBalancer = pointer.Bool(val) } // Status dst.Status = capsulev1beta1.TenantStatus{ diff --git a/api/v1alpha1/conversion_hub_test.go b/api/v1alpha1/conversion_hub_test.go index 21c512dc..64a2e369 100644 --- a/api/v1alpha1/conversion_hub_test.go +++ b/api/v1alpha1/conversion_hub_test.go @@ -53,9 +53,9 @@ func generateTenantsSpecs() (Tenant, capsulev1beta1.Tenant) { v1beta1ServiceOptions := &api.ServiceOptions{ AdditionalMetadata: v1beta1AdditionalMetadataSpec, AllowedServices: &api.AllowedServices{ - NodePort: pointer.BoolPtr(false), - ExternalName: pointer.BoolPtr(false), - LoadBalancer: pointer.BoolPtr(false), + NodePort: pointer.Bool(false), + ExternalName: pointer.Bool(false), + LoadBalancer: pointer.Bool(false), }, ExternalServiceIPs: &api.ExternalServiceIPsSpec{ Allowed: []api.AllowedIP{"192.168.0.1"}, diff --git a/api/v1beta2/tenantresource_global.go b/api/v1beta2/tenantresource_global.go index 1feced99..9108e533 100644 --- a/api/v1beta2/tenantresource_global.go +++ b/api/v1beta2/tenantresource_global.go @@ -25,8 +25,9 @@ type GlobalTenantResourceStatus struct { type ProcessedItems []ObjectReferenceStatus -func (p *ProcessedItems) AsSet() sets.String { - set := sets.NewString() +func (p *ProcessedItems) AsSet() sets.Set[string] { + set := sets.New[string]() + for _, i := range *p { set.Insert(i.String()) } diff --git a/config/crd/bases/capsule.clastix.io_tenants.yaml b/config/crd/bases/capsule.clastix.io_tenants.yaml index 6f0977c0..75c54723 100644 --- a/config/crd/bases/capsule.clastix.io_tenants.yaml +++ b/config/crd/bases/capsule.clastix.io_tenants.yaml @@ -245,15 +245,15 @@ spec: description: NetworkPolicySpec provides the specification of a NetworkPolicy properties: egress: - description: List of egress rules to be applied to the selected - pods. Outgoing traffic is allowed if there are no NetworkPolicies - selecting the pod (and cluster policy otherwise allows the - traffic), OR if the traffic matches at least one egress rule - across all of the NetworkPolicy objects whose podSelector - matches the pod. If this field is empty then this NetworkPolicy - limits all outgoing traffic (and serves solely to ensure that - the pods it selects are isolated by default). This field is - beta-level in 1.8 + description: egress is a list of egress rules to be applied + to the selected pods. Outgoing traffic is allowed if there + are no NetworkPolicies selecting the pod (and cluster policy + otherwise allows the traffic), OR if the traffic matches at + least one egress rule across all of the NetworkPolicy objects + whose podSelector matches the pod. If this field is empty + then this NetworkPolicy limits all outgoing traffic (and serves + solely to ensure that the pods it selects are isolated by + default). This field is beta-level in 1.8 items: description: NetworkPolicyEgressRule describes a particular set of traffic that is allowed out of pods matched by a @@ -261,52 +261,51 @@ spec: both ports and to. This type is beta-level in 1.8 properties: ports: - description: List of destination ports for outgoing traffic. - Each item in this list is combined using a logical OR. - If this field is empty or missing, this rule matches - all ports (traffic not restricted by port). If this - field is present and contains at least one item, then - this rule allows traffic only if the traffic matches - at least one port in the list. + description: ports is a list of destination ports for + outgoing traffic. Each item in this list is combined + using a logical OR. If this field is empty or missing, + this rule matches all ports (traffic not restricted + by port). If this field is present and contains at least + one item, then this rule allows traffic only if the + traffic matches at least one port in the list. items: description: NetworkPolicyPort describes a port to allow traffic on properties: endPort: - description: If set, indicates that the range of - ports from port to endPort, inclusive, should - be allowed by the policy. This field cannot be - defined if the port field is not defined or if - the port field is defined as a named (string) + description: endPort indicates that the range of + ports from port to endPort if set, inclusive, + should be allowed by the policy. This field cannot + be defined if the port field is not defined or + if the port field is defined as a named (string) port. The endPort must be equal or greater than - port. This feature is in Beta state and is enabled - by default. It can be disabled using the Feature - Gate "NetworkPolicyEndPort". + port. format: int32 type: integer port: anyOf: - type: integer - type: string - description: The port on the given protocol. This - can either be a numerical or named port on a pod. - If this field is not provided, this matches all - port names and numbers. If present, only traffic - on the specified protocol AND port will be matched. + description: port represents the port on the given + protocol. This can either be a numerical or named + port on a pod. If this field is not provided, + this matches all port names and numbers. If present, + only traffic on the specified protocol AND port + will be matched. x-kubernetes-int-or-string: true protocol: default: TCP - description: The protocol (TCP, UDP, or SCTP) which - traffic must match. If not specified, this field - defaults to TCP. + description: protocol represents the protocol (TCP, + UDP, or SCTP) which traffic must match. If not + specified, this field defaults to TCP. type: string type: object type: array to: - description: List of destinations for outgoing traffic - of pods selected for this rule. Items in this list are - combined using a logical OR operation. If this field - is empty or missing, this rule matches all destinations + description: to is a list of destinations for outgoing + traffic of pods selected for this rule. Items in this + list are combined using a logical OR operation. If this + field is empty or missing, this rule matches all destinations (traffic not restricted by destination). If this field is present and contains at least one item, this rule allows traffic only if the traffic matches at least @@ -317,21 +316,21 @@ spec: are allowed properties: ipBlock: - description: IPBlock defines policy on a particular + description: ipBlock defines policy on a particular IPBlock. If this field is set then neither of the other fields can be. properties: cidr: - description: CIDR is a string representing the - IP Block Valid examples are "192.168.1.1/24" - or "2001:db9::/64" + description: cidr is a string representing the + IPBlock Valid examples are "192.168.1.0/24" + or "2001:db8::/64" type: string except: - description: Except is a slice of CIDRs that - should not be included within an IP Block - Valid examples are "192.168.1.1/24" or "2001:db9::/64" + description: except is a slice of CIDRs that + should not be included within an IPBlock Valid + examples are "192.168.1.0/24" or "2001:db8::/64" Except values will be rejected if they are - outside the CIDR range + outside the cidr range items: type: string type: array @@ -339,14 +338,14 @@ spec: - cidr type: object namespaceSelector: - description: "Selects Namespaces using cluster-scoped - labels. This field follows standard label selector - semantics; if present but empty, it selects all - namespaces. \n If PodSelector is also set, then - the NetworkPolicyPeer as a whole selects the Pods - matching PodSelector in the Namespaces selected - by NamespaceSelector. Otherwise it selects all - Pods in the Namespaces selected by NamespaceSelector." + description: "namespaceSelector selects namespaces + using cluster-scoped labels. This field follows + standard label selector semantics; if present + but empty, it selects all namespaces. \n If podSelector + is also set, then the NetworkPolicyPeer as a whole + selects the pods matching podSelector in the namespaces + selected by namespaceSelector. Otherwise it selects + all pods in the namespaces selected by namespaceSelector." properties: matchExpressions: description: matchExpressions is a list of label @@ -397,15 +396,15 @@ spec: type: object x-kubernetes-map-type: atomic podSelector: - description: "This is a label selector which selects - Pods. This field follows standard label selector - semantics; if present but empty, it selects all - pods. \n If NamespaceSelector is also set, then - the NetworkPolicyPeer as a whole selects the Pods - matching PodSelector in the Namespaces selected - by NamespaceSelector. Otherwise it selects the - Pods matching PodSelector in the policy's own - Namespace." + description: "podSelector is a label selector which + selects pods. This field follows standard label + selector semantics; if present but empty, it selects + all pods. \n If namespaceSelector is also set, + then the NetworkPolicyPeer as a whole selects + the pods matching podSelector in the Namespaces + selected by NamespaceSelector. Otherwise it selects + the pods matching podSelector in the policy's + own namespace." properties: matchExpressions: description: matchExpressions is a list of label @@ -460,15 +459,15 @@ spec: type: object type: array ingress: - description: List of ingress rules to be applied to the selected - pods. Traffic is allowed to a pod if there are no NetworkPolicies - selecting the pod (and cluster policy otherwise allows the - traffic), OR if the traffic source is the pod's local node, - OR if the traffic matches at least one ingress rule across - all of the NetworkPolicy objects whose podSelector matches - the pod. If this field is empty then this NetworkPolicy does - not allow any traffic (and serves solely to ensure that the - pods it selects are isolated by default) + description: ingress is a list of ingress rules to be applied + to the selected pods. Traffic is allowed to a pod if there + are no NetworkPolicies selecting the pod (and cluster policy + otherwise allows the traffic), OR if the traffic source is + the pod's local node, OR if the traffic matches at least one + ingress rule across all of the NetworkPolicy objects whose + podSelector matches the pod. If this field is empty then this + NetworkPolicy does not allow any traffic (and serves solely + to ensure that the pods it selects are isolated by default) items: description: NetworkPolicyIngressRule describes a particular set of traffic that is allowed to the pods matched by a @@ -476,35 +475,35 @@ spec: both ports and from. properties: from: - description: List of sources which should be able to access - the pods selected for this rule. Items in this list - are combined using a logical OR operation. If this field - is empty or missing, this rule matches all sources (traffic - not restricted by source). If this field is present - and contains at least one item, this rule allows traffic - only if the traffic matches at least one item in the - from list. + description: from is a list of sources which should be + able to access the pods selected for this rule. Items + in this list are combined using a logical OR operation. + If this field is empty or missing, this rule matches + all sources (traffic not restricted by source). If this + field is present and contains at least one item, this + rule allows traffic only if the traffic matches at least + one item in the from list. items: description: NetworkPolicyPeer describes a peer to allow traffic to/from. Only certain combinations of fields are allowed properties: ipBlock: - description: IPBlock defines policy on a particular + description: ipBlock defines policy on a particular IPBlock. If this field is set then neither of the other fields can be. properties: cidr: - description: CIDR is a string representing the - IP Block Valid examples are "192.168.1.1/24" - or "2001:db9::/64" + description: cidr is a string representing the + IPBlock Valid examples are "192.168.1.0/24" + or "2001:db8::/64" type: string except: - description: Except is a slice of CIDRs that - should not be included within an IP Block - Valid examples are "192.168.1.1/24" or "2001:db9::/64" + description: except is a slice of CIDRs that + should not be included within an IPBlock Valid + examples are "192.168.1.0/24" or "2001:db8::/64" Except values will be rejected if they are - outside the CIDR range + outside the cidr range items: type: string type: array @@ -512,14 +511,14 @@ spec: - cidr type: object namespaceSelector: - description: "Selects Namespaces using cluster-scoped - labels. This field follows standard label selector - semantics; if present but empty, it selects all - namespaces. \n If PodSelector is also set, then - the NetworkPolicyPeer as a whole selects the Pods - matching PodSelector in the Namespaces selected - by NamespaceSelector. Otherwise it selects all - Pods in the Namespaces selected by NamespaceSelector." + description: "namespaceSelector selects namespaces + using cluster-scoped labels. This field follows + standard label selector semantics; if present + but empty, it selects all namespaces. \n If podSelector + is also set, then the NetworkPolicyPeer as a whole + selects the pods matching podSelector in the namespaces + selected by namespaceSelector. Otherwise it selects + all pods in the namespaces selected by namespaceSelector." properties: matchExpressions: description: matchExpressions is a list of label @@ -570,15 +569,15 @@ spec: type: object x-kubernetes-map-type: atomic podSelector: - description: "This is a label selector which selects - Pods. This field follows standard label selector - semantics; if present but empty, it selects all - pods. \n If NamespaceSelector is also set, then - the NetworkPolicyPeer as a whole selects the Pods - matching PodSelector in the Namespaces selected - by NamespaceSelector. Otherwise it selects the - Pods matching PodSelector in the policy's own - Namespace." + description: "podSelector is a label selector which + selects pods. This field follows standard label + selector semantics; if present but empty, it selects + all pods. \n If namespaceSelector is also set, + then the NetworkPolicyPeer as a whole selects + the pods matching podSelector in the Namespaces + selected by NamespaceSelector. Otherwise it selects + the pods matching podSelector in the policy's + own namespace." properties: matchExpressions: description: matchExpressions is a list of label @@ -631,57 +630,56 @@ spec: type: object type: array ports: - description: List of ports which should be made accessible - on the pods selected for this rule. Each item in this - list is combined using a logical OR. If this field is - empty or missing, this rule matches all ports (traffic - not restricted by port). If this field is present and - contains at least one item, then this rule allows traffic - only if the traffic matches at least one port in the - list. + description: ports is a list of ports which should be + made accessible on the pods selected for this rule. + Each item in this list is combined using a logical OR. + If this field is empty or missing, this rule matches + all ports (traffic not restricted by port). If this + field is present and contains at least one item, then + this rule allows traffic only if the traffic matches + at least one port in the list. items: description: NetworkPolicyPort describes a port to allow traffic on properties: endPort: - description: If set, indicates that the range of - ports from port to endPort, inclusive, should - be allowed by the policy. This field cannot be - defined if the port field is not defined or if - the port field is defined as a named (string) + description: endPort indicates that the range of + ports from port to endPort if set, inclusive, + should be allowed by the policy. This field cannot + be defined if the port field is not defined or + if the port field is defined as a named (string) port. The endPort must be equal or greater than - port. This feature is in Beta state and is enabled - by default. It can be disabled using the Feature - Gate "NetworkPolicyEndPort". + port. format: int32 type: integer port: anyOf: - type: integer - type: string - description: The port on the given protocol. This - can either be a numerical or named port on a pod. - If this field is not provided, this matches all - port names and numbers. If present, only traffic - on the specified protocol AND port will be matched. + description: port represents the port on the given + protocol. This can either be a numerical or named + port on a pod. If this field is not provided, + this matches all port names and numbers. If present, + only traffic on the specified protocol AND port + will be matched. x-kubernetes-int-or-string: true protocol: default: TCP - description: The protocol (TCP, UDP, or SCTP) which - traffic must match. If not specified, this field - defaults to TCP. + description: protocol represents the protocol (TCP, + UDP, or SCTP) which traffic must match. If not + specified, this field defaults to TCP. type: string type: object type: array type: object type: array podSelector: - description: Selects the pods to which this NetworkPolicy object - applies. The array of ingress rules is applied to any pods - selected by this field. Multiple network policies can select - the same set of pods. In this case, the ingress rules for - each are combined additively. This field is NOT optional and - follows standard label selector semantics. An empty podSelector + description: podSelector selects the pods to which this NetworkPolicy + object applies. The array of ingress rules is applied to any + pods selected by this field. Multiple network policies can + select the same set of pods. In this case, the ingress rules + for each are combined additively. This field is NOT optional + and follows standard label selector semantics. An empty podSelector matches all pods in this namespace. properties: matchExpressions: @@ -727,18 +725,18 @@ spec: type: object x-kubernetes-map-type: atomic policyTypes: - description: List of rule types that the NetworkPolicy relates - to. Valid options are ["Ingress"], ["Egress"], or ["Ingress", - "Egress"]. If this field is not specified, it will default - based on the existence of Ingress or Egress rules; policies - that contain an Egress section are assumed to affect Egress, - and all policies (whether or not they contain an Ingress section) - are assumed to affect Ingress. If you want to write an egress-only - policy, you must explicitly specify policyTypes [ "Egress" - ]. Likewise, if you want to write a policy that specifies - that no egress is allowed, you must specify a policyTypes + description: policyTypes is a list of rule types that the NetworkPolicy + relates to. Valid options are ["Ingress"], ["Egress"], or + ["Ingress", "Egress"]. If this field is not specified, it + will default based on the existence of ingress or egress rules; + policies that contain an egress section are assumed to affect + egress, and all policies (whether or not they contain an ingress + section) are assumed to affect ingress. If you want to write + an egress-only policy, you must explicitly specify policyTypes + [ "Egress" ]. Likewise, if you want to write a policy that + specifies that no egress is allowed, you must specify a policyTypes value that include "Egress" (since such a policy would not - include an Egress section and would otherwise default to just + include an egress section and would otherwise default to just [ "Ingress" ]). This field is beta-level in 1.8 items: description: PolicyType string describes the NetworkPolicy @@ -1156,15 +1154,16 @@ spec: a NetworkPolicy properties: egress: - description: List of egress rules to be applied to the selected - pods. Outgoing traffic is allowed if there are no NetworkPolicies - selecting the pod (and cluster policy otherwise allows - the traffic), OR if the traffic matches at least one egress - rule across all of the NetworkPolicy objects whose podSelector - matches the pod. If this field is empty then this NetworkPolicy - limits all outgoing traffic (and serves solely to ensure - that the pods it selects are isolated by default). This - field is beta-level in 1.8 + description: egress is a list of egress rules to be applied + to the selected pods. Outgoing traffic is allowed if there + are no NetworkPolicies selecting the pod (and cluster + policy otherwise allows the traffic), OR if the traffic + matches at least one egress rule across all of the NetworkPolicy + objects whose podSelector matches the pod. If this field + is empty then this NetworkPolicy limits all outgoing traffic + (and serves solely to ensure that the pods it selects + are isolated by default). This field is beta-level in + 1.8 items: description: NetworkPolicyEgressRule describes a particular set of traffic that is allowed out of pods matched by @@ -1173,55 +1172,53 @@ spec: 1.8 properties: ports: - description: List of destination ports for outgoing - traffic. Each item in this list is combined using - a logical OR. If this field is empty or missing, - this rule matches all ports (traffic not restricted - by port). If this field is present and contains - at least one item, then this rule allows traffic - only if the traffic matches at least one port in - the list. + description: ports is a list of destination ports + for outgoing traffic. Each item in this list is + combined using a logical OR. If this field is empty + or missing, this rule matches all ports (traffic + not restricted by port). If this field is present + and contains at least one item, then this rule allows + traffic only if the traffic matches at least one + port in the list. items: description: NetworkPolicyPort describes a port to allow traffic on properties: endPort: - description: If set, indicates that the range - of ports from port to endPort, inclusive, + description: endPort indicates that the range + of ports from port to endPort if set, inclusive, should be allowed by the policy. This field cannot be defined if the port field is not defined or if the port field is defined as a named (string) port. The endPort must be - equal or greater than port. This feature is - in Beta state and is enabled by default. It - can be disabled using the Feature Gate "NetworkPolicyEndPort". + equal or greater than port. format: int32 type: integer port: anyOf: - type: integer - type: string - description: The port on the given protocol. - This can either be a numerical or named port - on a pod. If this field is not provided, this - matches all port names and numbers. If present, - only traffic on the specified protocol AND - port will be matched. + description: port represents the port on the + given protocol. This can either be a numerical + or named port on a pod. If this field is not + provided, this matches all port names and + numbers. If present, only traffic on the specified + protocol AND port will be matched. x-kubernetes-int-or-string: true protocol: default: TCP - description: The protocol (TCP, UDP, or SCTP) - which traffic must match. If not specified, - this field defaults to TCP. + description: protocol represents the protocol + (TCP, UDP, or SCTP) which traffic must match. + If not specified, this field defaults to TCP. type: string type: object type: array to: - description: List of destinations for outgoing traffic - of pods selected for this rule. Items in this list - are combined using a logical OR operation. If this - field is empty or missing, this rule matches all - destinations (traffic not restricted by destination). + description: to is a list of destinations for outgoing + traffic of pods selected for this rule. Items in + this list are combined using a logical OR operation. + If this field is empty or missing, this rule matches + all destinations (traffic not restricted by destination). If this field is present and contains at least one item, this rule allows traffic only if the traffic matches at least one item in the to list. @@ -1231,21 +1228,21 @@ spec: of fields are allowed properties: ipBlock: - description: IPBlock defines policy on a particular + description: ipBlock defines policy on a particular IPBlock. If this field is set then neither of the other fields can be. properties: cidr: - description: CIDR is a string representing - the IP Block Valid examples are "192.168.1.1/24" - or "2001:db9::/64" + description: cidr is a string representing + the IPBlock Valid examples are "192.168.1.0/24" + or "2001:db8::/64" type: string except: - description: Except is a slice of CIDRs + description: except is a slice of CIDRs that should not be included within an - IP Block Valid examples are "192.168.1.1/24" - or "2001:db9::/64" Except values will - be rejected if they are outside the CIDR + IPBlock Valid examples are "192.168.1.0/24" + or "2001:db8::/64" Except values will + be rejected if they are outside the cidr range items: type: string @@ -1254,15 +1251,15 @@ spec: - cidr type: object namespaceSelector: - description: "Selects Namespaces using cluster-scoped - labels. This field follows standard label - selector semantics; if present but empty, - it selects all namespaces. \n If PodSelector - is also set, then the NetworkPolicyPeer as - a whole selects the Pods matching PodSelector - in the Namespaces selected by NamespaceSelector. - Otherwise it selects all Pods in the Namespaces - selected by NamespaceSelector." + description: "namespaceSelector selects namespaces + using cluster-scoped labels. This field follows + standard label selector semantics; if present + but empty, it selects all namespaces. \n If + podSelector is also set, then the NetworkPolicyPeer + as a whole selects the pods matching podSelector + in the namespaces selected by namespaceSelector. + Otherwise it selects all pods in the namespaces + selected by namespaceSelector." properties: matchExpressions: description: matchExpressions is a list @@ -1314,15 +1311,15 @@ spec: type: object x-kubernetes-map-type: atomic podSelector: - description: "This is a label selector which - selects Pods. This field follows standard + description: "podSelector is a label selector + which selects pods. This field follows standard label selector semantics; if present but empty, - it selects all pods. \n If NamespaceSelector + it selects all pods. \n If namespaceSelector is also set, then the NetworkPolicyPeer as - a whole selects the Pods matching PodSelector + a whole selects the pods matching podSelector in the Namespaces selected by NamespaceSelector. - Otherwise it selects the Pods matching PodSelector - in the policy's own Namespace." + Otherwise it selects the pods matching podSelector + in the policy's own namespace." properties: matchExpressions: description: matchExpressions is a list @@ -1378,12 +1375,12 @@ spec: type: object type: array ingress: - description: List of ingress rules to be applied to the - selected pods. Traffic is allowed to a pod if there are - no NetworkPolicies selecting the pod (and cluster policy - otherwise allows the traffic), OR if the traffic source - is the pod's local node, OR if the traffic matches at - least one ingress rule across all of the NetworkPolicy + description: ingress is a list of ingress rules to be applied + to the selected pods. Traffic is allowed to a pod if there + are no NetworkPolicies selecting the pod (and cluster + policy otherwise allows the traffic), OR if the traffic + source is the pod's local node, OR if the traffic matches + at least one ingress rule across all of the NetworkPolicy objects whose podSelector matches the pod. If this field is empty then this NetworkPolicy does not allow any traffic (and serves solely to ensure that the pods it selects @@ -1395,35 +1392,36 @@ spec: match both ports and from. properties: from: - description: List of sources which should be able - to access the pods selected for this rule. Items - in this list are combined using a logical OR operation. - If this field is empty or missing, this rule matches - all sources (traffic not restricted by source). - If this field is present and contains at least one - item, this rule allows traffic only if the traffic - matches at least one item in the from list. + description: from is a list of sources which should + be able to access the pods selected for this rule. + Items in this list are combined using a logical + OR operation. If this field is empty or missing, + this rule matches all sources (traffic not restricted + by source). If this field is present and contains + at least one item, this rule allows traffic only + if the traffic matches at least one item in the + from list. items: description: NetworkPolicyPeer describes a peer to allow traffic to/from. Only certain combinations of fields are allowed properties: ipBlock: - description: IPBlock defines policy on a particular + description: ipBlock defines policy on a particular IPBlock. If this field is set then neither of the other fields can be. properties: cidr: - description: CIDR is a string representing - the IP Block Valid examples are "192.168.1.1/24" - or "2001:db9::/64" + description: cidr is a string representing + the IPBlock Valid examples are "192.168.1.0/24" + or "2001:db8::/64" type: string except: - description: Except is a slice of CIDRs + description: except is a slice of CIDRs that should not be included within an - IP Block Valid examples are "192.168.1.1/24" - or "2001:db9::/64" Except values will - be rejected if they are outside the CIDR + IPBlock Valid examples are "192.168.1.0/24" + or "2001:db8::/64" Except values will + be rejected if they are outside the cidr range items: type: string @@ -1432,15 +1430,15 @@ spec: - cidr type: object namespaceSelector: - description: "Selects Namespaces using cluster-scoped - labels. This field follows standard label - selector semantics; if present but empty, - it selects all namespaces. \n If PodSelector - is also set, then the NetworkPolicyPeer as - a whole selects the Pods matching PodSelector - in the Namespaces selected by NamespaceSelector. - Otherwise it selects all Pods in the Namespaces - selected by NamespaceSelector." + description: "namespaceSelector selects namespaces + using cluster-scoped labels. This field follows + standard label selector semantics; if present + but empty, it selects all namespaces. \n If + podSelector is also set, then the NetworkPolicyPeer + as a whole selects the pods matching podSelector + in the namespaces selected by namespaceSelector. + Otherwise it selects all pods in the namespaces + selected by namespaceSelector." properties: matchExpressions: description: matchExpressions is a list @@ -1492,15 +1490,15 @@ spec: type: object x-kubernetes-map-type: atomic podSelector: - description: "This is a label selector which - selects Pods. This field follows standard + description: "podSelector is a label selector + which selects pods. This field follows standard label selector semantics; if present but empty, - it selects all pods. \n If NamespaceSelector + it selects all pods. \n If namespaceSelector is also set, then the NetworkPolicyPeer as - a whole selects the Pods matching PodSelector + a whole selects the pods matching podSelector in the Namespaces selected by NamespaceSelector. - Otherwise it selects the Pods matching PodSelector - in the policy's own Namespace." + Otherwise it selects the pods matching podSelector + in the policy's own namespace." properties: matchExpressions: description: matchExpressions is a list @@ -1554,59 +1552,59 @@ spec: type: object type: array ports: - description: List of ports which should be made accessible - on the pods selected for this rule. Each item in - this list is combined using a logical OR. If this - field is empty or missing, this rule matches all - ports (traffic not restricted by port). If this - field is present and contains at least one item, - then this rule allows traffic only if the traffic - matches at least one port in the list. + description: ports is a list of ports which should + be made accessible on the pods selected for this + rule. Each item in this list is combined using a + logical OR. If this field is empty or missing, this + rule matches all ports (traffic not restricted by + port). If this field is present and contains at + least one item, then this rule allows traffic only + if the traffic matches at least one port in the + list. items: description: NetworkPolicyPort describes a port to allow traffic on properties: endPort: - description: If set, indicates that the range - of ports from port to endPort, inclusive, + description: endPort indicates that the range + of ports from port to endPort if set, inclusive, should be allowed by the policy. This field cannot be defined if the port field is not defined or if the port field is defined as a named (string) port. The endPort must be - equal or greater than port. This feature is - in Beta state and is enabled by default. It - can be disabled using the Feature Gate "NetworkPolicyEndPort". + equal or greater than port. format: int32 type: integer port: anyOf: - type: integer - type: string - description: The port on the given protocol. - This can either be a numerical or named port - on a pod. If this field is not provided, this - matches all port names and numbers. If present, - only traffic on the specified protocol AND - port will be matched. + description: port represents the port on the + given protocol. This can either be a numerical + or named port on a pod. If this field is not + provided, this matches all port names and + numbers. If present, only traffic on the specified + protocol AND port will be matched. x-kubernetes-int-or-string: true protocol: default: TCP - description: The protocol (TCP, UDP, or SCTP) - which traffic must match. If not specified, - this field defaults to TCP. + description: protocol represents the protocol + (TCP, UDP, or SCTP) which traffic must match. + If not specified, this field defaults to TCP. type: string type: object type: array type: object type: array podSelector: - description: Selects the pods to which this NetworkPolicy - object applies. The array of ingress rules is applied - to any pods selected by this field. Multiple network policies - can select the same set of pods. In this case, the ingress - rules for each are combined additively. This field is - NOT optional and follows standard label selector semantics. - An empty podSelector matches all pods in this namespace. + description: podSelector selects the pods to which this + NetworkPolicy object applies. The array of ingress rules + is applied to any pods selected by this field. Multiple + network policies can select the same set of pods. In this + case, the ingress rules for each are combined additively. + This field is NOT optional and follows standard label + selector semantics. An empty podSelector matches all pods + in this namespace. properties: matchExpressions: description: matchExpressions is a list of label selector @@ -1652,20 +1650,20 @@ spec: type: object x-kubernetes-map-type: atomic policyTypes: - description: List of rule types that the NetworkPolicy relates - to. Valid options are ["Ingress"], ["Egress"], or ["Ingress", - "Egress"]. If this field is not specified, it will default - based on the existence of Ingress or Egress rules; policies - that contain an Egress section are assumed to affect Egress, - and all policies (whether or not they contain an Ingress - section) are assumed to affect Ingress. If you want to - write an egress-only policy, you must explicitly specify - policyTypes [ "Egress" ]. Likewise, if you want to write - a policy that specifies that no egress is allowed, you - must specify a policyTypes value that include "Egress" - (since such a policy would not include an Egress section - and would otherwise default to just [ "Ingress" ]). This - field is beta-level in 1.8 + description: policyTypes is a list of rule types that the + NetworkPolicy relates to. Valid options are ["Ingress"], + ["Egress"], or ["Ingress", "Egress"]. If this field is + not specified, it will default based on the existence + of ingress or egress rules; policies that contain an egress + section are assumed to affect egress, and all policies + (whether or not they contain an ingress section) are assumed + to affect ingress. If you want to write an egress-only + policy, you must explicitly specify policyTypes [ "Egress" + ]. Likewise, if you want to write a policy that specifies + that no egress is allowed, you must specify a policyTypes + value that include "Egress" (since such a policy would + not include an egress section and would otherwise default + to just [ "Ingress" ]). This field is beta-level in 1.8 items: description: PolicyType string describes the NetworkPolicy type This type is beta-level in 1.8 @@ -2277,15 +2275,16 @@ spec: a NetworkPolicy properties: egress: - description: List of egress rules to be applied to the selected - pods. Outgoing traffic is allowed if there are no NetworkPolicies - selecting the pod (and cluster policy otherwise allows - the traffic), OR if the traffic matches at least one egress - rule across all of the NetworkPolicy objects whose podSelector - matches the pod. If this field is empty then this NetworkPolicy - limits all outgoing traffic (and serves solely to ensure - that the pods it selects are isolated by default). This - field is beta-level in 1.8 + description: egress is a list of egress rules to be applied + to the selected pods. Outgoing traffic is allowed if there + are no NetworkPolicies selecting the pod (and cluster + policy otherwise allows the traffic), OR if the traffic + matches at least one egress rule across all of the NetworkPolicy + objects whose podSelector matches the pod. If this field + is empty then this NetworkPolicy limits all outgoing traffic + (and serves solely to ensure that the pods it selects + are isolated by default). This field is beta-level in + 1.8 items: description: NetworkPolicyEgressRule describes a particular set of traffic that is allowed out of pods matched by @@ -2294,55 +2293,53 @@ spec: 1.8 properties: ports: - description: List of destination ports for outgoing - traffic. Each item in this list is combined using - a logical OR. If this field is empty or missing, - this rule matches all ports (traffic not restricted - by port). If this field is present and contains - at least one item, then this rule allows traffic - only if the traffic matches at least one port in - the list. + description: ports is a list of destination ports + for outgoing traffic. Each item in this list is + combined using a logical OR. If this field is empty + or missing, this rule matches all ports (traffic + not restricted by port). If this field is present + and contains at least one item, then this rule allows + traffic only if the traffic matches at least one + port in the list. items: description: NetworkPolicyPort describes a port to allow traffic on properties: endPort: - description: If set, indicates that the range - of ports from port to endPort, inclusive, + description: endPort indicates that the range + of ports from port to endPort if set, inclusive, should be allowed by the policy. This field cannot be defined if the port field is not defined or if the port field is defined as a named (string) port. The endPort must be - equal or greater than port. This feature is - in Beta state and is enabled by default. It - can be disabled using the Feature Gate "NetworkPolicyEndPort". + equal or greater than port. format: int32 type: integer port: anyOf: - type: integer - type: string - description: The port on the given protocol. - This can either be a numerical or named port - on a pod. If this field is not provided, this - matches all port names and numbers. If present, - only traffic on the specified protocol AND - port will be matched. + description: port represents the port on the + given protocol. This can either be a numerical + or named port on a pod. If this field is not + provided, this matches all port names and + numbers. If present, only traffic on the specified + protocol AND port will be matched. x-kubernetes-int-or-string: true protocol: default: TCP - description: The protocol (TCP, UDP, or SCTP) - which traffic must match. If not specified, - this field defaults to TCP. + description: protocol represents the protocol + (TCP, UDP, or SCTP) which traffic must match. + If not specified, this field defaults to TCP. type: string type: object type: array to: - description: List of destinations for outgoing traffic - of pods selected for this rule. Items in this list - are combined using a logical OR operation. If this - field is empty or missing, this rule matches all - destinations (traffic not restricted by destination). + description: to is a list of destinations for outgoing + traffic of pods selected for this rule. Items in + this list are combined using a logical OR operation. + If this field is empty or missing, this rule matches + all destinations (traffic not restricted by destination). If this field is present and contains at least one item, this rule allows traffic only if the traffic matches at least one item in the to list. @@ -2352,21 +2349,21 @@ spec: of fields are allowed properties: ipBlock: - description: IPBlock defines policy on a particular + description: ipBlock defines policy on a particular IPBlock. If this field is set then neither of the other fields can be. properties: cidr: - description: CIDR is a string representing - the IP Block Valid examples are "192.168.1.1/24" - or "2001:db9::/64" + description: cidr is a string representing + the IPBlock Valid examples are "192.168.1.0/24" + or "2001:db8::/64" type: string except: - description: Except is a slice of CIDRs + description: except is a slice of CIDRs that should not be included within an - IP Block Valid examples are "192.168.1.1/24" - or "2001:db9::/64" Except values will - be rejected if they are outside the CIDR + IPBlock Valid examples are "192.168.1.0/24" + or "2001:db8::/64" Except values will + be rejected if they are outside the cidr range items: type: string @@ -2375,15 +2372,15 @@ spec: - cidr type: object namespaceSelector: - description: "Selects Namespaces using cluster-scoped - labels. This field follows standard label - selector semantics; if present but empty, - it selects all namespaces. \n If PodSelector - is also set, then the NetworkPolicyPeer as - a whole selects the Pods matching PodSelector - in the Namespaces selected by NamespaceSelector. - Otherwise it selects all Pods in the Namespaces - selected by NamespaceSelector." + description: "namespaceSelector selects namespaces + using cluster-scoped labels. This field follows + standard label selector semantics; if present + but empty, it selects all namespaces. \n If + podSelector is also set, then the NetworkPolicyPeer + as a whole selects the pods matching podSelector + in the namespaces selected by namespaceSelector. + Otherwise it selects all pods in the namespaces + selected by namespaceSelector." properties: matchExpressions: description: matchExpressions is a list @@ -2435,15 +2432,15 @@ spec: type: object x-kubernetes-map-type: atomic podSelector: - description: "This is a label selector which - selects Pods. This field follows standard + description: "podSelector is a label selector + which selects pods. This field follows standard label selector semantics; if present but empty, - it selects all pods. \n If NamespaceSelector + it selects all pods. \n If namespaceSelector is also set, then the NetworkPolicyPeer as - a whole selects the Pods matching PodSelector + a whole selects the pods matching podSelector in the Namespaces selected by NamespaceSelector. - Otherwise it selects the Pods matching PodSelector - in the policy's own Namespace." + Otherwise it selects the pods matching podSelector + in the policy's own namespace." properties: matchExpressions: description: matchExpressions is a list @@ -2499,12 +2496,12 @@ spec: type: object type: array ingress: - description: List of ingress rules to be applied to the - selected pods. Traffic is allowed to a pod if there are - no NetworkPolicies selecting the pod (and cluster policy - otherwise allows the traffic), OR if the traffic source - is the pod's local node, OR if the traffic matches at - least one ingress rule across all of the NetworkPolicy + description: ingress is a list of ingress rules to be applied + to the selected pods. Traffic is allowed to a pod if there + are no NetworkPolicies selecting the pod (and cluster + policy otherwise allows the traffic), OR if the traffic + source is the pod's local node, OR if the traffic matches + at least one ingress rule across all of the NetworkPolicy objects whose podSelector matches the pod. If this field is empty then this NetworkPolicy does not allow any traffic (and serves solely to ensure that the pods it selects @@ -2516,35 +2513,36 @@ spec: match both ports and from. properties: from: - description: List of sources which should be able - to access the pods selected for this rule. Items - in this list are combined using a logical OR operation. - If this field is empty or missing, this rule matches - all sources (traffic not restricted by source). - If this field is present and contains at least one - item, this rule allows traffic only if the traffic - matches at least one item in the from list. + description: from is a list of sources which should + be able to access the pods selected for this rule. + Items in this list are combined using a logical + OR operation. If this field is empty or missing, + this rule matches all sources (traffic not restricted + by source). If this field is present and contains + at least one item, this rule allows traffic only + if the traffic matches at least one item in the + from list. items: description: NetworkPolicyPeer describes a peer to allow traffic to/from. Only certain combinations of fields are allowed properties: ipBlock: - description: IPBlock defines policy on a particular + description: ipBlock defines policy on a particular IPBlock. If this field is set then neither of the other fields can be. properties: cidr: - description: CIDR is a string representing - the IP Block Valid examples are "192.168.1.1/24" - or "2001:db9::/64" + description: cidr is a string representing + the IPBlock Valid examples are "192.168.1.0/24" + or "2001:db8::/64" type: string except: - description: Except is a slice of CIDRs + description: except is a slice of CIDRs that should not be included within an - IP Block Valid examples are "192.168.1.1/24" - or "2001:db9::/64" Except values will - be rejected if they are outside the CIDR + IPBlock Valid examples are "192.168.1.0/24" + or "2001:db8::/64" Except values will + be rejected if they are outside the cidr range items: type: string @@ -2553,15 +2551,15 @@ spec: - cidr type: object namespaceSelector: - description: "Selects Namespaces using cluster-scoped - labels. This field follows standard label - selector semantics; if present but empty, - it selects all namespaces. \n If PodSelector - is also set, then the NetworkPolicyPeer as - a whole selects the Pods matching PodSelector - in the Namespaces selected by NamespaceSelector. - Otherwise it selects all Pods in the Namespaces - selected by NamespaceSelector." + description: "namespaceSelector selects namespaces + using cluster-scoped labels. This field follows + standard label selector semantics; if present + but empty, it selects all namespaces. \n If + podSelector is also set, then the NetworkPolicyPeer + as a whole selects the pods matching podSelector + in the namespaces selected by namespaceSelector. + Otherwise it selects all pods in the namespaces + selected by namespaceSelector." properties: matchExpressions: description: matchExpressions is a list @@ -2613,15 +2611,15 @@ spec: type: object x-kubernetes-map-type: atomic podSelector: - description: "This is a label selector which - selects Pods. This field follows standard + description: "podSelector is a label selector + which selects pods. This field follows standard label selector semantics; if present but empty, - it selects all pods. \n If NamespaceSelector + it selects all pods. \n If namespaceSelector is also set, then the NetworkPolicyPeer as - a whole selects the Pods matching PodSelector + a whole selects the pods matching podSelector in the Namespaces selected by NamespaceSelector. - Otherwise it selects the Pods matching PodSelector - in the policy's own Namespace." + Otherwise it selects the pods matching podSelector + in the policy's own namespace." properties: matchExpressions: description: matchExpressions is a list @@ -2675,59 +2673,59 @@ spec: type: object type: array ports: - description: List of ports which should be made accessible - on the pods selected for this rule. Each item in - this list is combined using a logical OR. If this - field is empty or missing, this rule matches all - ports (traffic not restricted by port). If this - field is present and contains at least one item, - then this rule allows traffic only if the traffic - matches at least one port in the list. + description: ports is a list of ports which should + be made accessible on the pods selected for this + rule. Each item in this list is combined using a + logical OR. If this field is empty or missing, this + rule matches all ports (traffic not restricted by + port). If this field is present and contains at + least one item, then this rule allows traffic only + if the traffic matches at least one port in the + list. items: description: NetworkPolicyPort describes a port to allow traffic on properties: endPort: - description: If set, indicates that the range - of ports from port to endPort, inclusive, + description: endPort indicates that the range + of ports from port to endPort if set, inclusive, should be allowed by the policy. This field cannot be defined if the port field is not defined or if the port field is defined as a named (string) port. The endPort must be - equal or greater than port. This feature is - in Beta state and is enabled by default. It - can be disabled using the Feature Gate "NetworkPolicyEndPort". + equal or greater than port. format: int32 type: integer port: anyOf: - type: integer - type: string - description: The port on the given protocol. - This can either be a numerical or named port - on a pod. If this field is not provided, this - matches all port names and numbers. If present, - only traffic on the specified protocol AND - port will be matched. + description: port represents the port on the + given protocol. This can either be a numerical + or named port on a pod. If this field is not + provided, this matches all port names and + numbers. If present, only traffic on the specified + protocol AND port will be matched. x-kubernetes-int-or-string: true protocol: default: TCP - description: The protocol (TCP, UDP, or SCTP) - which traffic must match. If not specified, - this field defaults to TCP. + description: protocol represents the protocol + (TCP, UDP, or SCTP) which traffic must match. + If not specified, this field defaults to TCP. type: string type: object type: array type: object type: array podSelector: - description: Selects the pods to which this NetworkPolicy - object applies. The array of ingress rules is applied - to any pods selected by this field. Multiple network policies - can select the same set of pods. In this case, the ingress - rules for each are combined additively. This field is - NOT optional and follows standard label selector semantics. - An empty podSelector matches all pods in this namespace. + description: podSelector selects the pods to which this + NetworkPolicy object applies. The array of ingress rules + is applied to any pods selected by this field. Multiple + network policies can select the same set of pods. In this + case, the ingress rules for each are combined additively. + This field is NOT optional and follows standard label + selector semantics. An empty podSelector matches all pods + in this namespace. properties: matchExpressions: description: matchExpressions is a list of label selector @@ -2773,20 +2771,20 @@ spec: type: object x-kubernetes-map-type: atomic policyTypes: - description: List of rule types that the NetworkPolicy relates - to. Valid options are ["Ingress"], ["Egress"], or ["Ingress", - "Egress"]. If this field is not specified, it will default - based on the existence of Ingress or Egress rules; policies - that contain an Egress section are assumed to affect Egress, - and all policies (whether or not they contain an Ingress - section) are assumed to affect Ingress. If you want to - write an egress-only policy, you must explicitly specify - policyTypes [ "Egress" ]. Likewise, if you want to write - a policy that specifies that no egress is allowed, you - must specify a policyTypes value that include "Egress" - (since such a policy would not include an Egress section - and would otherwise default to just [ "Ingress" ]). This - field is beta-level in 1.8 + description: policyTypes is a list of rule types that the + NetworkPolicy relates to. Valid options are ["Ingress"], + ["Egress"], or ["Ingress", "Egress"]. If this field is + not specified, it will default based on the existence + of ingress or egress rules; policies that contain an egress + section are assumed to affect egress, and all policies + (whether or not they contain an ingress section) are assumed + to affect ingress. If you want to write an egress-only + policy, you must explicitly specify policyTypes [ "Egress" + ]. Likewise, if you want to write a policy that specifies + that no egress is allowed, you must specify a policyTypes + value that include "Egress" (since such a policy would + not include an egress section and would otherwise default + to just [ "Ingress" ]). This field is beta-level in 1.8 items: description: PolicyType string describes the NetworkPolicy type This type is beta-level in 1.8 diff --git a/controllers/resources/global.go b/controllers/resources/global.go index 70725720..6bcaaa93 100644 --- a/controllers/resources/global.go +++ b/controllers/resources/global.go @@ -174,7 +174,7 @@ func (r *Global) reconcileNormal(ctx context.Context, tntResource *capsulev1beta return reconcile.Result{}, err } - if r.processor.HandlePruning(ctx, tntResource.Status.ProcessedItems.AsSet(), processedItems) { + if r.processor.HandlePruning(ctx, tntResource.Status.ProcessedItems.AsSet(), sets.Set[string](processedItems)) { tntResource.Status.ProcessedItems = make([]capsulev1beta2.ObjectReferenceStatus, 0, len(processedItems)) for _, item := range processedItems.List() { diff --git a/controllers/resources/namespaced.go b/controllers/resources/namespaced.go index 68e6c03f..e9b0ae80 100644 --- a/controllers/resources/namespaced.go +++ b/controllers/resources/namespaced.go @@ -132,7 +132,7 @@ func (r *Namespaced) reconcileNormal(ctx context.Context, tntResource *capsulev1 return reconcile.Result{}, err } - if r.processor.HandlePruning(ctx, tntResource.Status.ProcessedItems.AsSet(), processedItems) { + if r.processor.HandlePruning(ctx, tntResource.Status.ProcessedItems.AsSet(), sets.Set[string](processedItems)) { tntResource.Status.ProcessedItems = make([]capsulev1beta2.ObjectReferenceStatus, 0, len(processedItems)) for _, item := range processedItems.List() { diff --git a/controllers/resources/processor.go b/controllers/resources/processor.go index 37388c49..0ebd5b71 100644 --- a/controllers/resources/processor.go +++ b/controllers/resources/processor.go @@ -34,7 +34,7 @@ type Processor struct { client client.Client } -func (r *Processor) HandlePruning(ctx context.Context, current, desired sets.String) (updateStatus bool) { +func (r *Processor) HandlePruning(ctx context.Context, current, desired sets.Set[string]) (updateStatus bool) { log := ctrllog.FromContext(ctx) diff := current.Difference(desired) diff --git a/controllers/tls/manager.go b/controllers/tls/manager.go index 9a043f1c..f788e360 100644 --- a/controllers/tls/manager.go +++ b/controllers/tls/manager.go @@ -234,8 +234,8 @@ func (r *Reconciler) updateTenantCustomResourceDefinition(ctx context.Context, n Service: &apiextensionsv1.ServiceReference{ Namespace: r.Namespace, Name: "capsule-webhook-service", - Path: pointer.StringPtr("/convert"), - Port: pointer.Int32Ptr(443), + Path: pointer.String("/convert"), + Port: pointer.Int32(443), }, CABundle: caBundle, }, diff --git a/e2e/disable_externalname_test.go b/e2e/disable_externalname_test.go index a8b4e6fe..83f594c4 100644 --- a/e2e/disable_externalname_test.go +++ b/e2e/disable_externalname_test.go @@ -33,7 +33,7 @@ var _ = Describe("creating an ExternalName service when it is disabled for Tenan }, ServiceOptions: &api.ServiceOptions{ AllowedServices: &api.AllowedServices{ - ExternalName: pointer.BoolPtr(false), + ExternalName: pointer.Bool(false), }, }, }, diff --git a/e2e/disable_loadbalancer_test.go b/e2e/disable_loadbalancer_test.go index 29cfdc35..4beb160f 100644 --- a/e2e/disable_loadbalancer_test.go +++ b/e2e/disable_loadbalancer_test.go @@ -33,7 +33,7 @@ var _ = Describe("creating a LoadBalancer service when it is disabled for Tenant }, ServiceOptions: &api.ServiceOptions{ AllowedServices: &api.AllowedServices{ - LoadBalancer: pointer.BoolPtr(false), + LoadBalancer: pointer.Bool(false), }, }, }, diff --git a/e2e/disable_node_ports_test.go b/e2e/disable_node_ports_test.go index 10f670d6..b55b6a52 100644 --- a/e2e/disable_node_ports_test.go +++ b/e2e/disable_node_ports_test.go @@ -33,7 +33,7 @@ var _ = Describe("creating a nodePort service when it is disabled for Tenant", f }, ServiceOptions: &api.ServiceOptions{ AllowedServices: &api.AllowedServices{ - NodePort: pointer.BoolPtr(false), + NodePort: pointer.Bool(false), }, }, }, diff --git a/e2e/enable_loadbalancer_test.go b/e2e/enable_loadbalancer_test.go index 8990e162..18ffeea1 100644 --- a/e2e/enable_loadbalancer_test.go +++ b/e2e/enable_loadbalancer_test.go @@ -33,7 +33,7 @@ var _ = Describe("creating a LoadBalancer service when it is enabled for Tenant" }, ServiceOptions: &api.ServiceOptions{ AllowedServices: &api.AllowedServices{ - LoadBalancer: pointer.BoolPtr(true), + LoadBalancer: pointer.Bool(true), }, }, }, diff --git a/e2e/ingress_class_extensions_test.go b/e2e/ingress_class_extensions_test.go index 71b912be..af601e7f 100644 --- a/e2e/ingress_class_extensions_test.go +++ b/e2e/ingress_class_extensions_test.go @@ -135,7 +135,7 @@ var _ = Describe("when Tenant handles Ingress classes with extensions/v1beta1", Name: "denied-ingress", }, Spec: extensionsv1beta1.IngressSpec{ - IngressClassName: pointer.StringPtr("the-worst-ingress-available"), + IngressClassName: pointer.String("the-worst-ingress-available"), Backend: &extensionsv1beta1.IngressBackend{ ServiceName: "foo", ServicePort: intstr.FromInt(8080), diff --git a/e2e/ingress_class_networking_test.go b/e2e/ingress_class_networking_test.go index 99e19118..35f5ab05 100644 --- a/e2e/ingress_class_networking_test.go +++ b/e2e/ingress_class_networking_test.go @@ -222,7 +222,7 @@ var _ = Describe("when Tenant handles Ingress classes with networking.k8s.io/v1" Name: "denied-ingress", }, Spec: networkingv1.IngressSpec{ - IngressClassName: pointer.StringPtr("the-worst-ingress-available"), + IngressClassName: pointer.String("the-worst-ingress-available"), DefaultBackend: &networkingv1.IngressBackend{ Service: &networkingv1.IngressServiceBackend{ Name: "foo", diff --git a/e2e/overquota_namespace_test.go b/e2e/overquota_namespace_test.go index ab064b61..15a374f2 100644 --- a/e2e/overquota_namespace_test.go +++ b/e2e/overquota_namespace_test.go @@ -29,7 +29,7 @@ var _ = Describe("creating a Namespace in over-quota of three", func() { }, }, NamespaceOptions: &capsulev1beta2.NamespaceOptions{ - Quota: pointer.Int32Ptr(3), + Quota: pointer.Int32(3), }, }, } diff --git a/e2e/resource_quota_exceeded_test.go b/e2e/resource_quota_exceeded_test.go index 18e359f8..6b84a2d0 100644 --- a/e2e/resource_quota_exceeded_test.go +++ b/e2e/resource_quota_exceeded_test.go @@ -8,6 +8,7 @@ package e2e import ( "context" "fmt" + "github.com/clastix/capsule/pkg/api" . "github.com/onsi/ginkgo" @@ -134,7 +135,7 @@ var _ = Describe("exceeding a Tenant resource quota", func() { Name: "my-pause", }, Spec: appsv1.DeploymentSpec{ - Replicas: pointer.Int32Ptr(5), + Replicas: pointer.Int32(5), Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{ "app": "pause", diff --git a/e2e/service_metadata_test.go b/e2e/service_metadata_test.go index f9611dae..0db3959e 100644 --- a/e2e/service_metadata_test.go +++ b/e2e/service_metadata_test.go @@ -272,8 +272,8 @@ var _ = Describe("adding metadata to Service objects", func() { }, Ports: []discoveryv1beta1.EndpointPort{ { - Name: pointer.StringPtr("foo"), - Port: pointer.Int32Ptr(9999), + Name: pointer.String("foo"), + Port: pointer.Int32(9999), }, }, } @@ -291,8 +291,8 @@ var _ = Describe("adding metadata to Service objects", func() { }, Ports: []discoveryv1.EndpointPort{ { - Name: pointer.StringPtr("foo"), - Port: pointer.Int32Ptr(9999), + Name: pointer.String("foo"), + Port: pointer.Int32(9999), }, }, } diff --git a/e2e/storage_class_test.go b/e2e/storage_class_test.go index d40d81df..4a7c1016 100644 --- a/e2e/storage_class_test.go +++ b/e2e/storage_class_test.go @@ -236,7 +236,7 @@ var _ = Describe("when Tenant handles Storage classes", func() { Name: c, }, Spec: corev1.PersistentVolumeClaimSpec{ - StorageClassName: pointer.StringPtr(c), + StorageClassName: pointer.String(c), AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}, Resources: corev1.ResourceRequirements{ Requests: map[corev1.ResourceName]resource.Quantity{ diff --git a/pkg/indexer/ingress/hostname_path.go b/pkg/indexer/ingress/hostname_path.go index 2858614a..e717d0ea 100644 --- a/pkg/indexer/ingress/hostname_path.go +++ b/pkg/indexer/ingress/hostname_path.go @@ -33,7 +33,7 @@ func (s HostnamePath) Field() string { func (s HostnamePath) Func() client.IndexerFunc { return func(object client.Object) (entries []string) { - hostPathMap := make(map[string]sets.String) + hostPathMap := make(map[string]sets.Set[string]) switch ing := object.(type) { case *networkingv1.Ingress: diff --git a/pkg/indexer/ingress/utils.go b/pkg/indexer/ingress/utils.go index fa008f92..a4c893e3 100644 --- a/pkg/indexer/ingress/utils.go +++ b/pkg/indexer/ingress/utils.go @@ -10,8 +10,8 @@ import ( "k8s.io/apimachinery/pkg/util/sets" ) -func hostPathMapForExtensionsV1Beta1(ing *extensionsv1beta1.Ingress) map[string]sets.String { - hostPathMap := make(map[string]sets.String) +func hostPathMapForExtensionsV1Beta1(ing *extensionsv1beta1.Ingress) map[string]sets.Set[string] { + hostPathMap := make(map[string]sets.Set[string]) for _, r := range ing.Spec.Rules { if r.HTTP == nil { @@ -19,7 +19,7 @@ func hostPathMapForExtensionsV1Beta1(ing *extensionsv1beta1.Ingress) map[string] } if _, ok := hostPathMap[r.Host]; !ok { - hostPathMap[r.Host] = sets.NewString() + hostPathMap[r.Host] = sets.New[string]() } for _, path := range r.HTTP.Paths { @@ -30,8 +30,8 @@ func hostPathMapForExtensionsV1Beta1(ing *extensionsv1beta1.Ingress) map[string] return hostPathMap } -func hostPathMapForNetworkingV1Beta1(ing *networkingv1beta1.Ingress) map[string]sets.String { - hostPathMap := make(map[string]sets.String) +func hostPathMapForNetworkingV1Beta1(ing *networkingv1beta1.Ingress) map[string]sets.Set[string] { + hostPathMap := make(map[string]sets.Set[string]) for _, r := range ing.Spec.Rules { if r.HTTP == nil { @@ -39,7 +39,7 @@ func hostPathMapForNetworkingV1Beta1(ing *networkingv1beta1.Ingress) map[string] } if _, ok := hostPathMap[r.Host]; !ok { - hostPathMap[r.Host] = sets.NewString() + hostPathMap[r.Host] = sets.New[string]() } for _, path := range r.HTTP.Paths { @@ -50,8 +50,8 @@ func hostPathMapForNetworkingV1Beta1(ing *networkingv1beta1.Ingress) map[string] return hostPathMap } -func hostPathMapForNetworkingV1(ing *networkingv1.Ingress) map[string]sets.String { - hostPathMap := make(map[string]sets.String) +func hostPathMapForNetworkingV1(ing *networkingv1.Ingress) map[string]sets.Set[string] { + hostPathMap := make(map[string]sets.Set[string]) for _, r := range ing.Spec.Rules { if r.HTTP == nil { @@ -59,7 +59,7 @@ func hostPathMapForNetworkingV1(ing *networkingv1.Ingress) map[string]sets.Strin } if _, ok := hostPathMap[r.Host]; !ok { - hostPathMap[r.Host] = sets.NewString() + hostPathMap[r.Host] = sets.New[string]() } for _, path := range r.HTTP.Paths { diff --git a/pkg/webhook/ingress/types.go b/pkg/webhook/ingress/types.go index 3bf84eb0..63857491 100644 --- a/pkg/webhook/ingress/types.go +++ b/pkg/webhook/ingress/types.go @@ -20,7 +20,7 @@ type Ingress interface { IngressClass() *string Namespace() string Name() string - HostnamePathsPairs() map[string]sets.String + HostnamePathsPairs() map[string]sets.Set[string] SetIngressClass(string) SetNamespace(string) } @@ -69,14 +69,14 @@ func (n NetworkingV1) SetNamespace(ns string) { } //nolint:dupl -func (n NetworkingV1) HostnamePathsPairs() (pairs map[string]sets.String) { - pairs = make(map[string]sets.String) +func (n NetworkingV1) HostnamePathsPairs() (pairs map[string]sets.Set[string]) { + pairs = make(map[string]sets.Set[string]) for _, rule := range n.Spec.Rules { host := rule.Host if _, ok := pairs[host]; !ok { - pairs[host] = sets.NewString() + pairs[host] = sets.New[string]() } if http := rule.IngressRuleValue.HTTP; http != nil { @@ -139,14 +139,14 @@ func (n NetworkingV1Beta1) SetNamespace(ns string) { } //nolint:dupl -func (n NetworkingV1Beta1) HostnamePathsPairs() (pairs map[string]sets.String) { - pairs = make(map[string]sets.String) +func (n NetworkingV1Beta1) HostnamePathsPairs() (pairs map[string]sets.Set[string]) { + pairs = make(map[string]sets.Set[string]) for _, rule := range n.Spec.Rules { host := rule.Host if _, ok := pairs[host]; !ok { - pairs[host] = sets.NewString() + pairs[host] = sets.New[string]() } if http := rule.IngressRuleValue.HTTP; http != nil { @@ -207,14 +207,14 @@ func (e Extension) Namespace() string { } //nolint:dupl -func (e Extension) HostnamePathsPairs() (pairs map[string]sets.String) { - pairs = make(map[string]sets.String) +func (e Extension) HostnamePathsPairs() (pairs map[string]sets.Set[string]) { + pairs = make(map[string]sets.Set[string]) for _, rule := range e.Spec.Rules { host := rule.Host if _, ok := pairs[host]; !ok { - pairs[host] = sets.NewString() + pairs[host] = sets.New[string]() } if http := rule.IngressRuleValue.HTTP; http != nil { diff --git a/pkg/webhook/ingress/validate_hostnames.go b/pkg/webhook/ingress/validate_hostnames.go index c854953e..9975f3b1 100644 --- a/pkg/webhook/ingress/validate_hostnames.go +++ b/pkg/webhook/ingress/validate_hostnames.go @@ -63,7 +63,7 @@ func (r *hostnames) validate(ctx context.Context, client client.Client, req admi return nil } - hostnameList := sets.NewString() + hostnameList := sets.New[string]() for hostname := range ingress.HostnamePathsPairs() { hostnameList.Insert(hostname) } @@ -85,20 +85,20 @@ func (r *hostnames) validate(ctx context.Context, client client.Client, req admi return utils.ErroredResponse(err) } -func (r *hostnames) validateHostnames(tenant capsulev1beta2.Tenant, hostnames sets.String) error { +func (r *hostnames) validateHostnames(tenant capsulev1beta2.Tenant, hostnames sets.Set[string]) error { if tenant.Spec.IngressOptions.AllowedHostnames == nil { return nil } var valid, matched bool - tenantHostnameSet := sets.NewString(tenant.Spec.IngressOptions.AllowedHostnames.Exact...) + tenantHostnameSet := sets.New[string](tenant.Spec.IngressOptions.AllowedHostnames.Exact...) var invalidHostnames []string if len(hostnames) > 0 { if diff := hostnames.Difference(tenantHostnameSet); len(diff) > 0 { - invalidHostnames = append(invalidHostnames, diff.List()...) + invalidHostnames = append(invalidHostnames, diff.UnsortedList()...) } if len(invalidHostnames) == 0 {