Skip to content

Commit

Permalink
dynamically sets job label w/ group name (#229)
Browse files Browse the repository at this point in the history
update tests
  • Loading branch information
stinkyfingers authored Jan 31, 2022
1 parent 734ecc2 commit 30f00e5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 22 deletions.
40 changes: 22 additions & 18 deletions internal/chart/chartutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,29 @@ func TestBufferedFiles(t *testing.T) {
"test.yaml": "name: {{ App.spec.name }}",
}
values := jobValues{
Job: ketchv1.JobSpec{
Version: "v1",
Type: "Job",
Name: "testjob",
Framework: "myframework",
Description: "this is a test",
Parallelism: 2,
Completions: 2,
Suspend: false,
BackoffLimit: 4,
Containers: []ketchv1.Container{
{
Name: "test",
Image: "ubuntu",
Command: []string{"pwd"},
Job: Job{
JobSpec: ketchv1.JobSpec{
Version: "v1",
Type: "Job",
Name: "testjob",
Framework: "myframework",
Description: "this is a test",
Parallelism: 2,
Completions: 2,
Suspend: false,
BackoffLimit: 4,
Containers: []ketchv1.Container{
{
Name: "test",
Image: "ubuntu",
Command: []string{"pwd"},
},
},
Policy: ketchv1.Policy{
RestartPolicy: "Never",
},
},
Policy: ketchv1.Policy{
RestartPolicy: "Never",
},
Group: "theketch.io",
},
}

Expand All @@ -61,6 +64,7 @@ appVersion: v1
name: test
description: this is a test
framework: myframework
group: theketch.io
name: testjob
parallelism: 2
policy:
Expand Down
12 changes: 10 additions & 2 deletions internal/chart/job_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,22 @@ type JobChart struct {
}

type jobValues struct {
Job ketchv1.JobSpec `json:"job"`
Job Job `json:"job"`
}

type Job struct {
ketchv1.JobSpec
Group string `json:"group"`
}

// NewJobChart returns a JobChart instance from a ketchv1.Job and []Option
func NewJobChart(job *ketchv1.Job, opts ...Option) *JobChart {
jobChart := &JobChart{
values: jobValues{
Job: job.Spec,
Job: Job{
JobSpec: job.Spec,
Group: ketchv1.Group,
},
},
}
options := &Options{}
Expand Down
5 changes: 4 additions & 1 deletion internal/chart/job_chart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ func TestNewJobChart(t *testing.T) {
}
expected := &JobChart{
values: jobValues{
Job: testJob.Spec,
Job: Job{
JobSpec: testJob.Spec,
Group: "theketch.io",
},
},
templates: map[string]string{"test.yaml": "Lots of values"},
}
Expand Down
2 changes: 1 addition & 1 deletion internal/templates/job/yamls/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: batch/v1
kind: Job
metadata:
labels:
theketch.io/app-name: {{ $.Values.job.name | quote }}
{{ $.Values.job.group }}/job-name: {{ $.Values.job.name | quote }}
name: {{ $.Values.job.name | quote }}
spec:
{{- if $.Values.job.parallelism }}
Expand Down

0 comments on commit 30f00e5

Please sign in to comment.