-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add README for example and punt usage docs
- Loading branch information
1 parent
5f3d4a8
commit b719411
Showing
3 changed files
with
59 additions
and
218 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# search: Simple Example | ||
|
||
The `search-replace` function performs search and optionally replace fields | ||
across all resources. | ||
|
||
This is a simple example depicting search and replace operation on KRM resource config. | ||
|
||
Let's start with the input resource | ||
|
||
```yaml | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: the-deployment | ||
namespace: my-space | ||
``` | ||
Search matchers are provided with `by-` prefix. When multiple matchers are | ||
provided they are AND’ed together. `put-` matchers are mutually exclusive. | ||
|
||
We use the following ConfigMap to provide input matchers to the function. | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: ... | ||
data: | ||
by-path: metadata.name | ||
by-value: the-deployment | ||
put-value: my-deployment | ||
``` | ||
|
||
Invoking `search-replace` function would apply the changes to resource configs | ||
|
||
```yaml | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: my-deployment | ||
namespace: my-space | ||
``` | ||
|
||
## Function invocation | ||
|
||
Get the config example and try it out by running the following commands: | ||
|
||
```sh | ||
kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/mutators/search/simple . | ||
kpt fn run simple | ||
``` | ||
|
||
## Expected result | ||
|
||
Check the value of deployment `the-deloyment` is changed to `my-deloyment`. | ||
|
||
```sh | ||
kpt cfg cat simple | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters