Skip to content

Commit

Permalink
Preserve AkamaiCacheBustURL for back compat
Browse files Browse the repository at this point in the history
  • Loading branch information
adamrdrew committed Nov 22, 2024
1 parent 79909ec commit e966a51
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
3 changes: 3 additions & 0 deletions api/v1alpha1/frontendenvironment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ type FrontendEnvironmentSpec struct {
EnableAkamaiCacheBust bool `json:"enableAkamaiCacheBust,omitempty"`
// Set Akamai Cache Bust Image
AkamaiCacheBustImage string `json:"akamaiCacheBustImage,omitempty"`
// Deprecated: Users should move to AkamaiCacheBustURLs
// Preserving for backwards compatibility
AkamaiCacheBustURL string `json:"akamaiCacheBustURL,omitempty"`
// Set Akamai Cache Bust URL that the files will hang off of
AkamaiCacheBustURLs []string `json:"akamaiCacheBustURLs,omitempty"`
// The name of the secret we will use to get the akamai credentials
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/cloud.redhat.com_frontendenvironments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ spec:
akamaiCacheBustImage:
description: Set Akamai Cache Bust Image
type: string
akamaiCacheBustURL:
description: |-
Deprecated: Users should move to AkamaiCacheBustURLs
Preserving for backwards compatibility
type: string
akamaiCacheBustURLs:
description: Set Akamai Cache Bust URL that the files will hang off
of
Expand Down
12 changes: 9 additions & 3 deletions controllers/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,18 @@ func createCachePurgePathList(frontend *crd.Frontend, frontendEnvironment *crd.F
return false
}

// Return early if there are no AkamaiCacheBustURLs
if frontendEnvironment.Spec.AkamaiCacheBustURLs == nil {
cacheBustUrls := frontendEnvironment.Spec.AkamaiCacheBustURLs

if frontendEnvironment.Spec.AkamaiCacheBustURL != "" {
cacheBustUrls = append(cacheBustUrls, frontendEnvironment.Spec.AkamaiCacheBustURL)
}

// Return early if we have no cache bust URLs of any kind to process
if len(cacheBustUrls) == 0 {
return purgePaths
}

for _, cacheBustURL := range frontendEnvironment.Spec.AkamaiCacheBustURLs {
for _, cacheBustURL := range cacheBustUrls {
// Ensure the URL begins with https:// and has no trailing /
purgeHost := strings.TrimSuffix(fmt.Sprintf("https://%s", strings.TrimPrefix(cacheBustURL, "https://")), "/")

Expand Down
5 changes: 5 additions & 0 deletions deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ objects:
akamaiCacheBustImage:
description: Set Akamai Cache Bust Image
type: string
akamaiCacheBustURL:
description: 'Deprecated: Users should move to AkamaiCacheBustURLs
Preserving for backwards compatibility'
type: string
akamaiCacheBustURLs:
description: Set Akamai Cache Bust URL that the files will hang
off of
Expand Down
2 changes: 2 additions & 0 deletions docs/antora/modules/ROOT/pages/api_reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,8 @@ parts should be generated for the bundles. We want to do +
do this in epehemeral environments but not in production + | |
| *`enableAkamaiCacheBust`* __boolean__ | Enable Akamai Cache Bust + | |
| *`akamaiCacheBustImage`* __string__ | Set Akamai Cache Bust Image + | |
| *`akamaiCacheBustURL`* __string__ | Deprecated: Users should move to AkamaiCacheBustURLs +
Preserving for backwards compatibility + | |
| *`akamaiCacheBustURLs`* __string array__ | Set Akamai Cache Bust URL that the files will hang off of + | |
| *`akamaiSecretName`* __string__ | The name of the secret we will use to get the akamai credentials + | |
| *`targetNamespaces`* __string array__ | List of namespaces that should receive a copy of the frontend configuration as a config map +
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/cachebust/01-create-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ spec:
sso: https://sso.foo.redhat.com
enableAkamaiCacheBust: true
akamaiCacheBustImage: "quay.io/rh_ee_addrew/hi_true_bye:add_alias"
akamaiCacheBustURLs:
- "console.doesntexist.redhat.com"
akamaiCacheBustURL: "console.doesntexist.redhat.com"
---
apiVersion: cloud.redhat.com/v1alpha1
kind: Frontend
Expand Down

0 comments on commit e966a51

Please sign in to comment.