Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions modules/kafka/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ func validateKRaftVersion(fqName string) error {
version = "v" + version
}

// remove the architecture suffix
if strings.HasSuffix(version, ".amd64") || strings.HasSuffix(version, ".arm64") {
version = version[:strings.LastIndex(version, ".")]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdelapenya How about something like this? But at this point, we might as well let them use the image by fixing the version.

Suggested change
version = version[:strings.LastIndex(version, ".")]
return fmt.Errorf("invalid image tag %q: architecture suffixes like .arm64 or .amd64 are not valid semver; please use a multi-architecture image instead", tag)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we are using semver libraries to get a valid version, then we should honor it. I think this is a good compromise, failing if the version is not following semver.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asahasrabuddhe let's apply that fix, so we can merge this PR

Thanks!

}

if semver.Compare(version, "v7.4.0") < 0 { // version < v7.4.0
return fmt.Errorf("version=%s. KRaft mode is only available since version 7.4.0", version)
}
Expand Down
9 changes: 9 additions & 0 deletions modules/kafka/kafka_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ func TestValidateKRaftVersion(t *testing.T) {
image: "my-kafka:1.0.0",
wantErr: false,
},
{
name: "Official: valid, with the amd64 architecture suffix",
image: "confluentinc/confluent-local:7.5.9.amd64",
wantErr: false,
},
{
name: "Official: valid, with the arm64 architecture suffix",
image: "confluentinc/confluent-local:7.5.9.arm64",
},
Comment on lines +102 to +105
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Add missing wantErr field and fix formatting.

The test case is incomplete - it's missing the wantErr: false field. Additionally, there's a formatting issue flagged by the linter.

Apply this diff to fix both issues:

 	{
 		name:    "Official: valid, with the arm64 architecture suffix",
 		image:   "confluentinc/confluent-local:7.5.9.arm64",
+		wantErr: false,
 	},
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{
name: "Official: valid, with the arm64 architecture suffix",
image: "confluentinc/confluent-local:7.5.9.arm64",
},
{
name: "Official: valid, with the arm64 architecture suffix",
image: "confluentinc/confluent-local:7.5.9.arm64",
wantErr: false,
},
🧰 Tools
🪛 GitHub Actions: Main pipeline

[error] 103-103: golangci-lint: File is not properly formatted (gci)

🤖 Prompt for AI Agents
In modules/kafka/kafka_helpers_test.go around lines 102 to 105, the table-driven
test entry for "Official: valid, with the arm64 architecture suffix" is missing
the wantErr field and has a linter-formatting issue; update that test case to
include wantErr: false and adjust punctuation/indentation to match surrounding
cases (ensure fields are comma-separated, aligned, and the closing brace/comma
are correctly placed).

{
name: "lacks tag",
image: "my-kafka",
Expand Down
Loading