Skip to content

Commit 6e9cb97

Browse files
committed
temp2
1 parent 75acfa6 commit 6e9cb97

File tree

6 files changed

+28
-16
lines changed

6 files changed

+28
-16
lines changed

apis/v1alpha1/baselineadminnetworkpolicy_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ type BaselineAdminNetworkPolicyEgressRule struct {
163163
// If any AdminNetworkPolicyEgressPeer matches the destination of outgoing
164164
// traffic then the specified action is applied.
165165
// This field must be defined and contain at least one item.
166-
// +kubebuilder:validation:MinItems=1
167-
// +kubebuilder:validation:MaxItems=100
168166
//
169167
// Support: Core
170168
//
169+
// +kubebuilder:validation:MinItems=1
170+
// +kubebuilder:validation:MaxItems=100
171171
To []AdminNetworkPolicyEgressPeer `json:"to"`
172172

173173
// Ports allows for matching traffic based on port and protocols.

apis/v1alpha1/shared_types.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,8 @@ type AdminNetworkPolicyEgressPeer struct {
191191
// <network-policy-api:experimental>
192192
// +optional
193193
// +kubebuilder:validation:MinItems=1
194-
// +kubebuilder:validation:MaxItems=100
195-
// +kubebuilder:validation:XValidation:rule="self.all(x, isCIDR(x))",message="Invalid CIDR provided"
196-
Networks []string `json:"networks,omitempty"`
194+
// +kubebuilder:validation:MaxItems=45
195+
Networks []CIDR `json:"networks,omitempty"`
197196
}
198197

199198
// NamespacedPeer defines a flexible way to select Namespaces in a cluster.
@@ -256,3 +255,8 @@ type NamespacedPodPeer struct {
256255
//
257256
PodSelector metav1.LabelSelector `json:"podSelector"`
258257
}
258+
259+
// +kubebuilder:validation:XValidation:rule="isCIDR(self)",message="Invalid CIDR provided"
260+
// +kubebuilder:validation:MaxLength=48
261+
// Length 48 is taken from: https://elixir.bootlin.com/linux/latest/source/include/linux/inet.h#L50
262+
type CIDR string

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/experimental/policy.networking.k8s.io_adminnetworkpolicies.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,15 @@ spec:
265265
format and should be IPv4 or IPv6, for example \"10.0.0.0/8\"
266266
or \"fd00::/8\". \n Support: Extended \n <network-policy-api:experimental>"
267267
items:
268+
description: 'Length 48 is taken from: https://elixir.bootlin.com/linux/latest/source/include/linux/inet.h#L50'
269+
maxLength: 48
268270
type: string
269-
maxItems: 100
271+
x-kubernetes-validations:
272+
- message: Invalid CIDR provided
273+
rule: isCIDR(self)
274+
maxItems: 45
270275
minItems: 1
271276
type: array
272-
x-kubernetes-validations:
273-
- message: Invalid CIDR provided
274-
rule: self.all(x, isCIDR(x))
275277
nodes:
276278
description: "Nodes defines a way to select a set of nodes
277279
in the cluster. This field follows standard label selector

config/crd/experimental/policy.networking.k8s.io_baselineadminnetworkpolicies.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,15 @@ spec:
257257
format and should be IPv4 or IPv6, for example \"10.0.0.0/8\"
258258
or \"fd00::/8\". \n Support: Extended \n <network-policy-api:experimental>"
259259
items:
260+
description: 'Length 48 is taken from: https://elixir.bootlin.com/linux/latest/source/include/linux/inet.h#L50'
261+
maxLength: 48
260262
type: string
261-
maxItems: 100
263+
x-kubernetes-validations:
264+
- message: Invalid CIDR provided
265+
rule: isCIDR(self)
266+
maxItems: 45
262267
minItems: 1
263268
type: array
264-
x-kubernetes-validations:
265-
- message: Invalid CIDR provided
266-
rule: self.all(x, isCIDR(x))
267269
nodes:
268270
description: "Nodes defines a way to select a set of nodes
269271
in the cluster. This field follows standard label selector

hack/crd-e2e.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ trap cleanup INT TERM
4444
res=0
4545

4646
# Install kind
47-
(go install sigs.k8s.io/kind@v0.21.0) || res=$?
47+
(go install sigs.k8s.io/kind@v0.22.0) || res=$?
4848

4949
# Create cluster
5050
KIND_CREATE_ATTEMPTED=true
51-
kind create cluster --name "${CLUSTER_NAME}" || res=$?
51+
kind create cluster --name "${CLUSTER_NAME}" --image "quay.io/itssurya/dev-images:kindest-node-v1.30.0-alpha.2" || res=$?
5252

5353
for KUST_FOLDER in bases patches; do
5454
go run sigs.k8s.io/controller-tools/cmd/controller-gen rbac:roleName=manager-role crd paths=./apis/... output:crd:dir=./config/crd/bases output:stdout || res=$?
@@ -59,6 +59,10 @@ for KUST_FOLDER in bases patches; do
5959

6060
done
6161

62+
# Only for testing purposes, directly install experimental CRDs as well in the CI cluster
63+
kubectl apply -f ./config/crd/experimental/policy.networking.k8s.io_adminnetworkpolicies.yaml
64+
kubectl apply -f ./config/crd/experimental/policy.networking.k8s.io_baselineadminnetworkpolicies.yaml
65+
6266
# Clean up and exit
6367
cleanup || res=$?
6468
exit $res

0 commit comments

Comments
 (0)