Skip to content

Commit

Permalink
Use run instead of eval and migrate later
Browse files Browse the repository at this point in the history
  • Loading branch information
phanimarupaka committed Apr 20, 2021
1 parent 9b7e8ed commit 73443aa
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion examples/search-replace/simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ metadata:
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/search/simple .
kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/search-replace/simple .
kpt fn run simple
```

Expand Down
6 changes: 3 additions & 3 deletions functions/go/apply-setters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ data:
Render the declared values by invoking:
```
$ kpt fn eval --image gcr.io/kpt-fn/apply-setters:unstable --fn-config ./apply-setters-fn-config
$ kpt fn run --image gcr.io/kpt-fn/apply-setters:unstable --fn-config ./apply-setters-fn-config
```

Alternatively, setter values can be passed as key-value pairs in the CLI

```
$ kpt fn eval --image gcr.io/kpt-fn/apply-setters:unstable -- 'image=ubuntu' 'replicas=3'
$ kpt fn run --image gcr.io/kpt-fn/apply-setters:unstable -- 'image=ubuntu' 'replicas=3'
```

Rendered resource looks like the following:
Expand Down Expand Up @@ -119,7 +119,7 @@ data:
Render the declared values by invoking:
```
$ kpt fn eval --image gcr.io/kpt-fn/apply-setters:unstable --fn-config ./apply-setters-fn-config
$ kpt fn run --image gcr.io/kpt-fn/apply-setters:unstable --fn-config ./apply-setters-fn-config
```

Rendered resource looks like the following:
Expand Down
6 changes: 3 additions & 3 deletions functions/go/apply-setters/generated/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions functions/go/search-replace/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ data:
The function can be invoked using:
```
$ kpt fn eval --image gcr.io/kpt-fn/apply-setters:unstable --fn-config /path/to/fn-config.yaml
$ kpt fn run --image gcr.io/kpt-fn/apply-setters:unstable --fn-config /path/to/fn-config.yaml
```

Alternatively, data can be passed as key-value pairs in the CLI

```
$ kpt fn eval --image gcr.io/kpt-fn/apply-setters:unstable -- 'by-path=metadata.name' 'put-value=the-deployment'
$ kpt fn run --image gcr.io/kpt-fn/apply-setters:unstable -- 'by-path=metadata.name' 'put-value=the-deployment'
```

Supported Path expressions:
Expand Down Expand Up @@ -150,32 +150,32 @@ a:
```sh
# Matches fields with value "3":
$ kpt fn eval --image gcr.io/kpt-fn/search-replace:unstable -- by-value=3
$ kpt fn run --image gcr.io/kpt-fn/search-replace:unstable -- by-value=3
```

```sh
# Matches fields with value prefixed by "nginx-":
$ kpt fn eval --image gcr.io/kpt-fn/search-replace:unstable -- by-value-regex='ngnix-.*'
$ kpt fn run --image gcr.io/kpt-fn/search-replace:unstable -- by-value-regex='ngnix-.*'
```

```sh
# Matches field with path "spec.namespaces" set to "bookstore":
$ kpt fn eval --image gcr.io/kpt-fn/search-replace:unstable -- by-path='metadata.namespace' by-value='bookstore'
$ kpt fn run --image gcr.io/kpt-fn/search-replace:unstable -- by-path='metadata.namespace' by-value='bookstore'
```

```sh
# Matches fields with name "containerPort" arbitrarily deep in "spec" that have value of 80:
$ kpt fn eval --image gcr.io/kpt-fn/search-replace:unstable -- by-path='spec.**.containerPort' by-value=80
$ kpt fn run --image gcr.io/kpt-fn/search-replace:unstable -- by-path='spec.**.containerPort' by-value=80
```

```sh
# Set namespaces for all resources to "bookstore", even namespace is not set on a resource:
$ kpt fn eval --image gcr.io/kpt-fn/search-replace:unstable -- by-path='metadata.namespace' put-value='bookstore'
$ kpt fn run --image gcr.io/kpt-fn/search-replace:unstable -- by-path='metadata.namespace' put-value='bookstore'
```

```
# Search and Set multiple values using regex numbered capture groups
$ kpt fn eval --image gcr.io/kpt-fn/search-replace:unstable -- by-value-regex='something-(.*)' put-value='my-project-id-${1}'
$ kpt fn run --image gcr.io/kpt-fn/search-replace:unstable -- by-value-regex='something-(.*)' put-value='my-project-id-${1}'
metadata:
name: something-foo
namespace: something-bar
Expand All @@ -187,12 +187,12 @@ metadata:

```sh
# Put the setter pattern as a line comment for matching fields.
$ kpt fn eval --image gcr.io/kpt-fn/search-replace:unstable -- by-value='my-project-id-foo' put-comment='kpt-set: ${project-id}-foo'
$ kpt fn run --image gcr.io/kpt-fn/search-replace:unstable -- by-value='my-project-id-foo' put-comment='kpt-set: ${project-id}-foo'
metadata:
name: my-project-id-foo # kpt-set: ${project-id}-foo

# Setter pattern comments can be added to multiple values matching a regex numbered capture groups
$ kpt fn eval --image gcr.io/kpt-fn/search-replace:unstable -- by-value-regex='my-project-id-(.*)' put-comment='kpt-set: ${project-id}-${1}'
$ kpt fn run --image gcr.io/kpt-fn/search-replace:unstable -- by-value-regex='my-project-id-(.*)' put-comment='kpt-set: ${project-id}-${1}'
metadata:
name: my-project-id-foo # kpt-set: ${project-id}-foo
namespace: my-project-id-bar # kpt-set: ${project-id}-bar
Expand Down
20 changes: 10 additions & 10 deletions functions/go/search-replace/generated/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/e2etest/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestE2E(t *testing.T) {
}

// runTests will scan test cases in 'path' and run all the
// tests in it. It returns an error if any of the tests fqails.
// tests in it. It returns an error if any of the tests fails.
func runTests(t *testing.T, path string) {
cases, err := runner.ScanTestCases(path)
if err != nil {
Expand Down

0 comments on commit 73443aa

Please sign in to comment.