Skip to content

Commit

Permalink
feat: support license key (#116)
Browse files Browse the repository at this point in the history
* feat: support license key

Signed-off-by: arkbriar <[email protected]>

* Update values.yaml

---------

Signed-off-by: arkbriar <[email protected]>
  • Loading branch information
arkbriar committed Sep 6, 2024
1 parent a28c12d commit e466e0b
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/risingwave/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.1
version: 0.2.2

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
14 changes: 14 additions & 0 deletions charts/risingwave/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -598,3 +598,17 @@ Cloud related enviroments.
{{- end }}
{{- end }}
{{- end }}
{{/* Env vars for license key */}}
{{- define "risingwave.licenseKeyEnv" }}
{{- if and .Values.license.secret.key .Values.license.secret.name }}
- name: RW_LICENSE_KEY
valueFrom:
secretKeyRef:
name: {{ .Values.license.secret.name | quote }}
key: {{ .Values.license.secret.key | quote }}
{{- else if .Values.license.key }}
- name: RW_LICENSE_KEY
value: {{ .Values.license.key | quote }}
{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions charts/risingwave/templates/meta-sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ spec:
name: {{ include "risingwave.mysqlCredentialsSecretName" . }}
{{- end }}
env:
{{ include "risingwave.licenseKeyEnv" . | nindent 8 }}
{{ include "risingwave.cloudEnvironments" . | nindent 8 }}
# Disable auto region loading. Refer to the original source for more information.
# https://github.com/awslabs/aws-sdk-rust/blob/main/sdk/aws-config/src/imds/region.rs
Expand Down
1 change: 1 addition & 0 deletions charts/risingwave/templates/standalone/standalone-sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ spec:
name: {{ include "risingwave.mysqlCredentialsSecretName" . }}
{{- end }}
env:
{{ include "risingwave.licenseKeyEnv" . | nindent 8 }}
{{ include "risingwave.cloudEnvironments" . | nindent 8 }}
# Disable auto region loading. Refer to the original source for more information.
# https://github.com/awslabs/aws-sdk-rust/blob/main/sdk/aws-config/src/imds/region.rs
Expand Down
58 changes: 58 additions & 0 deletions charts/risingwave/tests/license_standalone_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
suite: Test license key (standalone)
templates:
- standalone/standalone-sts.yaml
chart:
appVersion: 1.0.0
version: 0.0.1
set:
standalone:
enabled: true
tests:
- it: no license key
asserts:
- notContains:
path: spec.template.spec.containers[0].env
content:
name: RW_LICENSE_KEY
any: true
- it: license key found with raw key
set:
license:
key: "ABC"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: RW_LICENSE_KEY
value: "ABC"
- it: license key found with secret ref
set:
license:
secret:
name: LICENSE-SECRET
key: LICENSE-KEY
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: RW_LICENSE_KEY
valueFrom:
secretKeyRef:
name: LICENSE-SECRET
key: LICENSE-KEY
- it: license key found with secret ref and key
set:
license:
key: "ABC"
secret:
name: LICENSE-SECRET
key: LICENSE-KEY
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: RW_LICENSE_KEY
valueFrom:
secretKeyRef:
name: LICENSE-SECRET
key: LICENSE-KEY
55 changes: 55 additions & 0 deletions charts/risingwave/tests/license_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
suite: Test license key (distributed)
templates:
- meta-sts.yaml
chart:
appVersion: 1.0.0
version: 0.0.1
tests:
- it: no license key
asserts:
- notContains:
path: spec.template.spec.containers[0].env
content:
name: RW_LICENSE_KEY
any: true
- it: license key found with raw key
set:
license:
key: "ABC"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: RW_LICENSE_KEY
value: "ABC"
- it: license key found with secret ref
set:
license:
secret:
name: LICENSE-SECRET
key: LICENSE-KEY
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: RW_LICENSE_KEY
valueFrom:
secretKeyRef:
name: LICENSE-SECRET
key: LICENSE-KEY
- it: license key found with secret ref and key
set:
license:
key: "ABC"
secret:
name: LICENSE-SECRET
key: LICENSE-KEY
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: RW_LICENSE_KEY
valueFrom:
secretKeyRef:
name: LICENSE-SECRET
key: LICENSE-KEY
18 changes: 18 additions & 0 deletions charts/risingwave/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1389,3 +1389,21 @@ cloud:
## This only works when endpoint is not set and region is set.
##
useVPCEndpoint: false

## @section license. Enterprise license key configuration for RisingWave enterprise.
##

license:
## @param key RisingWave enterprise license key.
##
key: ""

## @param secret Use existing Secret to provide license key.
## If set, value of key will be ignored.
secret:
## @param name Name of the existing Secret.
##
name: ""
## @param key Key in the Secret. Defaults to "licenseKey".
##
key: "licenseKey"

0 comments on commit e466e0b

Please sign in to comment.