Skip to content

Commit

Permalink
Merge branch 'main' into add_dockerfile_sample
Browse files Browse the repository at this point in the history
  • Loading branch information
eddycharly authored Oct 10, 2023
2 parents 792bd01 + 88cbfdf commit 8da04c1
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 39 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ codegen-docs: codegen-api-docs-md codegen-cli-docs codegen-jp-docs ## Generate d
.PHONY: codegen-mkdocs
codegen-mkdocs: codegen-docs ## Generate mkdocs website
@echo Generate mkdocs website... >&2
@pip3 install mkdocs
@pip3 install --upgrade pip
@pip3 install -U mkdocs-material mkdocs-redirects mkdocs-minify-plugin mkdocs-include-markdown-plugin lunr mkdocs-rss-plugin
@pip install mkdocs
@pip install --upgrade pip
@pip install -U mkdocs-material mkdocs-redirects mkdocs-minify-plugin mkdocs-include-markdown-plugin lunr mkdocs-rss-plugin
@rm -rf ./website/docs/apis && mkdir -p ./website/docs/apis && cp docs/user/apis/md/* ./website/docs/apis
@rm -rf ./website/docs/commands && mkdir -p ./website/docs/commands && cp docs/user/commands/* ./website/docs/commands
@rm -rf ./website/docs/jp && mkdir -p ./website/docs/jp && cp docs/user/jp/* ./website/docs/jp
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ foo:
```

Here the `(bar)` key conflict with the projection syntax used.
To workaround this issue, you can escape a projection by surrounding it with `/` characters like this:
To workaround this issue, you can escape a projection by surrounding it with `\` characters like this:

```yaml
apiVersion: json.kyverno.io/v1alpha1
Expand All @@ -344,17 +344,17 @@ spec:
assert:
all:
- foo:
/(bar)/: 10
\(bar)\: 10
```

In this case, the leading and trailing `/` characters will be erased and the projection won't be applied.
In this case, the leading and trailing `\` characters will be erased and the projection won't be applied.

Note that it's still possible to use the `~` modifier or to create a named binding with and escaped projection.

Keys like this are perfectly valid:
- `~index./baz/`
- `/baz/@foo`
- `~index./baz/@foo`
- `~index.\baz\`
- `\baz\@foo`
- `~index.\baz\@foo`

## SDK

Expand Down
2 changes: 1 addition & 1 deletion pkg/engine/assert/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
var (
foreachRegex = regexp.MustCompile(`^~(\w+)?\.(.*)`)
bindingRegex = regexp.MustCompile(`(.*)@(\w+)$`)
escapeRegex = regexp.MustCompile(`^/(.+)/$`)
escapeRegex = regexp.MustCompile(`^\\(.+)\\$`)
engineRegex = regexp.MustCompile(`^\((?:(\w+):)?(.+)\)$`)
)

Expand Down
12 changes: 6 additions & 6 deletions pkg/engine/assert/expression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func Test_parseExpressionRegex(t *testing.T) {
},
}, {
name: "escape",
in: "/~(test)@foo/",
in: `\~(test)@foo\`,
want: &expression{
foreach: false,
foreachName: "",
Expand All @@ -124,7 +124,7 @@ func Test_parseExpressionRegex(t *testing.T) {
},
}, {
name: "escape",
in: "/test/",
in: `\test\`,
want: &expression{
foreach: false,
foreachName: "",
Expand All @@ -133,7 +133,7 @@ func Test_parseExpressionRegex(t *testing.T) {
},
}, {
name: "escape",
in: "/(test)/",
in: `\(test)\`,
want: &expression{
foreach: false,
foreachName: "",
Expand All @@ -142,7 +142,7 @@ func Test_parseExpressionRegex(t *testing.T) {
},
}, {
name: "escape",
in: "//test//",
in: `\/test/\`,
want: &expression{
foreach: false,
foreachName: "",
Expand All @@ -151,7 +151,7 @@ func Test_parseExpressionRegex(t *testing.T) {
},
}, {
name: "escape",
in: "~index./(test)/",
in: `~index.\(test)\`,
want: &expression{
foreach: true,
foreachName: "index",
Expand All @@ -160,7 +160,7 @@ func Test_parseExpressionRegex(t *testing.T) {
},
}, {
name: "escape",
in: "~index./(test)/@name",
in: `~index.\(test)\@name`,
want: &expression{
foreach: true,
foreachName: "index",
Expand Down
10 changes: 5 additions & 5 deletions testdata/escaped/policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ spec:
assert:
all:
- foo:
/(bar)/: 4
\(bar)\: 4
- foo:
/(bar)/@test:
\(bar)\@test:
($test): 4
- foo:
/(bar)@test/: 6
\(bar)@test\: 6
- foo:
/(bar)@test/@test:
\(bar)@test\@test:
($test): 6
- foo:
/~foos/:
\~foos\:
- 1
- 2
- 3
12 changes: 6 additions & 6 deletions website/docs/policies/escaping.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ foo:
```
Here the `(bar)` key conflict with the projection syntax.
To workaround this situation, you can escape a projection by surrounding it with `/` characters like this:
To workaround this situation, you can escape a projection by surrounding it with `\` characters like this:

```yaml
apiVersion: json.kyverno.io/v1alpha1
Expand All @@ -28,15 +28,15 @@ spec:
assert:
all:
- foo:
/(bar)/: 10
\(bar)\: 10
```

In this case, the leading and trailing `/` characters will be erased and the projection won't be applied.
In this case, the leading and trailing `\` characters will be erased and the projection won't be applied.

Note that it's still possible to use the `~` modifier or to create a named binding with and escaped projection.

Keys like this are perfectly valid:

- `~index./baz/`
- `/baz/@foo`
- `~index./baz/@foo`
- `~index.\baz\`
- `\baz\@foo`
- `~index.\baz\@foo`
25 changes: 13 additions & 12 deletions website/mkdocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ theme:
favicon: static/favicon.ico
include_search_page: false
search_index_only: true
features:
- announce.dismiss
- search.suggest
- search.highlight
- search.share
- content.code.copy
- content.action.edit
- navigation.footer
- navigation.instant
- navigation.tracking
- navigation.tabs
palette:
- media: "(prefers-color-scheme: light)" # Light mode
scheme: default
Expand All @@ -37,17 +48,6 @@ theme:
toggle:
icon: material/lightbulb
name: Switch to dark mode
features:
- announce.dismiss
- search.suggest
- search.highlight
- search.share
- content.code.copy
- content.action.edit
- navigation.footer
- navigation.instant
- navigation.tracking
- navigation.tabs

plugins:
- search
Expand All @@ -67,7 +67,8 @@ plugins:
- minify:
minify_html: true
- include-markdown
- tags
- tags:
enabled: true
- blog:
post_url_format: "{slug}"

Expand Down

0 comments on commit 8da04c1

Please sign in to comment.