Skip to content

Commit

Permalink
feat: add append-env mutation models
Browse files Browse the repository at this point in the history
  • Loading branch information
Peefy committed Oct 19, 2023
1 parent 0e1448b commit 0fc3154
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/mutation/append-env/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "append-env"
edition = "*"
version = "0.0.1"
10 changes: 10 additions & 0 deletions examples/mutation/append-env/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
items = [item | {
if item.kind == "Pod":
spec.containers: [{
env += option("params").env
} for container in item.spec.containers]
elif item.kind == "Deployment":
spec.template.spec.containers: [{
env += option("params").env
} for container in item.spec.template.spec.containers]
} for item in option("items") or []]
37 changes: 37 additions & 0 deletions examples/mutation/append-env/suite/good.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: krm.kcl.dev/v1alpha1
kind: KCLRun
metadata:
name: append-env
annotations:
krm.kcl.dev/version: 0.0.1
krm.kcl.dev/type: mutation
documentation: >-
Append env list for `Pod` and `Deployment` resources
spec:
params:
env:
name: test_name
value: test_value
source: ./examples/mutation/append-env/main.k
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80

0 comments on commit 0fc3154

Please sign in to comment.