Skip to content

Commit

Permalink
docs: add more documents about the KRM KCL input format
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Nov 17, 2023
1 parent 0640b03 commit 1480a35
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ spec:
In the example above, the script accesses the `toMatch` parameters using `option("params").toMatch`.

Besides, the `source` ield supports different KCL sources, which can come from a local file, VCS such as github, OCI registry, http, etc. You can see the specific usage [here](./pkg/options/testdata/). Take an OCI source as the example.
Besides, the `source` field supports different KCL sources, which can come from a local file, VCS such as github, OCI registry, http, etc. You can see the specific usage [here](./pkg/options/testdata/). Take an OCI source as the example.

```yaml
apiVersion: krm.kcl.dev/v1alpha1
Expand Down
24 changes: 22 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,42 @@ import (

func main() {
// Input KRM resource list and KCL function config from os.Stdin
// YAML Stream Example
//
// Example
// ```yaml
// apiVersion: apps/v1
// kind: Deployment
// metadata:
// name: deployment
// spec:
// replicas: 2
// ---
// apiVersion: krm.kcl.dev/v1alpha1
// kind: KCLRun
// metadata:
// name: set-annotation
// spec:
// source: |
// [resource | {if resource.kind == "Deployment": metadata.annotations: {"managed-by" = "krm-kcl"}} for resource in option("resource_list").items]
// ```
//
// Resource List Example
//
// ```yaml
// apiVersion: config.kubernetes.io/v1
// kind: ResourceList
// items:
// - apiVersion: apps/v1
// kind: Deployment
// metadata:
// name: deployment
// spec:
// replicas: 2
// - kind: Service
// functionConfig:
// apiVersion: krm.kcl.dev/v1alpha1
// kind: KCLRun
// metadata:
// name: set-annotation
// spec:
// source: |
// [resource | {if resource.kind == "Deployment": metadata.annotations: {"managed-by" = "krm-kcl"}} for resource in option("resource_list").items]
Expand Down

0 comments on commit 1480a35

Please sign in to comment.