Skip to content

Commit

Permalink
bug: DFLY_PASSWORD environment variable deprecation (dragonflydb#2539)
Browse files Browse the repository at this point in the history
* If the image.tag version is equal to 14.0.0 or greater then specify the DFLY_requirepass environment variable. Otherwise use the DFLY_PASSWORD environment variable.

Signed-off-by: Michael Primeaux <[email protected]>

* Corrected version logic and added golden test

Signed-off-by: Michael Primeaux <[email protected]>

* Updated golden file for TLS + image.tag

Signed-off-by: Michael Primeaux <[email protected]>

* fix CI for chart linting test

* rename new test specific to password

* use v1.13.0

* update golden chart

---------

Signed-off-by: Michael Primeaux <[email protected]>
Signed-off-by: Michael Primeaux <[email protected]>
Co-authored-by: Tarun Pothulapati <[email protected]>
  • Loading branch information
mprimeaux and Pothulapati authored Feb 6, 2024
1 parent eaca66b commit 951b089
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 3 deletions.
108 changes: 108 additions & 0 deletions contrib/charts/dragonfly/ci/password-old-env-values.golden.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
# Source: dragonfly/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: test-dragonfly
namespace: default
labels:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
app.kubernetes.io/version: "v1.14.2"
app.kubernetes.io/managed-by: Helm
---
# Source: dragonfly/templates/extra-manifests.yaml
apiVersion: v1
kind: Secret
metadata:
name: dfly-password
stringData:
password: foobar
---
# Source: dragonfly/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: test-dragonfly
namespace: default
labels:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
app.kubernetes.io/version: "v1.14.2"
app.kubernetes.io/managed-by: Helm
spec:
type: ClusterIP
ports:
- port: 6379
targetPort: dragonfly
protocol: TCP
name: dragonfly
selector:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
---
# Source: dragonfly/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-dragonfly
namespace: default
labels:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
app.kubernetes.io/version: "v1.14.2"
app.kubernetes.io/managed-by: Helm
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
template:
metadata:
annotations:
labels:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
spec:
serviceAccountName: test-dragonfly
containers:
- name: dragonfly
image: "docker.dragonflydb.io/dragonflydb/dragonfly:v1.13.0"
imagePullPolicy: IfNotPresent
ports:
- name: dragonfly
containerPort: 6379
protocol: TCP
livenessProbe:
exec:
command:
- /bin/sh
- /usr/local/bin/healthcheck.sh
failureThreshold: 3
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
readinessProbe:
exec:
command:
- /bin/sh
- /usr/local/bin/healthcheck.sh
failureThreshold: 3
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
args:
- "--alsologtostderr"
resources:
limits: {}
requests: {}

env:
- name: DFLY_PASSWORD
valueFrom:
secretKeyRef:
name: dfly-password
key: password
16 changes: 16 additions & 0 deletions contrib/charts/dragonfly/ci/password-old-env-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
image:
tag: "v1.13.0"

extraObjects:
- apiVersion: v1
kind: Secret
metadata:
name: dfly-password
stringData:
password: foobar

passwordFromSecret:
enable: true
existingSecret:
name: dfly-password
key: password
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ spec:
requests: {}

env:
- name: DFLY_PASSWORD
- name: DFLY_requirepass
valueFrom:
secretKeyRef:
name: dfly-password
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ spec:
- mountPath: /data
name: "test-data"
env:
- name: DFLY_PASSWORD
- name: DFLY_requirepass
valueFrom:
secretKeyRef:
name: dfly-password
Expand Down
2 changes: 1 addition & 1 deletion contrib/charts/dragonfly/ci/tls-values.golden.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ spec:
- mountPath: /etc/dragonfly/tls
name: tls
env:
- name: DFLY_PASSWORD
- name: DFLY_requirepass
valueFrom:
secretKeyRef:
name: dfly-password
Expand Down
10 changes: 10 additions & 0 deletions contrib/charts/dragonfly/templates/_pod.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,18 @@ containers:
{{- end }}
{{- include "dragonfly.volumemounts" . | trim | nindent 4 }}
{{- if .Values.passwordFromSecret.enable }}
{{- $appVersion := .Chart.AppVersion | trimPrefix "v" }}
{{- $imageTag := .Values.image.tag | trimPrefix "v" }}
{{- $effectiveVersion := $appVersion }}
{{- if and $imageTag (ne $imageTag "") }}
{{- $effectiveVersion = $imageTag }}
{{- end }}
env:
{{- if semverCompare ">=1.14.0" $effectiveVersion }}
- name: DFLY_requirepass
{{- else }}
- name: DFLY_PASSWORD
{{- end }}
valueFrom:
secretKeyRef:
name: {{ .Values.passwordFromSecret.existingSecret.name }}
Expand Down
2 changes: 2 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=

0 comments on commit 951b089

Please sign in to comment.