Skip to content

Commit

Permalink
feat(annotations): add global annotations (#356)
Browse files Browse the repository at this point in the history
* feat(annotations): add global annotations

* bump chart

* fix checksum for unit tests

* use global context

* add to readme

* fix yaml for range

* add global annotation to new pvc template
  • Loading branch information
GMartinez-Sisti committed Mar 6, 2024
1 parent 4cdb790 commit ba2d710
Show file tree
Hide file tree
Showing 26 changed files with 1,987 additions and 1,887 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ The following options are supported. See [values.yaml](/charts/atlantis/values.y
| `environmentRaw` | Array environment variables in plain Kubernetes yaml format. See `values.yaml` for example. | `[]` |
| `environmentSecrets` | Array of Kubernetes secrets that can be used to set environment variables. See `values.yaml` for example. | `{}` |
| `environment` | Map of environment variables for the container. | `{}` |
| `extraAnnotations` | These annotations will be added to all the resources | `{}` |
| `extraArgs` | Add additional arguments to the atlantis server | `[]` |
| `extraContainers` | Additional containers to use and depends of use cases. | `[]` |
| `extraManifests` | Add additional manifests to deploy | `[]` |
Expand Down
2 changes: 1 addition & 1 deletion charts/atlantis/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
appVersion: v0.27.0
description: A Helm chart for Atlantis https://www.runatlantis.io
name: atlantis
version: 4.22.0
version: 4.23.0
keywords:
- terraform
home: https://www.runatlantis.io
Expand Down
12 changes: 8 additions & 4 deletions charts/atlantis/templates/configmap-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{{- if .Values.config -}}
{{- if .Values.config }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "atlantis.fullname" . }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
atlantis.yaml: |
{{ .Values.config | indent 4 }}
{{- end -}}
{{- .Values.config | nindent 4 }}
{{- end }}
8 changes: 6 additions & 2 deletions charts/atlantis/templates/configmap-init-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ kind: ConfigMap
metadata:
name: {{ template "atlantis.fullname" . }}-init-config
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
init-config.sh: |
{{- .Values.initConfig.script | nindent 4 }}
{{- end -}}
{{- end }}
12 changes: 8 additions & 4 deletions charts/atlantis/templates/configmap-repo-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{{- if .Values.repoConfig -}}
{{- if .Values.repoConfig }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "atlantis.fullname" . }}-repo-config
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
repos.yaml: |
{{ .Values.repoConfig | indent 4 }}
{{- end -}}
{{- .Values.repoConfig | indent 4 }}
{{- end }}
31 changes: 18 additions & 13 deletions charts/atlantis/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.ingress.enabled -}}
{{- if .Values.ingress.enabled }}
{{- $apiVersion := .Values.ingress.apiVersion }}
{{- if and $apiVersion (or (eq $apiVersion "networking.k8s.io/v1") (eq $apiVersion "networking.k8s.io/v1beta1") (eq $apiVersion "extensions/v1beta1")) -}}
{{- else -}}
Expand All @@ -19,22 +19,27 @@ kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- if .Values.ingress.labels }}
{{ toYaml .Values.ingress.labels | indent 4 }}
{{- end }}
{{- with .Values.ingress.annotations }}
{{- include "atlantis.labels" . | nindent 4 }}
{{- if .Values.ingress.labels }}
{{- toYaml .Values.ingress.labels | nindent 4 }}
{{- end }}
{{- if or .Values.ingress.annotations .Values.extraAnnotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
{{- with .Values.ingress.annotations }}
{{- toYaml . | indent 4 }}
{{- end }}
{{- with .Values.extraAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
spec:
{{- if .Values.ingress.ingressClassName }}
{{- if .Values.ingress.ingressClassName }}
ingressClassName: {{ .Values.ingress.ingressClassName }}
{{- end }}
{{- if .Values.ingress.tls }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{ toYaml .Values.ingress.tls | indent 4 }}
{{- end }}
{{- toYaml .Values.ingress.tls | nindent 4 }}
{{- end }}
rules:
{{- if not .Values.ingress.hosts }}
-
Expand Down
21 changes: 13 additions & 8 deletions charts/atlantis/templates/podmonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,25 @@ kind: PodMonitoring
metadata:
name: {{ template "atlantis.fullname" . }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.service.annotations }}
{{- include "atlantis.labels" . | nindent 4 }}
{{- if or .Values.service.annotations .Values.extraAnnotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
{{- with .Values.service.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.extraAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ template "atlantis.name" . }}
release: {{ .Release.Name }}
{{- if .Values.podTemplate.labels }}
{{ toYaml .Values.podTemplate.labels | indent 6 }}
{{- end }}
{{- if .Values.podTemplate.labels }}
{{- toYaml .Values.podTemplate.labels | nindent 6 }}
{{- end }}
endpoints:
- port: atlantis
interval: {{ .Values.podMonitor.interval }}
{{- end -}}
{{- end }}
10 changes: 7 additions & 3 deletions charts/atlantis/templates/pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ template "atlantis.fullname" . }}-data
labels:
{{- include "atlantis.labels" . | nindent 2 }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
accessModes: {{ .Values.volumeClaim.accessModes| toYaml | nindent 2 }}
resources:
Expand All @@ -13,6 +17,6 @@ spec:
# It deletes the repo after the pull request is merged.
storage: {{ .Values.volumeClaim.dataStorage }}
{{- if .Values.volumeClaim.storageClassName }}
storageClassName: {{ .Values.volumeClaim.storageClassName }}
storageClassName: {{ .Values.volumeClaim.storageClassName }}
{{- end }}
{{- end }}
10 changes: 7 additions & 3 deletions charts/atlantis/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{{- if .Values.enableKubernetesBackend -}}
{{- if .Values.enableKubernetesBackend }}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ template "atlantis.fullname" . }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
rules:
- apiGroups:
- coordination.k8s.io
Expand All @@ -20,4 +24,4 @@ rules:
resources:
- secrets
verbs: ['*']
{{- end -}}
{{- end }}
10 changes: 7 additions & 3 deletions charts/atlantis/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{{- if .Values.enableKubernetesBackend -}}
{{- if .Values.enableKubernetesBackend }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ template "atlantis.fullname" . }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
subjects:
- kind: ServiceAccount
name: {{ template "atlantis.serviceAccountName" . }}
Expand All @@ -13,4 +17,4 @@ roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ template "atlantis.fullname" . }}
{{- end -}}
{{- end }}
6 changes: 5 additions & 1 deletion charts/atlantis/templates/secret-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ kind: Secret
metadata:
name: {{ template "atlantis.apiSecretName" . }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
apisecret: {{ .Values.api.secret | b64enc }}
{{- end }}
14 changes: 9 additions & 5 deletions charts/atlantis/templates/secret-aws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ kind: Secret
metadata:
name: {{ template "atlantis.fullname" . }}-aws
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
{{- if .Values.aws.credentials }}
{{- if .Values.aws.credentials }}
credentials: {{ .Values.aws.credentials | b64enc }}
{{- end }}
{{- if .Values.aws.config }}
{{- end }}
{{- if .Values.aws.config }}
config: {{ .Values.aws.config | b64enc }}
{{- end }}
{{- end }}
{{- end }}
6 changes: 5 additions & 1 deletion charts/atlantis/templates/secret-basic-auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ kind: Secret
metadata:
name: {{ template "atlantis.fullname" . }}-basic-auth
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
username: {{ .Values.basicAuth.username | b64enc }}
password: {{ .Values.basicAuth.password | b64enc }}
Expand Down
8 changes: 6 additions & 2 deletions charts/atlantis/templates/secret-gitconfig.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{{- if .Values.gitconfig}}
{{- if .Values.gitconfig }}
apiVersion: v1
kind: Secret
metadata:
name: {{ template "atlantis.fullname" . }}-gitconfig
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
gitconfig: {{ .Values.gitconfig | b64enc }}
{{- end }}
8 changes: 6 additions & 2 deletions charts/atlantis/templates/secret-netrc.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{{- if .Values.netrc}}
{{- if .Values.netrc }}
apiVersion: v1
kind: Secret
metadata:
name: {{ template "atlantis.fullname" . }}-netrc
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
netrc: {{ .Values.netrc | b64enc }}
{{- end }}
6 changes: 5 additions & 1 deletion charts/atlantis/templates/secret-redis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ kind: Secret
metadata:
name: {{ template "atlantis.fullname" . }}-redis
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
password: {{ .Values.redis.password | b64enc }}
{{- end }}
13 changes: 8 additions & 5 deletions charts/atlantis/templates/secret-service-account.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{{- $all := . -}}
{{ range $name, $secret := .Values.serviceAccountSecrets }}
{{- range $name, $secret := .Values.serviceAccountSecrets }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ $name }}
labels:
component: service-account-secret
{{- include "atlantis.labels" $all | nindent 4 }}
{{- include "atlantis.labels" $ | nindent 4 }}
{{- with $.Values.extraAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
service-account.json: {{ $secret }}
---
{{ end }}
{{- end }}
16 changes: 10 additions & 6 deletions charts/atlantis/templates/secret-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,32 @@ kind: Secret
metadata:
name: {{ template "atlantis.fullname" . }}-webhook
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
{{- if .Values.githubApp }}
key.pem: {{ required "githubApp.key is required if githubApp configuration is specified." .Values.githubApp.key | b64enc }}
github_secret: {{ required "githubApp.secret is required if githubApp configuration is specified." .Values.githubApp.secret | b64enc }}
{{- end}}
{{- end }}
{{- if .Values.github.user }}
github_token: {{ required "github.token is required if github configuration is specified." .Values.github.token | b64enc }}
github_secret: {{ required "github.secret is required if github configuration is specified." .Values.github.secret | b64enc }}
{{- end}}
{{- end }}
{{- if .Values.gitlab }}
gitlab_token: {{ required "gitlab.token is required if gitlab configuration is specified." .Values.gitlab.token | b64enc }}
gitlab_secret: {{ required "gitlab.secret is required if gitlab configuration is specified." .Values.gitlab.secret | b64enc }}
{{- end}}
{{- end }}
{{- if .Values.bitbucket }}
bitbucket_token: {{ required "bitbucket.token is required if bitbucket configuration is specified." .Values.bitbucket.token | b64enc }}
{{- if .Values.bitbucket.baseURL }}
bitbucket_secret: {{ required "bitbucket.secret is required if bitbucket.baseURL is specified." .Values.bitbucket.secret | b64enc }}
{{- end}}
{{- end }}
{{- end }}
{{- if .Values.azuredevops }}
azuredevops_token: {{ required "azuredevops.token is required if azuredevops configuration is specified." .Values.azuredevops.token | b64enc }}
azuredevops_webhook_password: {{ required "azuredevops.webhookPassword is required if azuredevops configuration is specified." .Values.azuredevops.webhookPassword | b64enc }}
{{- end}}
{{- end }}
{{- end }}
Loading

0 comments on commit ba2d710

Please sign in to comment.