Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically sets job label w/ group name #229

Merged
merged 1 commit into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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