-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New tests for ConfigurationPolicy (including using the hub namespace argument) and object-templates-raw. Signed-off-by: Justin Kulikauskas <jkulikau@redhat.com>
- Loading branch information
1 parent
382967b
commit d5600b8
Showing
8 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
cmd/template-resolver/testdata/setup/00_policies.namespace.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: policies | ||
spec: {} |
7 changes: 7 additions & 0 deletions
7
cmd/template-resolver/testdata/setup/coolest-car.configmap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: coolest-car | ||
namespace: policies | ||
data: | ||
model: Subaru Baja |
17 changes: 17 additions & 0 deletions
17
cmd/template-resolver/testdata/test_config-policy-directly/input.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: ConfigurationPolicy | ||
metadata: | ||
name: label-configmaps | ||
spec: | ||
remediationAction: enforce | ||
severity: low | ||
object-templates: | ||
- complianceType: musthave | ||
objectDefinition: | ||
kind: ConfigMap | ||
apiVersion: v1 | ||
metadata: | ||
name: '{{ (lookup "v1" "ConfigMap" "default" "cool-car").metadata.name }}' | ||
namespace: '{{ (lookup "v1" "ConfigMap" "default" "cool-car").metadata.namespace }}' | ||
labels: | ||
ford.com/model: '{{ fromConfigMap "default" "cool-car" "model" }}' |
17 changes: 17 additions & 0 deletions
17
cmd/template-resolver/testdata/test_config-policy-directly/output.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: ConfigurationPolicy | ||
metadata: | ||
name: label-configmaps | ||
spec: | ||
object-templates: | ||
- complianceType: musthave | ||
objectDefinition: | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
ford.com/model: Shelby Mustang | ||
name: cool-car | ||
namespace: default | ||
remediationAction: enforce | ||
severity: low |
18 changes: 18 additions & 0 deletions
18
cmd/template-resolver/testdata/test_config-policy-directly_hub/input.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: ConfigurationPolicy | ||
metadata: | ||
name: label-configmaps | ||
namespace: my-cluster | ||
spec: | ||
remediationAction: enforce | ||
severity: low | ||
object-templates: | ||
- complianceType: musthave | ||
objectDefinition: | ||
kind: ConfigMap | ||
apiVersion: v1 | ||
metadata: | ||
name: coolest-car | ||
namespace: default | ||
labels: | ||
cars.com/model: '{{hub fromConfigMap "policies" "coolest-car" "model" hub}}' |
18 changes: 18 additions & 0 deletions
18
cmd/template-resolver/testdata/test_config-policy-directly_hub/output.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: ConfigurationPolicy | ||
metadata: | ||
name: label-configmaps | ||
namespace: my-cluster | ||
spec: | ||
object-templates: | ||
- complianceType: musthave | ||
objectDefinition: | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
cars.com/model: Subaru Baja | ||
name: coolest-car | ||
namespace: default | ||
remediationAction: enforce | ||
severity: low |
14 changes: 14 additions & 0 deletions
14
cmd/template-resolver/testdata/test_object-templates-raw/input.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
object-templates-raw: | | ||
{{- range (lookup "v1" "ConfigMap" "default" "").items }} | ||
{{- if and .data.model (contains "Mustang" .data.model) }} | ||
- complianceType: musthave | ||
objectDefinition: | ||
kind: ConfigMap | ||
apiVersion: v1 | ||
metadata: | ||
name: {{ .metadata.name }} | ||
namespace: {{ .metadata.namespace }} | ||
labels: | ||
ford.com/model: Mustang | ||
{{- end }} | ||
{{- end }} |
10 changes: 10 additions & 0 deletions
10
cmd/template-resolver/testdata/test_object-templates-raw/output.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
object-templates: | ||
- complianceType: musthave | ||
objectDefinition: | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
ford.com/model: Mustang | ||
name: cool-car | ||
namespace: default |