Skip to content

Commit 2a06a17

Browse files
committed
Add CronJob to refvars transformer
1 parent 5b67b58 commit 2a06a17

File tree

5 files changed

+79
-0
lines changed

5 files changed

+79
-0
lines changed

pkg/commands/testdata/testcase-variable-ref/expected.diff

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,31 @@ diff -u -N /tmp/noop/apps_v1beta1_StatefulSet_cockroachdb.yaml /tmp/transformed/
4141
terminationGracePeriodSeconds: 60
4242
volumes:
4343
- name: datadir
44+
diff -u -N /tmp/noop/batch_v1beta1_CronJob_cronjob-example.yaml /tmp/transformed/batch_v1beta1_CronJob_cronjob-example.yaml
45+
--- /tmp/noop/batch_v1beta1_CronJob_cronjob-example.yaml YYYY-MM-DD HH:MM:SS
46+
+++ /tmp/transformed/batch_v1beta1_CronJob_cronjob-example.yaml YYYY-MM-DD HH:MM:SS
47+
@@ -1,7 +1,7 @@
48+
apiVersion: batch/v1beta1
49+
kind: CronJob
50+
metadata:
51+
- name: base-cronjob-example
52+
+ name: dev-base-cronjob-example
53+
spec:
54+
concurrencyPolicy: Forbid
55+
jobTemplate:
56+
@@ -11,10 +11,10 @@
57+
containers:
58+
- command:
59+
- echo
60+
- - base-cockroachdb
61+
+ - dev-base-cockroachdb
62+
env:
63+
- name: CDB_PUBLIC_SVC
64+
- value: base-cockroachdb-public
65+
+ value: dev-base-cockroachdb-public
66+
image: cockroachdb/cockroach:v1.1.5
67+
name: cronjob-example
68+
schedule: '*/1 * * * *'
4469
diff -u -N /tmp/noop/policy_v1beta1_PodDisruptionBudget_cockroachdb-budget.yaml /tmp/transformed/policy_v1beta1_PodDisruptionBudget_cockroachdb-budget.yaml
4570
--- /tmp/noop/policy_v1beta1_PodDisruptionBudget_cockroachdb-budget.yaml YYYY-MM-DD HH:MM:SS
4671
+++ /tmp/transformed/policy_v1beta1_PodDisruptionBudget_cockroachdb-budget.yaml YYYY-MM-DD HH:MM:SS

pkg/commands/testdata/testcase-variable-ref/expected.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,27 @@ spec:
192192
requests:
193193
storage: 1Gi
194194
---
195+
apiVersion: batch/v1beta1
196+
kind: CronJob
197+
metadata:
198+
name: dev-base-cronjob-example
199+
spec:
200+
concurrencyPolicy: Forbid
201+
jobTemplate:
202+
spec:
203+
template:
204+
spec:
205+
containers:
206+
- command:
207+
- echo
208+
- dev-base-cockroachdb
209+
env:
210+
- name: CDB_PUBLIC_SVC
211+
value: dev-base-cockroachdb-public
212+
image: cockroachdb/cockroach:v1.1.5
213+
name: cronjob-example
214+
schedule: '*/1 * * * *'
215+
---
195216
apiVersion: policy/v1beta1
196217
kind: PodDisruptionBudget
197218
metadata:
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: batch/v1beta1
2+
kind: CronJob
3+
metadata:
4+
name: cronjob-example
5+
spec:
6+
schedule: "*/1 * * * *"
7+
concurrencyPolicy: Forbid
8+
jobTemplate:
9+
spec:
10+
template:
11+
spec:
12+
containers:
13+
- name: cronjob-example
14+
image: cockroachdb/cockroach:v1.1.5
15+
command:
16+
- echo
17+
- "$(CDB_STATEFULSET_NAME)"
18+
env:
19+
- name: CDB_PUBLIC_SVC
20+
value: "$(CDB_PUBLIC_SVC)"

pkg/commands/testdata/testcase-variable-ref/in/package/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namePrefix: base-
22
resources:
33
- cockroachdb-statefulset-secure.yaml
4+
- cronjob.yaml
45
vars:
56
- name: CDB_PUBLIC_SVC
67
objref:

pkg/transformers/refvars.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ func NewRefVarTransformer(vars map[string]string) (Transformer, error) {
3838
GroupVersionKind: &schema.GroupVersionKind{Kind: "Job"},
3939
Path: []string{"spec", "template", "spec", "containers", "command"},
4040
},
41+
{
42+
GroupVersionKind: &schema.GroupVersionKind{Kind: "CronJob"},
43+
Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "containers", "command"},
44+
},
4145
{
4246
GroupVersionKind: &schema.GroupVersionKind{Kind: "StatefulSet"},
4347
Path: []string{"spec", "template", "spec", "initContainers", "args"},
@@ -58,6 +62,10 @@ func NewRefVarTransformer(vars map[string]string) (Transformer, error) {
5862
GroupVersionKind: &schema.GroupVersionKind{Kind: "Job"},
5963
Path: []string{"spec", "template", "spec", "containers", "args"},
6064
},
65+
{
66+
GroupVersionKind: &schema.GroupVersionKind{Kind: "CronJob"},
67+
Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "containers", "args"},
68+
},
6169
{
6270
GroupVersionKind: &schema.GroupVersionKind{Kind: "StatefulSet"},
6371
Path: []string{"spec", "template", "spec", "initContainers", "env", "value"},
@@ -78,6 +86,10 @@ func NewRefVarTransformer(vars map[string]string) (Transformer, error) {
7886
GroupVersionKind: &schema.GroupVersionKind{Kind: "Job"},
7987
Path: []string{"spec", "template", "spec", "containers", "env", "value"},
8088
},
89+
{
90+
GroupVersionKind: &schema.GroupVersionKind{Kind: "CronJob"},
91+
Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "containers", "env", "value"},
92+
},
8193
{
8294
GroupVersionKind: &schema.GroupVersionKind{Kind: "Pod"},
8395
Path: []string{"spec", "containers", "command"},

0 commit comments

Comments
 (0)