Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Fix CronJob manifest verification #1133

Merged
merged 1 commit into from
Jun 11, 2018
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
2 changes: 1 addition & 1 deletion cluster/kubernetes/resource/cronjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type CronJobSpec struct {
Spec struct {
Template PodTemplate
}
}
} `yaml:"jobTemplate"`
}

func (c CronJob) Containers() []resource.Container {
Expand Down
33 changes: 33 additions & 0 deletions cluster/kubernetes/resource/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"reflect"
"testing"

"github.com/stretchr/testify/assert"

"github.com/weaveworks/flux"
"github.com/weaveworks/flux/cluster/kubernetes/testfiles"
"github.com/weaveworks/flux/resource"
Expand Down Expand Up @@ -119,6 +121,37 @@ data:
}
}

func TestParseCronJob(t *testing.T) {
doc := `---
apiVersion: batch/v1beta1
kind: CronJob
metadata:
namespace: default
name: weekly-curl-homepage
spec:
jobTemplate:
spec:
template:
spec:
containers:
- name: weekly-curl-homepage
image: centos:7 # Has curl installed by default
`
objs, err := ParseMultidoc([]byte(doc), "test")
assert.NoError(t, err)

obj, ok := objs["default:cronjob/weekly-curl-homepage"]
assert.True(t, ok)
cj, ok := obj.(*CronJob)
assert.True(t, ok)

containers := cj.Spec.JobTemplate.Spec.Template.Spec.Containers
if assert.Len(t, containers, 1) {
assert.Equal(t, "centos:7", containers[0].Image)
assert.Equal(t, "weekly-curl-homepage", containers[0].Name)
}
}

func TestUnmarshalList(t *testing.T) {
doc := `---
kind: List
Expand Down