Skip to content

Commit

Permalink
Merge pull request #14 from epoch8/datapipe-env
Browse files Browse the repository at this point in the history
datapipe 0.2.1
  • Loading branch information
elephantum authored Jul 24, 2023
2 parents b545e13 + 5f8d30a commit 847b0ff
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 9 deletions.
4 changes: 4 additions & 0 deletions charts/datapipe/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# 0.2.1

* Add support for `.Values.env` to loop-cronjob
* Add unit tests
2 changes: 1 addition & 1 deletion charts/datapipe/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.0
version: 0.2.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
24 changes: 16 additions & 8 deletions charts/datapipe/templates/loops-cronjob.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# CronJob template
# for each .Values.loops item, create a cronjob
{{ $image := .Values.image }}
{{ $resources := .Values.resources }}
{{ $executor := .Values.executor }}

{{ $labels := include "datapipe.labels" . }}

{{- range .Values.loops }}

apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ .name }}
labels:
{{- $labels | nindent 4 }}
spec:
schedule: "{{ .schedule }}"
concurrencyPolicy: Forbid
Expand All @@ -19,7 +20,7 @@ spec:
spec:
containers:
- name: {{ .name }}
image: "{{ $image.repository }}:{{ $image.tag }}"
image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag }}"
command:
- datapipe
- step
Expand All @@ -28,17 +29,24 @@ spec:
{{- end }}
{{- if .executor }}
- --executor={{ .executor }}
{{- else if $executor }}
- --executor={{ $executor }}
{{- else if $.Values.executor }}
- --executor={{ $.Values.executor }}
{{- end }}
{{- if .labels }}
- --labels={{ .labels }}
{{- end }}
- run
env:
{{- if $.Values.env }}
{{- $.Values.env | toYaml | nindent 12 }}
{{ end }}
{{- if .env }}
{{- .env | toYaml | nindent 12 }}
{{ end }}
{{- if .resources }}
resources: {{ .resources | toYaml | nindent 14 }}
{{- else if $resources }}
resources: {{ $resources | toYaml | nindent 14 }}
{{- else if $.Values.resources }}
resources: {{ $.Values.resources | toYaml | nindent 14 }}
{{- end }}
ports:
- name: ray-dash-http
Expand Down
78 changes: 78 additions & 0 deletions charts/datapipe/tests/__snapshot__/simple_test.yaml.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
All manifests should match snapshot:
1: |
apiVersion: batch/v1
kind: CronJob
metadata:
labels:
app.kubernetes.io/instance: datapipe
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: datapipe
app.kubernetes.io/version: 1.16.0
helm.sh/chart: datapipe-0.1.0
name: loop-hourly
spec:
concurrencyPolicy: Forbid
jobTemplate:
spec:
template:
spec:
containers:
- command:
- datapipe
- step
- --labels=stage=loop-hourly
- run
env:
- name: TEST_ENV
value: test
image: test-datapipe:1.1.1
name: loop-hourly
ports:
- containerPort: 8265
name: ray-dash-http
restartPolicy: OnFailure
schedule: 0 * * * *
2: |
apiVersion: batch/v1
kind: CronJob
metadata:
labels:
app.kubernetes.io/instance: datapipe
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: datapipe
app.kubernetes.io/version: 1.16.0
helm.sh/chart: datapipe-0.1.0
name: loop-daily
spec:
concurrencyPolicy: Forbid
jobTemplate:
spec:
template:
spec:
containers:
- command:
- datapipe
- step
- --labels=stage=loop-daily
- run
env:
- name: TEST_ENV
value: test
image: test-datapipe:1.1.1
name: loop-daily
ports:
- containerPort: 8265
name: ray-dash-http
restartPolicy: OnFailure
schedule: 0 0 * * *
3: |
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/instance: datapipe
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: datapipe
app.kubernetes.io/version: 1.16.0
helm.sh/chart: datapipe-0.1.0
name: datapipe
17 changes: 17 additions & 0 deletions charts/datapipe/tests/simple-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# yaml-language-server: $schema=../values.schema.json

image:
repository: test-datapipe
tag: 1.1.1

env:
- name: TEST_ENV
value: "test"

loops:
- name: loop-hourly
schedule: "0 * * * *"
labels: "stage=loop-hourly"
- name: loop-daily
schedule: "0 0 * * *"
labels: "stage=loop-daily"
19 changes: 19 additions & 0 deletions charts/datapipe/tests/simple_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
suite: datapipe simple case

values:
- simple-values.yaml

chart:
version: 0.1.0

release:
name: datapipe
namespace: default

tests:
- it: All manifests should match snapshot
templates:
- loops-cronjob.yaml
- serviceaccount.yaml
asserts:
- matchSnapshot: {}

0 comments on commit 847b0ff

Please sign in to comment.