Skip to content

Commit

Permalink
docs: fix go install gator (open-policy-agent#3325)
Browse files Browse the repository at this point in the history
Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
  • Loading branch information
sozercan authored and leewoobin789 committed Apr 1, 2024
1 parent 62525f2 commit c92d19d
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions website/docs/gator.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
id: gator
id: gator
title: The gator CLI
---

Expand All @@ -17,13 +17,17 @@ you can also install `gator` using [Homebrew](https://brew.sh).

To build from source:

```shell
go install github.com/open-policy-agent/gatekeeper/v3/cmd/gator@master
```
go get github.com/open-policy-agent/gatekeeper/cmd/gator
```

:::note
`go install` of `gator` requires Gatekeeper `master` branch or `v3.16.0` and later.
:::

Install with Homebrew:

```
```shell
brew install gator
```

Expand Down Expand Up @@ -53,13 +57,13 @@ than the aforementioned three will be skipped.

For example, to test a manifest (piped via stdin) against a folder of policies:

```
```shell
cat my-manifest.yaml | gator test --filename=template-and-constraints/
```

Or you can specify both as flags:

```
```shell
gator test -f=my-manifest.yaml -f=templates-and-constraints/
```

Expand All @@ -77,9 +81,9 @@ section.
For example, to test a manifest (piped via stdin) against an OCI Artifact
containing policies:

```
```shell
cat my-manifest.yaml | gator test --image=localhost:5000/gator/template-library:v1 \
--image=localhost:5000/gator/constraints:v1
--image=localhost:5000/gator/constraints:v1
```

#### Exit Codes
Expand Down Expand Up @@ -113,7 +117,7 @@ stdout.

The allowed values are `yaml` and `json`, specified like:

```
```shell
gator test --filename=manifests-and-policies/ --output=json
```

Expand Down Expand Up @@ -249,22 +253,22 @@ gator verify suite.yaml

To run all suites in the current directory and all child directories recursively

```
```shell
gator verify ./...
```

To only run tests whose full names contain a match for a regular expression, use
the `run` flag:

```
```shell
gator verify path/to/suites/... --run "disallowed"
```

### Validating Metadata-Based Constraint Templates

`gator verify` may be used with an [`AdmissionReview`](https://pkg.go.dev/k8s.io/kubernetes/pkg/apis/admission#AdmissionReview)
object to test your constraints. This can be helpful to simulate a certain operation (`CREATE`, `UPDATE`, `DELETE`, etc.)
or [`UserInfo`](https://pkg.go.dev/k8s.io/kubernetes@v1.25.3/pkg/apis/authentication#UserInfo) metadata.
`gator verify` may be used with an [`AdmissionReview`](https://pkg.go.dev/k8s.io/kubernetes/pkg/apis/admission#AdmissionReview)
object to test your constraints. This can be helpful to simulate a certain operation (`CREATE`, `UPDATE`, `DELETE`, etc.)
or [`UserInfo`](https://pkg.go.dev/k8s.io/kubernetes@v1.25.3/pkg/apis/authentication#UserInfo) metadata.
Recall that the `input.review.user` can be accessed in the Rego code (see [Input Review](howto.md#input-review) for more guidance). The `AdmissionReview` object can be specified where you would specify the object under test above:

```yaml
Expand Down Expand Up @@ -366,26 +370,26 @@ supplied, the command will exit 1. See the [non default namespace example](#non-
Similar to `gator test`, `gator expand` expects a `--filename` or `--image`
flag. The flags can be used individually, in combination, and/or repeated.

```
gator expand --filename="manifest.yaml" –filename="expansion-policy/"
```shell
gator expand --filename="manifest.yaml" –filename="expansion-policy/"
```

Or, using an OCI Artifact for the expansion configuration:

```
```shell
gator expand --filename="my-deployment.yaml" --image=localhost:5000/gator/expansion-policy:v1
```

By default, `gator expand` will output to stdout, but a `–outputfile` flag can be
specified to write the results to a file.

```
```shell
gator expand --filename="manifest.yaml" –outputfile="results.yaml"
```

`gator expand` can output in `yaml` or `json` (default is `yaml`).

```
```shell
gator expand --filename="manifest.yaml" –format="json"
```

Expand Down Expand Up @@ -511,7 +515,7 @@ We recommend using the [Oras CLI](https://oras.land/cli/) to create OCI
artifacts. For example, to push a bundle containing the 2 local directories
`constraints` and `template_library`:

```
```shell
oras push localhost:5000/gator/policy-bundle:v1 ./constraints/:application/vnd.oci.image.layer.v1.tar+gzip \
./template_library/:application/vnd.oci.image.layer.v1.tar+gzip
```
Expand Down

0 comments on commit c92d19d

Please sign in to comment.