Skip to content

Commit 8d22eae

Browse files
committedApr 19, 2023
Make the akamai secret configurable
1 parent fcf18c5 commit 8d22eae

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed
 

‎api/v1alpha1/frontendenvironment_types.go

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ type FrontendEnvironmentSpec struct {
6060
AkamaiCacheBustImage string `json:"akamaiCacheBustImage,omitempty"`
6161
// Set Akamai Cache Bust URL that the files will hang off of
6262
AkamaiCacheBustURL string `json:"akamaiCacheBustURL,omitempty"`
63+
// The name of the secret we will use to get the akamai credentials
64+
AkamaiSecretName string `json:"akamaiSecretName,omitempty"`
6365
}
6466

6567
type MonitoringConfig struct {

‎config/crd/bases/cloud.redhat.com_frontendenvironments.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ spec:
5252
description: Set Akamai Cache Bust URL that the files will hang off
5353
of
5454
type: string
55+
akamaiSecretName:
56+
description: The name of the secret we will use to get the akamai
57+
credentials
58+
type: string
5559
enableAkamaiCacheBust:
5660
description: Enable Akamai Cache Bust
5761
type: boolean

‎controllers/reconcile.go

+15-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ import (
2727
"sigs.k8s.io/controller-runtime/pkg/client"
2828
)
2929

30-
const RoutePrefixDefault = "apps"
30+
const (
31+
RoutePrefixDefault = "apps"
32+
AkamaiSecretNameDefault = "akamai"
33+
)
3134

3235
type FrontendReconciliation struct {
3336
Log logr.Logger
@@ -132,10 +135,17 @@ func populateContainer(d *apps.Deployment, frontend *crd.Frontend, frontendEnvir
132135
}
133136
}
134137

138+
func getAkamaiSecretName(frontendEnvironment *crd.FrontendEnvironment) string {
139+
if frontendEnvironment.Spec.AkamaiSecretName == "" {
140+
return AkamaiSecretNameDefault
141+
}
142+
return frontendEnvironment.Spec.AkamaiSecretName
143+
}
144+
135145
// getAkamaiSecret gets the akamai secret from the cluster
136-
func getAkamaiSecret(ctx context.Context, client client.Client, frontend *crd.Frontend) (*v1.Secret, error) {
146+
func getAkamaiSecret(ctx context.Context, client client.Client, frontend *crd.Frontend, secretName string) (*v1.Secret, error) {
137147
secret := &v1.Secret{}
138-
err := client.Get(ctx, types.NamespacedName{Name: "akamai", Namespace: frontend.Namespace}, secret)
148+
err := client.Get(ctx, types.NamespacedName{Name: secretName, Namespace: frontend.Namespace}, secret)
139149
if err != nil {
140150
return nil, err
141151
}
@@ -201,7 +211,8 @@ func (r *FrontendReconciliation) populateInitContainer(d *apps.Deployment, front
201211
}
202212

203213
// Get the akamai secret
204-
secret, err := getAkamaiSecret(r.Ctx, r.Client, frontend)
214+
akamaiSecretName := getAkamaiSecretName(frontendEnvironment)
215+
secret, err := getAkamaiSecret(r.Ctx, r.Client, frontend, akamaiSecretName)
205216
if err != nil {
206217
return err
207218
}

‎deploy.yml

+4
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,10 @@ objects:
353353
description: Set Akamai Cache Bust URL that the files will hang
354354
off of
355355
type: string
356+
akamaiSecretName:
357+
description: The name of the secret we will use to get the akamai
358+
credentials
359+
type: string
356360
enableAkamaiCacheBust:
357361
description: Enable Akamai Cache Bust
358362
type: boolean

‎docs/antora/modules/ROOT/pages/api_reference.adoc

+1
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ FrontendEnvironmentSpec defines the desired state of FrontendEnvironment
317317
| *`enableAkamaiCacheBust`* __boolean__ | Enable Akamai Cache Bust
318318
| *`akamaiCacheBustImage`* __string__ | Set Akamai Cache Bust Image
319319
| *`akamaiCacheBustURL`* __string__ | Set Akamai Cache Bust URL that the files will hang off of
320+
| *`akamaiSecretName`* __string__ | The name of the secret we will use to get the akamai credentials
320321
|===
321322

322323

0 commit comments

Comments
 (0)