File tree Expand file tree Collapse file tree 6 files changed +105
-0
lines changed
Expand file tree Collapse file tree 6 files changed +105
-0
lines changed Original file line number Diff line number Diff line change 1+ # Diffs:
2+ # Compliance messages:
3+ NonCompliant; violation - Error parsing object-templates-raw YAML: error converting YAML to JSON: yaml: unknown anchor 'odd' referenced
Original file line number Diff line number Diff line change 1+ apiVersion : policy.open-cluster-management.io/v1
2+ kind : ConfigurationPolicy
3+ metadata :
4+ name : invalid-otr-yaml
5+ spec :
6+ remediationAction : inform
7+ severity : low
8+ namespaceSelector :
9+ include : ["default"]
10+ object-templates-raw : |
11+ - complianceType: musthave
12+ objectDefinition:
13+ apiVersion: v1
14+ kind: ConfigMap
15+ metadata:
16+ name: sample
17+ namespace: default
18+ data:
19+ something: *odd
20+ another: valid
Original file line number Diff line number Diff line change 1+ // Copyright (c) 2025 Red Hat, Inc.
2+ // Copyright Contributors to the Open Cluster Management project
3+
4+ package dryruntest
5+
6+ import (
7+ "embed"
8+ "testing"
9+
10+ "open-cluster-management.io/config-policy-controller/test/dryrun"
11+ )
12+
13+ //go:embed invalid_yaml/*
14+ var invalidObjectTemplatesRaw embed.FS
15+
16+ //go:embed range/*
17+ var rangeObjectTemplatesRaw embed.FS
18+
19+ func TestInvalidObjectTemplatesRaw (t * testing.T ) {
20+ t .Run ("Test noncompliant with invalid YAML in object-templates-raw" ,
21+ dryrun .Run (invalidObjectTemplatesRaw ))
22+ }
23+
24+ func TestRangeObjectTemplatesRaw (t * testing.T ) {
25+ t .Run ("Test compliant with range in object-templates-raw" ,
26+ dryrun .Run (rangeObjectTemplatesRaw ))
27+ }
Original file line number Diff line number Diff line change 1+ apiVersion : v1
2+ kind : Pod
3+ metadata :
4+ namespace : default
5+ name : nginx-pod-1
6+ spec :
7+ containers :
8+ - image : nginx:1.7.9
9+ name : nginx
10+ ports :
11+ - containerPort : 80
12+ ---
13+ apiVersion : v1
14+ kind : Pod
15+ metadata :
16+ namespace : default
17+ name : nginx-pod-2
18+ spec :
19+ containers :
20+ - image : nginx:1.7.9
21+ name : nginx
22+ ports :
23+ - containerPort : 80
Original file line number Diff line number Diff line change 1+ # Diffs:
2+ v1 Pod default/nginx-pod-1:
3+
4+ v1 Pod default/nginx-pod-2:
5+
6+ # Compliance messages:
7+ Compliant; notification - pods [nginx-pod-1] found as specified in namespace default; notification - pods [nginx-pod-2] found as specified in namespace default
Original file line number Diff line number Diff line change 1+ apiVersion : policy.open-cluster-management.io/v1
2+ kind : ConfigurationPolicy
3+ metadata :
4+ name : policy-pod-multi-combo
5+ namespace : managed
6+ spec :
7+ remediationAction : inform
8+ namespaceSelector :
9+ exclude : ["kube-*"]
10+ include : ["default"]
11+ object-templates-raw : |
12+ {{ range $id := (list 1 2) }}
13+ - complianceType: musthave
14+ objectDefinition:
15+ apiVersion: v1
16+ kind: Pod
17+ metadata:
18+ name: nginx-pod-{{ $id }}
19+ spec:
20+ containers:
21+ - image: nginx:1.7.9
22+ name: nginx
23+ ports:
24+ - containerPort: 80
25+ {{ end }}
You can’t perform that action at this time.
0 commit comments