Skip to content

Commit

Permalink
dev now does have a parameter store key
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakeii committed Dec 5, 2024
1 parent b083b92 commit 133db01
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions common/app/common/CommercialBundle.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,17 @@ object CommercialBundle {
private lazy val parameterStore = new ParameterStore(Environment.awsRegion)

private val cacheDuration: FiniteDuration = 1.minute
private val stage = Environment.stage
private val stage = Environment.stage.toLowerCase()
private val bundlePathKey = s"/frontend/$stage/commercial.bundlePath"

// when running locally Configuration.assets.path is set to "assets/" to serve local assets, but the commercial bundle no longer lives there, so we need to override it
private val basePath =
if (stage == "dev") "https://assets.guim.co.uk/" else Configuration.assets.path

private var cachedBundlePath: String = bundlePathFromParameterStore
private var cachedTimestamp: Instant = Instant.now()

// when running locally Configuration.assets.path is set to "assets/" to serve local assets, but the commercial bundle no longer lives there, so we need to override it
private val basePath =
if (stage.equalsIgnoreCase("dev")) "https://assets-code.guim.co.uk/" else Configuration.assets.path

private def bundlePathFromParameterStore: String = {
if (stage == "CODE")
parameterStore.get("/frontend/CODE/commercial.bundlePath")
else
// for PROD and DEV to use the same bundle path
parameterStore.get("/frontend/commercial.bundlePath")
}
private def bundlePathFromParameterStore: String = parameterStore.get(bundlePathKey)

private def bundlePath: String = {
if (Instant.now().isAfter(cachedTimestamp.plus(cacheDuration.toMillis))) {
Expand Down

0 comments on commit 133db01

Please sign in to comment.