Skip to content

Commit

Permalink
add ability to support free entry of environment variables for nango-…
Browse files Browse the repository at this point in the history
…server (#10)

This PR addresses [Allow Arbitrary Environment Variables to be set for
nango-server](#9).
I've attached a screenshot of a basicauth login below:

<img width="1050" alt="nango-basicauth-login"
src="https://github.com/user-attachments/assets/be457c83-1f5e-4237-bc82-4fb51ecebb54"
/>

Note that there are a _number_ of ways to support environment variables
within helm charts - two options which I tested/considered are below:

1. Free-entry configuration - where a user would only provide an `env`
value that renders valid YAML. This is rendered utilizing the following:

```
{{- if .Values.server.env }}
{{- toYaml .Values.server.env | nindent 12 }}
{{- end }}
```

2. Iterative configuration (which is what I've seen used more
frequently) - where a user provides a list composed of `name` and
`value` or `valueFrom` fields which (I thought) offered a greater deal
of validation (see "A Note on Iterative Configuration" below).

# A Note on Iterative Configuration

I was open to utilizing this as it was/is common within the
kubernetes/helm community and a popular suggestion on AI sites. What I
discovered was this was _worse_ than simply accepting "free entry" as it
_modified_ the YAML but did not reject it - an example is below:

```
{{- range .Values.server.env }}
- name: {{ .name }}
  {{- if .value }}
  value: {{ .value | quote }}
  {{- else if .valueFrom }}
  valueFrom: {{ toYaml .valueFrom | nindent 16 }}
  {{- end }}
{{- end }}
```

When given:

```
env:
  - namea: FLAG_AUTH_ENABLED
    value: "false"
  - name: NANGO_DASHBOARD_USERNAME
    value: nango
  - name: NANGO_DASHBOARD_PASSWORD
    valueFroma:
      secretKeyRef:
        name: nango-secrets
        key: nango-dashboard-password
```

Would render:

```
- name: 
  value: "false"
- name: NANGO_DASHBOARD_USERNAME
  value: "nango"
- name: NANGO_DASHBOARD_PASSWORD
```
  • Loading branch information
colinbjohnson authored Jan 17, 2025
1 parent c1a1dc7 commit afb6d4b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions charts/nango/templates/server/server-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ spec:
key: mailgun-api-key
- name: SERVER_PORT
value: "{{ .Values.server.SERVER_PORT }}"
{{- if .Values.server.env }}
{{- toYaml .Values.server.env | nindent 12 }}
{{- end }}
volumeMounts:
{{- if .Values.shared.useVolumeForFlows }}
- mountPath: {{ .Values.shared.flows_path }}
Expand Down
12 changes: 12 additions & 0 deletions example-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ elasticsearch:
server:
name: nango-server
replicas: 1
# you can set /any/ nango-server environment variable required utilizing the "env" key as follows:
# the example below shows a configuration to enable basic auth
# env:
# - name: FLAG_AUTH_ENABLED
# value: "false"
# - name: NANGO_DASHBOARD_USERNAME
# value: nango
# - name: NANGO_DASHBOARD_PASSWORD
# valueFrom:
# secretKeyRef:
# name: nango-secrets
# key: nango-dashboard-password

jobs:
name: nango-jobs
Expand Down

0 comments on commit afb6d4b

Please sign in to comment.