Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
Merge 22db918 into fd3fcb5
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Manno committed Feb 5, 2020
2 parents fd3fcb5 + 22db918 commit 1c4f124
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 26 deletions.
11 changes: 0 additions & 11 deletions deploy/helm/quarks-job/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,3 @@ Create the name of the quarks-job service account to use
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Namespace of the quarks-job role.
*/}}
{{- define "quarks-job.roleNamespace" -}}
{{- if .Values.global.operator.watchNamespace }}
namespace: {{ .Values.global.operator.watchNamespace }}
{{- else}}
namespace: {{ .Release.Namespace }}
{{- end }}
{{- end -}}
2 changes: 1 addition & 1 deletion deploy/helm/quarks-job/templates/role-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "quarks-job.fullname" . }}
{{- template "quarks-job.roleNamespace" . }}
namespace: {{ .Values.global.operator.watchNamespace }}
subjects:
- kind: ServiceAccount
name: {{ template "quarks-job.serviceAccountName" . }}
Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/quarks-job/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: Role
metadata:
creationTimestamp: null
name: {{ template "quarks-job.fullname" . }}
{{- template "quarks-job.roleNamespace" . }}
namespace: {{ .Values.global.operator.watchNamespace }}
rules:
- apiGroups:
- ""
Expand Down
40 changes: 27 additions & 13 deletions pkg/kube/controllers/quarksjob/output_persistor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -239,6 +240,8 @@ var _ = Describe("OutputPersistor", func() {
})

Context("when output persistence with fan out is configured", func() {
var tmpDir string

provideContent := func(data map[string]map[string]string) []byte {
tmp := map[string]string{}
for k, v := range data {
Expand All @@ -255,29 +258,40 @@ var _ = Describe("OutputPersistor", func() {
}

BeforeEach(func() {
var err error

tmpDir, err = ioutil.TempDir("/tmp", "testcase")
Expect(err).ToNot(HaveOccurred())
Expect(os.Mkdir(filepath.Join(tmpDir, "busybox"), 0755)).ToNot(HaveOccurred())

_, log := helper.NewTestLogger()
po = quarksjob.NewOutputPersistor(log, namespace, pod.Name, clientSet, versionedClientSet, tmpDir)

qJob.Spec.Output = &qjv1a1.Output{
OutputMap: qjv1a1.OutputMap{
"busybox": qjv1a1.NewFileToSecrets("provides.json", "link-nats-deployment", false),
},
}

Expect(ioutil.WriteFile("/tmp/busybox/provides.json", []byte(provideContent(map[string]map[string]string{
"nats-nats": map[string]string{
"nats.user": "admin",
"nats.password": "changeme",
"nats.port": "1337",
},
"nats-nuts": map[string]string{
"nats.user": "udmin",
"nats.password": "chungeme",
"nats.port": "1337",
},
})), 0640)).NotTo(HaveOccurred())
Expect(ioutil.WriteFile(
filepath.Join(tmpDir, "busybox", "provides.json"),
[]byte(provideContent(map[string]map[string]string{
"nats-nats": {
"nats.user": "admin",
"nats.password": "changeme",
"nats.port": "1337",
},
"nats-nuts": {
"nats.user": "udmin",
"nats.password": "chungeme",
"nats.port": "1337",
},
})), 0640)).NotTo(HaveOccurred())
})

AfterEach(func() {
qJob.Spec.Output = nil
Expect(os.Remove("/tmp/busybox/provides.json")).ToNot(HaveOccurred())
Expect(os.RemoveAll(tmpDir)).ToNot(HaveOccurred())
})

It("creates a secret per each key/value of the given input file", func() {
Expand Down

0 comments on commit 1c4f124

Please sign in to comment.