Skip to content

Commit

Permalink
feat: template crd
Browse files Browse the repository at this point in the history
  • Loading branch information
vsukhin committed Sep 5, 2023
1 parent 8472004 commit 4862ae1
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 0 deletions.
37 changes: 37 additions & 0 deletions charts/testkube-api/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -575,3 +575,40 @@ rules:
- patch
- update
{{ end }}

---

apiVersion: {{ include "global.capabilities.rbac.apiVersion" . }}
kind: Role
metadata:
name: template-role-{{ .Release.Name }}
labels: {{- include "testkube-api.labels" . | nindent 4 }}
{{- if .Values.global.labels }}
{{- include "global.tplvalues.render" ( dict "value" .Values.global.labels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.global.annotations}}
annotations: {{- include "global.tplvalues.render" ( dict "value" .Values.global.annotations "context" $ ) | nindent 4 }}
{{- end }}
rules:
- apiGroups:
- tests.testkube.io
resources:
- templates
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- deletecollection
- apiGroups:
- tests.testkube.io
resources:
- templates/status
verbs:
- get
- patch
- update
{{ end }}
22 changes: 22 additions & 0 deletions charts/testkube-api/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,25 @@ subjects:
- kind: ServiceAccount
name: {{ include "testkube-api.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}

---

apiVersion: {{ include "global.capabilities.rbac.apiVersion" . }}
kind: RoleBinding
metadata:
name: templates-crb-{{ .Release.Name }}
labels: {{- include "testkube-api.labels" . | nindent 4 }}
{{- if .Values.global.labels }}
{{- include "global.tplvalues.render" ( dict "value" .Values.global.labels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.global.annotations}}
annotations: {{- include "global.tplvalues.render" ( dict "value" .Values.global.annotations "context" $ ) | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: template-role-{{ .Release.Name }}
subjects:
- kind: ServiceAccount
name: {{ include "testkube-api.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ spec:
job_template:
description: Job template to launch executor
type: string
jobTemplateReference:
description: name of the template resource
type: string
meta:
description: Meta data about executor
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ spec:
payloadTemplate:
description: golang based template for notification payload
type: string
payloadTemplateReference:
description: name of the template resource
type: string
selector:
description: Labels to filter for tests and test suites
type: string
Expand Down
26 changes: 26 additions & 0 deletions charts/testkube-operator/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,32 @@ rules:
- get
- patch
- update
- apiGroups:
- tests.testkube.io
resources:
- templates
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- tests.testkube.io
resources:
- templates/finalizers
verbs:
- update
- apiGroups:
- tests.testkube.io
resources:
- templates/status
verbs:
- get
- patch
- update

---

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{{ if .Values.installCRD }}
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: templates.tests.testkube.io
spec:
group: tests.testkube.io
names:
kind: Template
listKind: TemplateList
plural: templates
singular: template
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
description: Template is the Schema for the Templates API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: TemplateSpec defines the desired state of Template
properties:
body:
description: template body to use
type: string
type:
description: TemplateType defines template type by purpose
enum:
- job
- container
- cronjob
- scraper
- pvc
- webhook
type: string
required:
- body
- type
type: object
status:
description: TemplateStatus defines the observed state of Template
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
{{ end }}
15 changes: 15 additions & 0 deletions charts/testkube-operator/templates/tests.testkube.io_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,9 @@ spec:
cronJobTemplate:
description: cron job template extensions
type: string
cronJobTemplateReference:
description: name of the template resource
type: string
envConfigMaps:
description: config map references
items:
Expand Down Expand Up @@ -588,6 +591,9 @@ spec:
jobTemplate:
description: job template extensions
type: string
jobTemplateReference:
description: name of the template resource
type: string
name:
description: test execution custom name
type: string
Expand All @@ -605,9 +611,18 @@ spec:
preRunScript:
description: script to run before test execution
type: string
pvcTemplate:
description: pvc template extensions
type: string
pvcTemplateReference:
description: name of the template resource
type: string
scraperTemplate:
description: scraper template extensions
type: string
scraperTemplateReference:
description: name of the template resource
type: string
secretEnvs:
additionalProperties:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,9 @@ spec:
cronJobTemplate:
description: cron job template extensions
type: string
cronJobTemplateReference:
description: name of the template resource
type: string
executionLabels:
additionalProperties:
type: string
Expand All @@ -636,6 +639,12 @@ spec:
httpsProxy:
description: https proxy for executor containers
type: string
jobTemplate:
description: job template extensions
type: string
jobTemplateReference:
description: name of the template resource
type: string
labels:
additionalProperties:
type: string
Expand All @@ -648,6 +657,18 @@ spec:
description: test kubernetes namespace (\"testkube\" when not
set)
type: string
pvcTemplate:
description: pvc template extensions
type: string
pvcTemplateReference:
description: name of the template resource
type: string
scraperTemplate:
description: scraper template extensions
type: string
scraperTemplateReference:
description: name of the template resource
type: string
secretUUID:
description: secret uuid
type: string
Expand Down

0 comments on commit 4862ae1

Please sign in to comment.