Skip to content

Commit

Permalink
fix(chart): explicitly set namespace based on release
Browse files Browse the repository at this point in the history
On `helm install` or `upgrade`, the `--namespace` flag is respected
regardless. However, when using this chart for static templating, the
`--namespace` flag is ignored because the templates do not explicitly
set `.metadata.namespace` to `.Release.Namespace`, making it cumbersome
to customize the namespace.

Signed-off-by: valorl <[email protected]>
  • Loading branch information
valorl committed Nov 4, 2024
1 parent 8bcff6a commit debef03
Show file tree
Hide file tree
Showing 24 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions charts/atlantis/templates/configmap-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "atlantis.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/configmap-gitconfig-init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "atlantis.fullname" . }}-gitconfig-init
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/configmap-init-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "atlantis.fullname" . }}-init-config
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/configmap-repo-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "atlantis.fullname" . }}-repo-config
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ apiVersion: {{ $apiVersion }}
kind: Ingress
metadata:
name: {{ $fullName }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- if .Values.ingress.labels }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/podmonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: monitoring.googleapis.com/v1
kind: PodMonitoring
metadata:
name: {{ template "atlantis.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- if or .Values.service.annotations .Values.extraAnnotations }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ template "atlantis.fullname" . }}-data
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ template "atlantis.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ template "atlantis.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/secret-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ template "atlantis.apiSecretName" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/secret-aws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ template "atlantis.fullname" . }}-aws
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/secret-basic-auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ template "atlantis.fullname" . }}-basic-auth
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/secret-gitconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ template "atlantis.fullname" . }}-gitconfig
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/secret-netrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ template "atlantis.fullname" . }}-netrc
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/secret-redis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ template "atlantis.fullname" . }}-redis
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/secret-service-account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ $name }}
namespace: {{ .Release.Namespace }}
labels:
component: service-account-secret
{{- include "atlantis.labels" $ | nindent 4 }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/secret-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ template "atlantis.fullname" . }}-webhook
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.extraAnnotations }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: v1
kind: Service
metadata:
name: {{ template "atlantis.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- if or .Values.service.annotations .Values.extraAnnotations }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "atlantis.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- if or .Values.serviceAccount.annotations .Values.extraAnnotations }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "atlantis.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.servicemonitor.additionalLabels }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ template "atlantis.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.statefulSet.labels }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "atlantis.fullname" . }}-tests
namespace: {{ .Release.Namespace }}
data:
tests.bats: |-
setup() {
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/tests/test-atlantis-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Pod
metadata:
name: "{{ .Release.Name }}-ui-test"
namespace: {{ .Release.Namespace }}
annotations:
helm.sh/hook: test
{{- with .Values.test.annotations }}
Expand Down
1 change: 1 addition & 0 deletions charts/atlantis/templates/webhook-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ apiVersion: {{ $apiVersion }}
kind: Ingress
metadata:
name: {{ $fullName }}-secondary
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlantis.labels" . | nindent 4 }}
{{- with .Values.webhook_ingress.labels }}
Expand Down

0 comments on commit debef03

Please sign in to comment.