-
Notifications
You must be signed in to change notification settings - Fork 37
/
src.rego
36 lines (29 loc) · 1.26 KB
/
src.rego
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# METADATA
# title: 'RHCOP-OCP_BESTPRACT-00027: DeploymentConfig triggers container name miss match'
# description: |-
# If you are using a DeploymentConfig with 'spec.triggers' set,
# but the container name does not match the trigger will never fire. There is probably a mistake in your definition.
# custom:
# matchers:
# kinds:
# - apiGroups:
# - apps.openshift.io
# kinds:
# - DeploymentConfig
package ocp.bestpractices.deploymentconfig_triggers_containername
import future.keywords.in
import data.lib.konstraint.core as konstraint_core
import data.lib.openshift
violation[msg] {
openshift.is_policy_active("RHCOP-OCP_BESTPRACT-00027")
openshift.is_deploymentconfig
some trigger in konstraint_core.resource.spec.triggers
some container_name in trigger.imageChangeParams.containerNames
not _containers_contains_trigger(openshift.containers, container_name)
msg := konstraint_core.format_with_id(sprintf("%s/%s: has a imageChangeParams trigger with a miss-matching container name for '%s'", [konstraint_core.kind, konstraint_core.name, container_name]), "RHCOP-OCP_BESTPRACT-00027")
}
# regal ignore:custom-in-construct
_containers_contains_trigger(containers, container_name) {
some container in containers
container.name == container_name
}