Skip to content

Commit aafaf9f

Browse files
fzipiclaude
andcommitted
fix: use list of objects for crs-versions to avoid duplicate target names
When lts and latest point to the same CRS version, using a map produces duplicate target names. Switch to a list of {tag, version} objects so the target name uses the semantic key (previous/lts/latest) instead of the version string. Also update verifyimage.yml to derive the CRS major version by checking whether the target ends with "-previous" rather than parsing a version number from the name. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9387602 commit aafaf9f

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

.github/workflows/verifyimage.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ jobs:
9292

9393
- name: Run ${{ matrix.target }}
9494
run: |
95-
# get the major version from the matrix.target
96-
# The targets end with `<major>-<minor>-<patch>`.
97-
CRS_VERSION="v$(awk -F'-' '{print $(NF-2)}' <<< ${{ matrix.target }})"
95+
# get the major CRS version from the matrix.target
96+
# Targets ending with "previous" are v3; all others are v4.
97+
CRS_VERSION="$([[ "${{ matrix.target }}" == *-previous ]] && echo v3 || echo v4)"
9898
. .github/workflows/configure-rules-for-test.sh \
9999
"src/opt/modsecurity/configure-rules.${CRS_VERSION}.conf" \
100100
README.md \

docker-bake.hcl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ variable "v4-lts-crs-version" {
3131
}
3232

3333
variable "crs-versions" {
34-
default = {
35-
"previous" = v3-lts-crs-version,
36-
"lts" = v4-lts-crs-version,
37-
"latest" = major-crs-version
38-
}
34+
default = [
35+
{ tag = "previous", version = v3-lts-crs-version },
36+
{ tag = "lts", version = v4-lts-crs-version },
37+
{ tag = "latest", version = major-crs-version }
38+
]
3939
}
4040

4141
variable "nginx-version" {
@@ -150,7 +150,7 @@ target "platforms-base" {
150150

151151
target "apache" {
152152
matrix = {
153-
crs_release = crs-versions
153+
crs_entry = crs-versions
154154
base = [
155155
{
156156
name = "debian"
@@ -170,25 +170,25 @@ target "apache" {
170170
}
171171

172172
inherits = ["platforms-base"]
173-
name = "apache-${base.name}-${replace(crs_release, ".", "-")}"
173+
name = "apache-${base.name}-${crs_entry.tag}"
174174
contexts = {
175175
image = base.image
176176
}
177177
dockerfile = base.dockerfile
178178
args = {
179-
CRS_RELEASE = "${crs_release}"
179+
CRS_RELEASE = crs_entry.version
180180
LUA_MODULES = base.lua_modules
181181
}
182182
tags = concat(
183183
tag(base.tag_base),
184-
vtag("${crs_release}", base.tag_base),
185-
equal(crs_release, v4-lts-crs-version) ? lts-tag("${crs_release}", base.tag_base) : []
184+
vtag("${crs_entry.version}", base.tag_base),
185+
equal(crs_entry.tag, "lts") ? lts-tag("${crs_entry.version}", base.tag_base) : []
186186
)
187187
}
188188

189189
target "nginx" {
190190
matrix = {
191-
crs_release = crs-versions
191+
crs_entry = crs-versions
192192
base = [
193193
{
194194
name = "debian"
@@ -218,13 +218,13 @@ target "nginx" {
218218
]
219219
}
220220
inherits = ["platforms-base"]
221-
name = "nginx-${base.name}-${read-only-fs.name}-${replace(crs_release, ".", "-")}"
221+
name = "nginx-${base.name}-${read-only-fs.name}-${crs_entry.tag}"
222222
contexts = {
223223
image = base.image
224224
}
225225
dockerfile = base.dockerfile
226226
args = {
227-
CRS_RELEASE = crs_release
227+
CRS_RELEASE = crs_entry.version
228228
NGINX_VERSION = nginx-version
229229
LUA_MODULES = base.lua_modules
230230
NGINX_DYNAMIC_MODULES = join(" ", [for mod in nginx-dynamic-modules : join(" ", [mod.owner, mod.name, mod.version])])
@@ -233,7 +233,7 @@ target "nginx" {
233233
}
234234
tags = concat(
235235
tag("${base.tag_base}${equal(read-only-fs.read-only, "true") ? "-read-only" : ""}"),
236-
vtag("${crs_release}", "${base.tag_base}${equal(read-only-fs.read-only, "true") ? "-read-only" : ""}"),
237-
equal(crs_release, v4-lts-crs-version) ? lts-tag("${crs_release}", "${base.tag_base}${equal(read-only-fs.read-only, "true") ? "-read-only" : ""}") : []
236+
vtag("${crs_entry.version}", "${base.tag_base}${equal(read-only-fs.read-only, "true") ? "-read-only" : ""}"),
237+
equal(crs_entry.tag, "lts") ? lts-tag("${crs_entry.version}", "${base.tag_base}${equal(read-only-fs.read-only, "true") ? "-read-only" : ""}") : []
238238
)
239239
}

0 commit comments

Comments
 (0)