Skip to content

Commit 4b4e0dc

Browse files
authored
Added docs for using exec in fn render (#2642)
* Added docs for using exec in fn render * addressed review comment
1 parent b63887c commit 4b4e0dc

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

internal/docs/generated/fndocs/docs.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/book/04-using-functions/01-declarative-function-execution.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,48 @@ The end result is that:
110110
If any of the functions in the pipeline fails for whatever reason, then the
111111
entire pipeline is aborted and the local filesystem is left intact.
112112

113-
## Specifying `image`
113+
## Specifying `function`
114+
115+
### `image`
114116

115117
The `image` field specifies the container image for the function. You can specify
116118
an image from any container registry. If the registry is omitted, the default
117119
container registry for functions catalog (`gcr.io/kpt-fn`) is prepended automatically.
118120
For example, `set-labels:v0.1` is automatically expanded to `gcr.io/kpt-fn/set-labels:v0.1`.
119121

122+
### `exec`
123+
124+
The `exec` field specifies the executable command for the function. You can specify
125+
an executable with arguments.
126+
127+
Example below uses `sed` executable to replace all occurances of `foo` with `bar`
128+
in the package resources.
129+
130+
```yaml
131+
# PKG_DIR/Kptfile (Excerpt)
132+
apiVersion: kpt.dev/v1
133+
kind: Kptfile
134+
metadata:
135+
name: app
136+
pipeline:
137+
mutators:
138+
- exec: "sed -e 's/foo/bar/'"
139+
```
140+
141+
Note that you must render the package by allowing executables by specifying `--allow-exec`
142+
command line flag as shown below.
143+
144+
```shell
145+
$ kpt fn render [PKG_DIR] --allow-exec
146+
```
147+
148+
Using `exec` is not recommended for two reasons:
149+
150+
- It makes the package non-portable since rendering the package requires the
151+
executables to be present on the system.
152+
- Executing binaries is not very secure since they can perform privileged operations
153+
on the system.
154+
120155
## Specifying `functionConfig`
121156

122157
In [Chapter 2], we saw this conceptual representation of a function invocation:

site/reference/cli/fn/render/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ PKG_PATH:
4848
#### Flags
4949

5050
```
51+
--allow-exec:
52+
Allow executable binaries to run as function. Note that executable binaries
53+
can perform privileged operations on your system, so ensure that binaries
54+
referred in the pipeline are trusted and safe to execute.
55+
5156
--image-pull-policy:
5257
If the image should be pulled before rendering the package(s). It can be set
5358
to one of always, ifNotPresent, never. If unspecified, always will be the

0 commit comments

Comments
 (0)