From 92a2d91482467cc0398118dfaf1f54abfe94629b Mon Sep 17 00:00:00 2001 From: Khaled Emara Date: Mon, 28 Oct 2024 16:28:27 +0300 Subject: [PATCH] doc(gctx): cli variable injection Signed-off-by: Khaled Emara --- content/en/docs/kyverno-cli/usage/apply.md | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/content/en/docs/kyverno-cli/usage/apply.md b/content/en/docs/kyverno-cli/usage/apply.md index 1e1bc1e5c..cfdc9f9e1 100644 --- a/content/en/docs/kyverno-cli/usage/apply.md +++ b/content/en/docs/kyverno-cli/usage/apply.md @@ -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.