Skip to content

Commit

Permalink
update for gatekeeper/v0.2 branch (#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mengqi Yu authored Aug 5, 2021
1 parent e172cad commit e975da1
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: fnresults
exitCode: 1
items:
- image: gcr.io/kpt-fn/gatekeeper:unstable
- image: gcr.io/kpt-fn/gatekeeper:v0.2
stderr: |
[error] apps/v1/Deployment/nginx-deploy : Containers must not run as root
violatedConstraint: disallowroot
Expand Down
2 changes: 1 addition & 1 deletion examples/gatekeeper-disallow-root-user/Kptfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ metadata:
name: example
pipeline:
validators:
- image: gcr.io/kpt-fn/gatekeeper:unstable
- image: gcr.io/kpt-fn/gatekeeper:v0.2
6 changes: 3 additions & 3 deletions examples/gatekeeper-disallow-root-user/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ enforce the policy `Containers must not run as root` on resources.
Get the example package by running the following commands:

```shell
$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/gatekeeper-disallow-root-user
$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/gatekeeper-disallow-root-user@gatekeeper/v0.2
```

There are 3 resources: a `ConstraintTemplate`, a `DisallowRoot` and
Expand Down Expand Up @@ -81,7 +81,7 @@ metadata:
name: fnresults
exitCode: 1
items:
- image: gcr.io/kpt-fn/gatekeeper:unstable
- image: gcr.io/kpt-fn/gatekeeper:v0.2
stderr: |-
[error] apps/v1/Deployment/nginx-deploy : Containers must not run as root
violatedConstraint: disallowroot
Expand Down Expand Up @@ -110,4 +110,4 @@ To pass validation, let's set
field `spec.template.spec.securityContext.runAsNonRoot` to `true` in
the `Deployment` in `resources.yaml`. Rerun the command. It will succeed.

[gatekeeper]: https://catalog.kpt.dev/gatekeeper/v0.1/
[gatekeeper]: https://catalog.kpt.dev/gatekeeper/v0.2/
2 changes: 1 addition & 1 deletion examples/gatekeeper-imperative/.expected/results.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: fnresults
exitCode: 1
items:
- image: gcr.io/kpt-fn/gatekeeper:unstable
- image: gcr.io/kpt-fn/gatekeeper:v0.2
stderr: |
[error] v1/ConfigMap/default/super-secret : The following banned keys are being used in the ConfigMap: {"private_key"}
violatedConstraint: no-secrets-in-configmap
Expand Down
8 changes: 4 additions & 4 deletions examples/gatekeeper-imperative/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ running [`gatekeeper`] function imperatively.
Get the example package by running the following commands:

```shell
$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/gatekeeper-imperative
$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/gatekeeper-imperative@gatekeeper/v0.2
```

To ensure ConfigMaps do not contain fields with name `private_key`, we express
Expand All @@ -26,7 +26,7 @@ We have a `ConfigMap` in `config-map.yaml` that violates the policy.
Run the function with `--results-dir` flag:

```shell
$ kpt fn eval gatekeeper-imperative --image gcr.io/kpt-fn/gatekeeper:unstable --results-dir /tmp
$ kpt fn eval gatekeeper-imperative --image gcr.io/kpt-fn/gatekeeper:v0.2 --results-dir /tmp
```

### Expected result
Expand All @@ -40,7 +40,7 @@ metadata:
name: fnresults
exitCode: 1
items:
- image: gcr.io/kpt-fn/gatekeeper:unstable
- image: gcr.io/kpt-fn/gatekeeper:v0.2
stderr: |-
The following banned keys are being used in the ConfigMap: {"private_key"}
violatedConstraint: no-secrets-in-configmap
Expand Down Expand Up @@ -72,4 +72,4 @@ To pass validation, let's replace the key `private_key` in the `ConfigMap` in
`resources.yaml` with something else e.g. `public_key`. Rerun the command. It
will succeed.

[`gatekeeper`]: https://catalog.kpt.dev/gatekeeper/v0.1/
[`gatekeeper`]: https://catalog.kpt.dev/gatekeeper/v0.2/
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: fnresults
exitCode: 1
items:
- image: gcr.io/kpt-fn/gatekeeper:unstable
- image: gcr.io/kpt-fn/gatekeeper:v0.2
stderr: |
[error] v1/ConfigMap/default/super-secret : The following banned keys are being used in the ConfigMap: {"private_key"}
violatedConstraint: no-secrets-in-configmap
Expand Down
2 changes: 1 addition & 1 deletion examples/gatekeeper-invalid-configmap/Kptfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ metadata:
name: example
pipeline:
validators:
- image: gcr.io/kpt-fn/gatekeeper:unstable
- image: gcr.io/kpt-fn/gatekeeper:v0.2
8 changes: 4 additions & 4 deletions examples/gatekeeper-invalid-configmap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function to validate resources using gatekeeper constraints.
Get the example package by running the following commands:

```shell
$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/gatekeeper-invalid-configmap
$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/gatekeeper-invalid-configmap@gatekeeper/v0.2
```

There are 3 resources: a `ConstraintTemplate`, a `K8sBannedConfigMapKeysV1` and
Expand All @@ -25,7 +25,7 @@ metadata:
name: example
pipeline:
validators:
- image: gcr.io/kpt-fn/gatekeeper:unstable
- image: gcr.io/kpt-fn/gatekeeper:v0.2
```
### Function invocation
Expand All @@ -47,7 +47,7 @@ metadata:
name: fnresults
exitCode: 1
items:
- image: gcr.io/kpt-fn/gatekeeper:unstable
- image: gcr.io/kpt-fn/gatekeeper:v0.2
stderr: |-
The following banned keys are being used in the ConfigMap: {"private_key"}
violatedConstraint: no-secrets-in-configmap
Expand Down Expand Up @@ -78,4 +78,4 @@ To pass validation, let's replace the key `private_key` in the `ConfigMap` in
`resources.yaml` with something else e.g. `public_key`.
Rerun the command. It will succeed.

[gatekeeper]: https://catalog.kpt.dev/gatekeeper/v0.1/
[gatekeeper]: https://catalog.kpt.dev/gatekeeper/v0.2/
2 changes: 1 addition & 1 deletion examples/gatekeeper-warning-only/.expected/results.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: fnresults
exitCode: 0
items:
- image: gcr.io/kpt-fn/gatekeeper:unstable
- image: gcr.io/kpt-fn/gatekeeper:v0.2
exitCode: 0
results:
- message: |-
Expand Down
2 changes: 1 addition & 1 deletion examples/gatekeeper-warning-only/Kptfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ metadata:
name: example
pipeline:
validators:
- image: gcr.io/kpt-fn/gatekeeper:unstable
- image: gcr.io/kpt-fn/gatekeeper:v0.2
8 changes: 4 additions & 4 deletions examples/gatekeeper-warning-only/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ configured to be warnings instead of errors.
Get the example package by running the following commands:

```shell
$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/gatekeeper-warning-only
$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/gatekeeper-warning-only@gatekeeper/v0.2
```

Here's an example `Kptfile` to run the function:
Expand All @@ -23,7 +23,7 @@ metadata:
name: example
pipeline:
validators:
- image: gcr.io/kpt-fn/gatekeeper:unstable
- image: gcr.io/kpt-fn/gatekeeper:v0.2
```
In the constraint, we use `enforcementAction: warn` instead of
Expand Down Expand Up @@ -58,7 +58,7 @@ metadata:
name: fnresults
exitCode: 0
items:
- image: gcr.io/kpt-fn/gatekeeper:unstable
- image: gcr.io/kpt-fn/gatekeeper:v0.2
exitCode: 0
results:
- message: |-
Expand Down Expand Up @@ -86,4 +86,4 @@ To pass validation, let's replace the key `private_key` in the `ConfigMap` in
`resources.yaml` with something else e.g. `public_key`.
Rerun the command. It will no longer have the warning.

[gatekeeper]: https://catalog.kpt.dev/gatekeeper/v0.1/
[gatekeeper]: https://catalog.kpt.dev/gatekeeper/v0.2/
10 changes: 5 additions & 5 deletions functions/go/gatekeeper/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ image: gcr.io/kpt-fn/gatekeeper
description: Validate the KRM resources using Gatekeeper policies.
tags:
- validator
sourceURL: https://github.com/GoogleContainerTools/kpt-functions-catalog/tree/master/functions/go/gatekeeper
sourceURL: https://github.com/GoogleContainerTools/kpt-functions-catalog/tree/gatekeeper/v0.2/functions/go/gatekeeper
examplePackageURLs:
- https://github.com/GoogleContainerTools/kpt-functions-catalog/tree/master/examples/gatekeeper-disallow-root-user
- https://github.com/GoogleContainerTools/kpt-functions-catalog/tree/master/examples/gatekeeper-invalid-configmap
- https://github.com/GoogleContainerTools/kpt-functions-catalog/tree/master/examples/gatekeeper-warning-only
- https://github.com/GoogleContainerTools/kpt-functions-catalog/tree/master/examples/gatekeeper-imperative
- https://github.com/GoogleContainerTools/kpt-functions-catalog/tree/gatekeeper/v0.2/examples/gatekeeper-disallow-root-user
- https://github.com/GoogleContainerTools/kpt-functions-catalog/tree/gatekeeper/v0.2/examples/gatekeeper-invalid-configmap
- https://github.com/GoogleContainerTools/kpt-functions-catalog/tree/gatekeeper/v0.2/examples/gatekeeper-warning-only
- https://github.com/GoogleContainerTools/kpt-functions-catalog/tree/gatekeeper/v0.2/examples/gatekeeper-imperative
emails:
- kpt-team@google.com
license: Apache-2.0

0 comments on commit e975da1

Please sign in to comment.