Skip to content

Conversation

@Vicente-Cheng
Copy link
Collaborator

Problem:
fix linter for v1.7

Solution:
fix linter for v1.7

Related Issue:

Test plan:

@Vicente-Cheng Vicente-Cheng requested review from a team, Yu-Jack and tserong as code owners January 22, 2026 09:38
Copilot AI review requested due to automatic review settings January 22, 2026 09:38
brandboat
brandboat previously approved these changes Jan 22, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses linter warnings (specifically the prealloc warning) for v1.7 by refactoring slice allocations to use proper pre-allocation instead of suppressing warnings with nolint comments.

Changes:

  • Replaced slice literal assignments with pre-allocated slices using make() with appropriate capacity
  • Removed nolint: prealloc comments that were suppressing linter warnings
  • Removed unused path/filepath import after switching from filepath.Join to string concatenation

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/utils/command.go Pre-allocated cmdArgs slice and replaced filepath.Join with string concatenation for namespace paths
cmd/node-disk-manager-webhook/main.go Pre-allocated starters slice with capacity 4 and moved declaration after error checks

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 50 to 52
"--mount="+exec.namespace+"/mnt",
"--net="+exec.namespace+"/net",
"--ipc="+exec.namespace+"/ipc",
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

Replacing filepath.Join with string concatenation introduces a subtle change in path construction. Since exec.namespace comes from GetHostNamespacePath which returns paths ending with "/" (e.g., "/proc/1/ns/"), the new code produces paths like "/proc/1/ns//mnt" with double slashes, whereas filepath.Join would have produced "/proc/1/ns/mnt". While Linux generally tolerates double slashes, this behavioral change is unintended. To properly address the linter warning while maintaining exact behavior, consider using pre-allocated slices with filepath.Join, or ensure exec.namespace is trimmed of trailing slashes before concatenation.

Copilot uses AI. Check for mistakes.
Yu-Jack
Yu-Jack previously approved these changes Jan 22, 2026
Signed-off-by: Vicente Cheng <vicente.cheng@suse.com>
@Vicente-Cheng Vicente-Cheng merged commit a4796fd into harvester:master Jan 22, 2026
7 of 8 checks passed
@Vicente-Cheng
Copy link
Collaborator Author

@Mergifyio backport v1.7

@mergify
Copy link

mergify bot commented Jan 22, 2026

backport v1.7

✅ Backports have been created

Details

Cherry-pick of a4796fd has failed:

On branch mergify/bp/v1.7/pr-262
Your branch is up to date with 'origin/v1.7'.

You are currently cherry-picking commit a4796fd.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   cmd/node-disk-manager-webhook/main.go
	both modified:   pkg/utils/command.go

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants