Skip to content

Commit 1ff33fc

Browse files
committed
When using valkey, also add REDIS-prefixed env-variables
This makes the transition from redis to valkey easier for the teams, as they don't have to change anything in their code. This also allows using the URI env variable with redis libraries that expect a rediss scheme, by using the REDIS_URI_ env variables instead of VALKEY_URI_. Made all the REDIS variables optional, to make it easier when we start removing anything Redis related at some later point.
1 parent f3b799c commit 1ff33fc

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

pkg/resourcecreator/aiven/valkey.go

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ func Valkey(ast *resource.Ast, config Config, source Source, aivenApp *aiven_nai
2626
}
2727

2828
addValkeyEnvVariables(ast, aivenApp.Spec.SecretName, valkey.Instance)
29+
// Make the transition easier for teams coming from Redis by setting the `REDIS_` env variables too
30+
addRedisEnvVariables(ast, aivenApp.Spec.SecretName, valkey.Instance)
31+
2932
aivenApp.Spec.Valkey = append(aivenApp.Spec.Valkey, &aiven_nais_io_v1.ValkeySpec{
3033
Instance: valkey.Instance,
3134
Access: valkey.Access,

pkg/resourcecreator/testdata/valkey.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,33 @@ tests:
5555
containers:
5656
- name: "myapplication"
5757
env:
58+
- name: REDIS_USERNAME_NAISTEST1
59+
valueFrom:
60+
secretKeyRef:
61+
key: REDIS_USERNAME_NAISTEST1
62+
name: ^aiven-myapplication-.{8}-\d{4}-\d\d?-0$
63+
- name: REDIS_PASSWORD_NAISTEST1
64+
valueFrom:
65+
secretKeyRef:
66+
key: REDIS_PASSWORD_NAISTEST1
67+
name: ^aiven-myapplication-.{8}-\d{4}-\d\d?-0$
68+
- name: REDIS_URI_NAISTEST1
69+
valueFrom:
70+
secretKeyRef:
71+
key: REDIS_URI_NAISTEST1
72+
name: ^aiven-myapplication-.{8}-\d{4}-\d\d?-0$
73+
- name: REDIS_HOST_NAISTEST1
74+
valueFrom:
75+
secretKeyRef:
76+
key: REDIS_HOST_NAISTEST1
77+
name: ^aiven-myapplication-.{8}-\d{4}-\d\d?-0$
78+
optional: true
79+
- name: REDIS_PORT_NAISTEST1
80+
valueFrom:
81+
secretKeyRef:
82+
key: REDIS_PORT_NAISTEST1
83+
name: ^aiven-myapplication-.{8}-\d{4}-\d\d?-0$
84+
optional: true
5885
- name: VALKEY_USERNAME_NAISTEST1
5986
valueFrom:
6087
secretKeyRef:

0 commit comments

Comments
 (0)