diff --git a/documentation/content/en/book/05-developing-functions/_index.md b/documentation/content/en/book/05-developing-functions/_index.md index c4e6cb19e6..36ec3627c6 100644 --- a/documentation/content/en/book/05-developing-functions/_index.md +++ b/documentation/content/en/book/05-developing-functions/_index.md @@ -93,6 +93,13 @@ Understanding this specification enables you to have a deeper understanding of how things work under the hood. It also enables to create your own toolchain for function development if you so desire. +When kpt reads resources from disk, each resource in the `ResourceList` carries an +`internal.config.kubernetes.io/path` annotation indicating its file path relative to +the package directory. When a function creates new resources, it should set this +annotation to a path relative to the same package directory. See the +[annotations reference](/reference/annotations/#path-annotation-details) +for full details. + As an example, you can see the `ResourceList` containing resources in the `wordpress` package: @@ -363,3 +370,4 @@ kpt fn eval ./testdata/noop-passthrough/resources.yaml --image ${FN_CONTAINER_RE - See other [go documentation examples](https://pkg.go.dev/github.com/kptdev/krm-functions-sdk/go/fn/examples) to use KubeObject. - To contribute to KRM catalog functions, please follow the [contributor guide](https://github.com/kptdev/krm-functions-catalog/blob/main/CONTRIBUTING.md) +- For the `metadata.yaml` schema reference (required fields, allowed tags), see the [metadata schema documentation](https://catalog.kpt.dev/metadata-schema/) diff --git a/documentation/content/en/reference/annotations/_index.md b/documentation/content/en/reference/annotations/_index.md index 828ff675e9..bc549484b2 100644 --- a/documentation/content/en/reference/annotations/_index.md +++ b/documentation/content/en/reference/annotations/_index.md @@ -25,6 +25,20 @@ The following annotations are used by kpt internally: | `internal.config.kubernetes.io/index` | specifies the index of the resource in a file when formatted as a ResourceList | | `config.kubernetes.io/merge-source` | specifies the source of the resource during a three way merge | +## Path annotation details + +The `internal.config.kubernetes.io/path` annotation specifies the file path of a +resource relative to the package directory (the directory containing the Kptfile +whose pipeline invoked the function). + +When kpt reads resources from disk, it sets this annotation on each resource. +When a function creates new resources, it should set this annotation to a path +relative to the same package directory. kpt handles adjusting paths to be +relative to the root package before writing to disk. + +For `kpt fn eval DIR`, the path is relative to the package directory DIR +(the directory passed as the evaluation target). + [config.kubernetes.io/depends-on]: /reference/annotations/depends-on/ [config.kubernetes.io/apply-time-mutation]: /reference/annotations/apply-time-mutation/ [config.kubernetes.io/local-config]: /reference/annotations/local-config/