Skip to content

Commit 04432ce

Browse files
fix: strip architecture suffix from Kafka image tags for semver parsing
Newer Kafka Docker images include architecture suffixes in their tags (e.g. 7.5.0.arm64), which are not valid semver. This change normalises the tag by removing the architecture suffix before passing it to the semver parser, ensuring compatibility with golang.org/x/mod/semver.
1 parent da1f481 commit 04432ce

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

modules/kafka/kafka.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ func validateKRaftVersion(fqName string) error {
212212
version = "v" + version
213213
}
214214

215+
// remove the architecture suffix
216+
if strings.HasSuffix(version, ".amd64") || strings.HasSuffix(version, ".arm64") {
217+
version = version[:strings.LastIndex(version, ".")]
218+
}
219+
215220
if semver.Compare(version, "v7.4.0") < 0 { // version < v7.4.0
216221
return fmt.Errorf("version=%s. KRaft mode is only available since version 7.4.0", version)
217222
}

modules/kafka/kafka_helpers_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ func TestValidateKRaftVersion(t *testing.T) {
9393
image: "my-kafka:1.0.0",
9494
wantErr: false,
9595
},
96+
{
97+
name: "Official: valid, with the amd64 architecture suffix",
98+
image: "confluentinc/confluent-local:7.5.9.amd64",
99+
wantErr: false,
100+
},
101+
{
102+
name: "Official: valid, with the arm64 architecture suffix",
103+
image: "confluentinc/confluent-local:7.5.9.arm64",
104+
wantErr: false,
105+
},
96106
}
97107

98108
for _, test := range tests {

0 commit comments

Comments
 (0)