Add --cable-driver-option join flag#1830
Conversation
Allow setting Submariner.spec.cableDriverOptions at join time via repeated key=value flags, following the same Options []string pattern as --image-override. Signed-off-by: sanek9 <sanya0996@gmail.com>
|
🤖 Created branch: z_pr1830/sanek9/feat/cable-driver-options |
WalkthroughAdds repeatable ChangesCable driver options
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant JoinCommand
participant ClusterToBroker
participant ParseCableDriverOptions
participant deploy.Submariner
participant SubmarinerSpec
JoinCommand->>ClusterToBroker: CableDriverOptionArr
ClusterToBroker->>ParseCableDriverOptions: parse key=value entries
ParseCableDriverOptions-->>ClusterToBroker: CableDriverOptions map
ClusterToBroker->>deploy.Submariner: SubmarinerOptions with cable driver options
deploy.Submariner->>SubmarinerSpec: populate CableDriverOptions
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Part of the proposal overview: submariner-io/submariner#4101 |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/join/join.go (1)
266-273: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winTrim whitespace and handle empty keys.
It's recommended to trim surrounding whitespace from the parsed key and ensure it is not empty (e.g., handling inputs like
--cable-driver-option =valueor--cable-driver-option " key=value"). This helps prevent subtle misconfigurations where the driver might ignore the option due to a leading space or an invalid empty key.♻️ Proposed refactor
for _, s := range options { key, value, found := strings.Cut(s, "=") if !found { return nil, fmt.Errorf("invalid option %q provided. Please use `key=value` syntax", s) } + + key = strings.TrimSpace(key) + if key == "" { + return nil, fmt.Errorf("invalid option %q provided. Key cannot be empty", s) + } result[key] = value }If you apply this, consider adding a quick test case in
join_test.goto cover the empty key scenario!🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/join/join.go` around lines 266 - 273, Update the option parsing loop to trim surrounding whitespace from the key returned by strings.Cut before storing it in result, and reject the option when the trimmed key is empty. Preserve the existing key=value validation and value handling, and add coverage in the relevant join parsing tests for whitespace and empty-key inputs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pkg/join/join.go`:
- Around line 266-273: Update the option parsing loop to trim surrounding
whitespace from the key returned by strings.Cut before storing it in result, and
reject the option when the trimmed key is empty. Preserve the existing key=value
validation and value handling, and add coverage in the relevant join parsing
tests for whitespace and empty-key inputs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8d362387-e3b5-4543-8b9c-e31136a8d7f5
📒 Files selected for processing (5)
cmd/subctl/join.gopkg/deploy/submariner.gopkg/join/join.gopkg/join/join_test.gopkg/join/options.go
|
Depends on submariner-io/submariner-operator#4142 |
What this PR does / why we need it
Allows setting
Submariner.spec.cableDriverOptionsat join time:Same
key=valuepattern as--image-override.Depends on
spec.cableDriverOptions(otherwise the field is dropped / unknown).Related issues
Checklist
subctl join --helpdocuments the flagCross-links (this series)
Made with Cursor
Summary by CodeRabbit
New Features
--cable-driver-option key=valuesettings when joining a cluster.Bug Fixes
Tests