Skip to content

Commit 1bd97ea

Browse files
committed
coroot-ee: license key from a Secret
1 parent fbefb26 commit 1bd97ea

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

api/v1/coroot_types.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ type CommunityEditionSpec struct {
2121
type EnterpriseEditionSpec struct {
2222
// License key for Coroot Enterprise Edition.
2323
// You can get the Coroot Enterprise license and start a free trial anytime through the Coroot Customer Portal: https://coroot.com/account.
24-
LicenseKey string `json:"licenseKey,omitempty"`
25-
Image ImageSpec `json:"image,omitempty"`
24+
LicenseKey string `json:"licenseKey,omitempty"`
25+
// Secret containing the license key.
26+
LicenseKeySecret *corev1.SecretKeySelector `json:"licenseKeySecret,omitempty"`
27+
Image ImageSpec `json:"image,omitempty"`
2628
}
2729

2830
type AgentsOnlySpec struct {

api/v1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/coroot.com_coroots.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4531,6 +4531,30 @@ spec:
45314531
License key for Coroot Enterprise Edition.
45324532
You can get the Coroot Enterprise license and start a free trial anytime through the Coroot Customer Portal: https://coroot.com/account.
45334533
type: string
4534+
licenseKeySecret:
4535+
description: Secret containing the license key.
4536+
properties:
4537+
key:
4538+
description: The key of the secret to select from. Must be
4539+
a valid secret key.
4540+
type: string
4541+
name:
4542+
default: ""
4543+
description: |-
4544+
Name of the referent.
4545+
This field is effectively required, but due to backwards compatibility is
4546+
allowed to be empty. Instances of this type with an empty value here are
4547+
almost certainly wrong.
4548+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
4549+
type: string
4550+
optional:
4551+
description: Specify whether the Secret or its key must be
4552+
defined
4553+
type: boolean
4554+
required:
4555+
- key
4556+
type: object
4557+
x-kubernetes-map-type: atomic
45344558
type: object
45354559
env:
45364560
description: Environment variables for Coroot.

controller/coroot.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,15 @@ func (r *CorootReconciler) corootStatefulSet(cr *corootv1.Coroot) *appsv1.Statef
196196
}
197197

198198
image := r.getAppImage(cr, AppCorootCE)
199-
if cr.Spec.EnterpriseEdition != nil {
199+
if ee := cr.Spec.EnterpriseEdition; ee != nil {
200200
image = r.getAppImage(cr, AppCorootEE)
201-
env = append(env, corev1.EnvVar{Name: "LICENSE_KEY", Value: cr.Spec.EnterpriseEdition.LicenseKey})
201+
licenseKey := corev1.EnvVar{Name: "LICENSE_KEY"}
202+
if ee.LicenseKeySecret != nil {
203+
licenseKey.ValueFrom = &corev1.EnvVarSource{SecretKeyRef: ee.LicenseKeySecret}
204+
} else {
205+
licenseKey.Value = ee.LicenseKey
206+
}
207+
env = append(env, licenseKey)
202208
}
203209

204210
if ep := cr.Spec.ExternalPrometheus; ep != nil {

0 commit comments

Comments
 (0)