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

feat: introduce namespaceOverride #126

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
13 changes: 13 additions & 0 deletions charts/localstack/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ If release name contains chart name it will be used as a full name.
{{- end }}
{{- end }}

{{/*
Create a default namespace for the app.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If a common.names.namespace is provided, it will be used as the namespace.
*/}}
{{- define "common.names.namespace" -}}
{{- if .Values.common.names.namespaces }}
{{- .Values.common.names.namespaces | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- .Release.Namespace | quote }}
{{- end }}
{{- end }}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a bit of a misunderstanding. My point in the previous comments is that we can just directly use common.names.namespace (exactly the same way as the Novu chart) because this is defined in the bitnami commons (which we also have as a dependency) here: https://github.com/bitnami/charts/blob/8ecfbadb2b93576772fd134aeedcb13ad20221d2/bitnami/common/templates/_names.tpl#L59-L64

So you can just remove this section, just use the (already by the subchart defined) common.names.namespaces everywhere (as you are already 🥳), and use the value namespaceOverride in the values.

Suggested change
{{/*
Create a default namespace for the app.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If a common.names.namespace is provided, it will be used as the namespace.
*/}}
{{- define "common.names.namespace" -}}
{{- if .Values.common.names.namespaces }}
{{- .Values.common.names.namespaces | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- .Release.Namespace | quote }}
{{- end }}
{{- end }}

Copy link
Author

@khaledCNTXT khaledCNTXT Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we haven't defined our own 'common', Novu will not permit us to update it. Please try downloading the Novu repository and give it a try

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean with "Novu will not permit us to update it"? Can't you just set arbitrary values for transitive charts? Wouldn't it just be novu.localstack.namespaceOverride?

{{/*
Create chart name and version as used by the chart label.
*/}}
Expand Down
2 changes: 1 addition & 1 deletion charts/localstack/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "localstack.fullname" . }}-init-scripts-config
namespace: {{ .Release.Namespace | quote }}
namespace: {{ include "common.names.namespace" . }}
labels:
{{- include "localstack.labels" . | nindent 4 }}
annotations:
Expand Down
2 changes: 1 addition & 1 deletion charts/localstack/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "localstack.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
namespace: {{ include "common.names.namespace" . }}
labels:
{{- include "localstack.labels" . | nindent 4 }}
annotations:
Expand Down
2 changes: 1 addition & 1 deletion charts/localstack/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}
namespace: {{ .Release.Namespace | quote }}
namespace: {{ include "common.names.namespace" . }}
labels:
{{- include "localstack.labels" . | nindent 4 }}
annotations:
Expand Down
2 changes: 1 addition & 1 deletion charts/localstack/templates/pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ include "common.names.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
namespace: {{ include "common.names.namespace" . }}
labels:
{{- include "localstack.labels" . | nindent 4 }}
annotations:
Expand Down
2 changes: 1 addition & 1 deletion charts/localstack/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: {{ .Release.Namespace | quote }}
namespace: {{ include "common.names.namespace" . }}
name: {{ include "localstack.roleName" . }}
labels:
{{- include "localstack.labels" . | nindent 4 }}
Expand Down
2 changes: 1 addition & 1 deletion charts/localstack/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "localstack.roleBindingName" . }}
namespace: {{ .Release.Namespace | quote }}
namespace: {{ include "common.names.namespace" . }}
labels:
{{- include "localstack.labels" . | nindent 4 }}
subjects:
Expand Down
2 changes: 1 addition & 1 deletion charts/localstack/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
kind: Service
metadata:
name: {{ include "localstack.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
namespace: {{ include "common.names.namespace" . }}
labels:
{{- include "localstack.labels" . | nindent 4 }}
annotations:
Expand Down
2 changes: 1 addition & 1 deletion charts/localstack/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "localstack.serviceAccountName" . }}
namespace: {{ .Release.Namespace | quote }}
namespace: {{ include "common.names.namespace" . }}
labels:
{{- include "localstack.labels" . | nindent 4 }}
annotations:
Expand Down
5 changes: 5 additions & 0 deletions charts/localstack/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

common:
names:
namespaces: ""

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we can use common.names.namespaces from the subchart, this isn't necessary:

Suggested change
common:
names:
namespaces: ""

## @param extraDeploy Extra objects to deploy (value evaluated as a template)
##
extraDeploy: []
Expand Down Expand Up @@ -263,3 +267,4 @@ volumeMounts: []
## @param priorityClassName Allows you to set the priorityClassName for the pod
## The default is not to set any priorityClassName
# priorityClassName: ""