Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ inputs:

expression: |
nads.items.all(n,
!has(n.spec) ||
!has(n.spec.config) ||
n.spec.config == "" ||
!("type" in parseJSON(n.spec.config)) ||
parseJSON(n.spec.config).type != "bridge" ||
("macspoofchk" in parseJSON(n.spec.config) && parseJSON(n.spec.config).macspoofchk == true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,29 @@ cases:
spec:
config: '{"cniVersion": "0.3.1", "type": "bridge", "bridge": "br3",
"macspoofchk": false}'
- name: NAD with no spec at all is compliant (regression - istio-cni style)
expect: true
inputs:
nads:
apiVersion: v1
kind: List
items:
- apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
name: istio-cni
namespace: default
- name: NAD with an empty-string config is compliant (regression - parseJSON(""))
expect: true
inputs:
nads:
apiVersion: v1
kind: List
items:
- apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
name: empty-config
namespace: default
spec:
config: ""
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ inputs:

expression: |
nads.items.all(n,
!has(n.spec) ||
!has(n.spec.config) ||
n.spec.config == "" ||
!("topology" in parseJSON(n.spec.config)) ||
parseJSON(n.spec.config).topology != "localnet" ||
("vlanID" in parseJSON(n.spec.config) && parseJSON(n.spec.config).vlanID > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,29 @@ cases:
spec:
config: '{"cniVersion": "0.3.1", "type": "ovn-k8s-cni-overlay", "topology":
"localnet", "netAttachDefName": "default/localnet-untagged"}'
- name: NAD with no spec at all is compliant (regression - istio-cni style)
expect: true
inputs:
nads:
apiVersion: v1
kind: List
items:
- apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
name: istio-cni
namespace: default
- name: NAD with an empty-string config is compliant (regression - parseJSON(""))
expect: true
inputs:
nads:
apiVersion: v1
kind: List
items:
- apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
name: empty-config
namespace: default
spec:
config: ""
Loading