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

Add template for ServiceAccount annotations #239

Merged
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
4 changes: 4 additions & 0 deletions charts/opa-kube-mgmt/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "opa.serviceAccountName" .}}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{ toYaml . }}
{{- end }}
labels:
app: {{ template "opa.fullname" . }}
chart: {{ template "opa.chart" . }}
Expand Down
8 changes: 8 additions & 0 deletions charts/opa-kube-mgmt/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
"enabled": {"type": "boolean", "default": true},
"image": {"$ref": "#/definitions/image"}
}
},
"serviceAccount": {
"type": "object",
"properties": {
"create": {"type": "boolean", "default": true},
"annotations": {"type": "object", "additionalProperties": {"type": "string"}, "default": {}},
"name": {"type": ["string", "null"], "default": null}
}
}
}
}
2 changes: 2 additions & 0 deletions charts/opa-kube-mgmt/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ rbac:
serviceAccount:
# Specifies whether a ServiceAccount should be created
create: true
# Annotations for the ServiceAccount
annotations: {}
# The name of the ServiceAccount to use.
# If not set and create is true, a name is generated using the fullname template
name:
Expand Down
15 changes: 15 additions & 0 deletions test/lint/sa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
suite: lint serviceaccount
templates:
- fake.yaml
tests:
- it: annotations not string
set:
serviceAccount:
annotations:
foo: 1
asserts:
- failedTemplate:
errorMessage: |
values don't meet the specifications of the schema(s) in the following chart(s):
opa-kube-mgmt:
- serviceAccount.annotations.foo: Invalid type. Expected: string, given: integer
19 changes: 19 additions & 0 deletions test/unit/sa_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
suite: test serviceaccount annotations
templates:
- serviceaccount.yaml
tests:
- it: should omit serviceaccount annotations by default
asserts:
- notExists:
path: metadata.annotations
- it: should render serviceaccount annotations when provided
set:
serviceAccount:
annotations:
foo: bar
asserts:
- exists:
path: metadata.annotations
- equal:
path: metadata.annotations.foo
value: bar