Skip to content

Commit

Permalink
doc(gctx): cli variable injection
Browse files Browse the repository at this point in the history
Signed-off-by: Khaled Emara <[email protected]>
  • Loading branch information
KhaledEmaraDev committed Oct 28, 2024
1 parent 16d64e4 commit 92a2d91
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions content/en/docs/kyverno-cli/usage/apply.md
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,29 @@ echo $?
3
```

You can also inject global context entries using variables. This feature allows for more flexible and dynamic policy testing and execution.

To inject global context entries using the CLI the Values file should contain a `policies` section where you can define the global context entries you want to inject.

Here's an example of a Values file that injects a global context entry:

```yaml
apiVersion: cli.kyverno.io/v1alpha1
kind: Value
metadata:
name: values
globalValues:
request.operation: CREATE
policies:
- name: gctx
rules:
- name: main-deployment-exists
values:
deploymentCount: 1
```

In this example, `request.operation` is set as a global value, and `deploymentCount` is set for a specific rule in the `gctx` policy.

### Policy Report

Policy reports provide information about policy execution and violations. Use `--policy-report` with the `apply` command to generate a policy report for `validate` policies. `mutate` and `generate` policies do not trigger policy reports.
Expand Down

0 comments on commit 92a2d91

Please sign in to comment.