forked from open-policy-agent/gatekeeper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: upgrade cf to have the defaults injection (open-policy-agent#2811
) Signed-off-by: Alex Pana <[email protected]> Signed-off-by: alex <[email protected]>
- Loading branch information
Showing
7 changed files
with
122 additions
and
12 deletions.
There are no files selected for viewing
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
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
75 changes: 75 additions & 0 deletions
75
test/gator/test/fixtures/manifests/with-policies/with-violations-and-defaults.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,75 @@ | ||
apiVersion: templates.gatekeeper.sh/v1 | ||
kind: ConstraintTemplate | ||
metadata: | ||
name: k8srequiredlabelsdefault | ||
spec: | ||
crd: | ||
spec: | ||
names: | ||
kind: K8sRequiredLabelsDefault | ||
validation: | ||
legacySchema: false | ||
openAPIV3Schema: | ||
properties: | ||
labels: | ||
description: A list of labels and values the object must specify. | ||
default: | ||
- key: "aRequiredLabel" | ||
items: | ||
properties: | ||
key: | ||
description: The required label. | ||
type: string | ||
type: object | ||
type: array | ||
message: | ||
default: "aRequiredMessage" | ||
type: string | ||
placeholder: # needed to showcase defaulting of the other two props above. | ||
type: string | ||
type: object | ||
targets: | ||
- rego: | | ||
package k8srequiredlabels | ||
get_message(parameters, _default) = msg { | ||
not parameters.message | ||
msg := _default | ||
} | ||
get_message(parameters, _default) = msg { | ||
msg := parameters.message | ||
} | ||
violation[{"msg": msg, "details": {"missing_labels": missing}}] { | ||
provided := {label | input.review.object.metadata.labels[label]} | ||
required := {label | label := input.parameters.labels[_].key} | ||
missing := required - provided | ||
count(missing) > 0 | ||
msg := input.parameters.message | ||
} | ||
target: admission.k8s.gatekeeper.sh | ||
--- | ||
apiVersion: constraints.gatekeeper.sh/v1beta1 | ||
kind: K8sRequiredLabelsDefault | ||
metadata: | ||
name: all-must-have-owner | ||
spec: | ||
match: | ||
kinds: | ||
- apiGroups: [""] | ||
kinds: ["Namespace"] | ||
parameters: | ||
placeholder: "placeholder" | ||
# notice no parameters that are used in the validaiton code are defined, | ||
# the defaults are applied from the ConstraintTemplate's open api v3 schema definition | ||
--- | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: my-ns | ||
# Missing owner label | ||
# labels: | ||
# owner: user.agilebank.demo |
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
21 changes: 13 additions & 8 deletions
21
vendor/github.com/open-policy-agent/frameworks/constraint/pkg/client/client.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
vendor/github.com/open-policy-agent/frameworks/constraint/pkg/client/template_client.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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