-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
99cd6fb
commit 1cfe236
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
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,30 @@ | ||
## Introduction | ||
|
||
`set-annotations` is a kcl mutation package, which can be used to add `metadata.annotations` attributes for the Kubernetes resources. | ||
|
||
The KCL code is as follows: | ||
|
||
```python | ||
params = option("params") or {} | ||
# Use `k = v` to override existing annotations | ||
annotations: {str:str} = {k = v for k, v in params.annotations or {}} | ||
items = [item | { | ||
metadata.annotations: annotations | ||
} for item in option("items")] | ||
``` | ||
|
||
## How to Use | ||
|
||
Add the source into your `KCLRun` resource and use the [kubectl kcl plugin](https://kcl-lang.io/docs/user_docs/guides/working-with-k8s/mutate-manifests/kubectl-kcl-plugin) or the [kcl operator](https://kcl-lang.io/docs/user_docs/guides/working-with-k8s/mutate-manifests/kcl-operator) to integrate this model. | ||
|
||
```yaml | ||
apiVersion: krm.kcl.dev/v1alpha1 | ||
kind: KCLRun | ||
metadata: | ||
name: set-annotations | ||
spec: | ||
params: | ||
annotations: | ||
config.kubernetes.io/local-config: "true" | ||
source: oci://ghcr.io/kcl-lang/set-annotations | ||
``` |
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,26 @@ | ||
version: 0.1.0 | ||
name: set-annotations | ||
displayName: set-annotations | ||
createdAt: "2023-10-25T06:46:13Z" | ||
description: '`set-annotations` is a kcl mutation package, which can be used to add | ||
`metadata.annotations` attributes for the Kubernetes resources.' | ||
links: | ||
- name: KCL homepage | ||
url: https://kcl-lang.io/ | ||
- name: KCL repo | ||
url: https://github.com/kcl-lang/kcl | ||
install: | | ||
#### Add `set-annotations` with tag `0.1.0` as dependency | ||
``` | ||
kpm add set-annotations:0.1.0 | ||
``` | ||
#### Pull `set-annotations` with tag `0.1.0` to local | ||
``` | ||
kpm pull set-annotations:0.1.0 | ||
``` | ||
maintainers: | ||
- name: kcl-lang.io | ||
email: [email protected] | ||
provider: | ||
name: kcl-lang.io |