Skip to content

Commit

Permalink
Add gator verify expansion support details in website docs
Browse files Browse the repository at this point in the history
Signed-off-by: David-Jaeyoon-Lee <davjlee@google.com>
  • Loading branch information
David-Jaeyoon-Lee committed Nov 6, 2024
1 parent 5db30bb commit 6c1464a
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion website/docs/gator.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ gator test --filename=manifests-and-policies/ --output=json
`gator verify` organizes tests into three levels: Suites, Tests, and Cases:

- A Suite is a file which defines Tests.
- A Test declares a ConstraintTemplate, a Constraint, and Cases to test the
- A Test declares a ConstraintTemplate, a Constraint, an ExpansionTemplate (optional), and Cases to test the
Constraint.
- A Case defines an object to validate and whether the object is expected to
pass validation.
Expand Down Expand Up @@ -162,6 +162,8 @@ ConstraintTemplate. It is an error for the Constraint to have a different type
than that defined in the ConstraintTemplate spec.crd.spec.names.kind, or for the
ConstraintTemplate to not compile.

A Test can also optionally compile an ExpansionTemplate.

### Cases

Each Test contains a list of Cases under the `cases` field.
Expand Down Expand Up @@ -264,6 +266,25 @@ the `run` flag:
gator verify path/to/suites/... --run "disallowed"
```

### Validating Generated Resources with ExpansionTemplates
`gator verify` may be used along with expansion templates to validate generated resources. The expansion template is optionally declared at the test level. If an expansion template is set for a test, gator will attempt to expand each object under the test. The violations for the parent object & its expanded resources will be aggregated.

Example for declaring an expansion template in a Gator Suite:
```yaml
apiVersion: test.gatekeeper.sh/v1alpha1
kind: Suite
tests:
- name: expansion
template: template.yaml
constraint: constraint.yaml
expansion: expansion.yaml
cases:
- name: example-expand
object: deployment.yaml
assertions:
- violations: yes
```

### Validating Metadata-Based Constraint Templates

`gator verify` may be used with an [`AdmissionReview`](https://pkg.go.dev/k8s.io/kubernetes/pkg/apis/admission#AdmissionReview)
Expand Down

0 comments on commit 6c1464a

Please sign in to comment.