Conversation
📝 WalkthroughWalkthroughAdds non-admin mode detection and runtime behavior to the Velero CLI (hide admin commands and remove namespace override) and extends non-admin BSL get output with a "VELERO PHASE" column derived from the NABSL status. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant RootCmd as Root Command
participant Config as VeleroConfig
participant Factories as Client Factories
participant CmdMgr as Command Manager
User->>RootCmd: invoke CLI
RootCmd->>Config: load VeleroConfig
Config-->>RootCmd: return config
RootCmd->>RootCmd: isNonadminEnabled(config)
alt non-admin enabled
RootCmd->>Factories: use config (remove namespace override)
RootCmd->>CmdMgr: construct commands
RootCmd->>CmdMgr: filter out admin commands (keep nonadmin, client, completion)
CmdMgr-->>RootCmd: filtered command set
else admin mode
RootCmd->>CmdMgr: construct commands (full set)
CmdMgr-->>RootCmd: full command set
end
RootCmd->>User: present available commands
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (1 warning, 2 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cmd/root.go`:
- Around line 465-477: Update the allowedCmds set used inside the
isNonadminEnabled(config) branch so it matches the required nonadmin UX: include
"client", "help", and "nonadmin" and remove "completion"; modify the map literal
named allowedCmds (used with c.Commands() and cmd.Hidden) to only contain those
three keys so all other commands are hidden as intended.
|
@weshayutin Rather than just hiding it, what if we built the binary differently? |
No.. shipping more binaries will be a headache |
Joeavaikath
left a comment
There was a problem hiding this comment.
LGTM, hiding is better than nothing if we can't outright disable it
Signed-off-by: Wesley Hayutin <weshayutin@gmail.com> Co-authored-by: Claude <noreply@anthropic.com>
* if nonadmin: true * only allow the cli to present `oc oadp nonadmin` commands Signed-off-by: Wesley Hayutin <weshayutin@gmail.com> Co-authored-by: Claude <noreply@anthropic.com>
3d283a4 to
018f859
Compare
There was a problem hiding this comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@cmd/root.go`:
- Around line 465-478: The visible commands set for nonadmin mode is incorrect:
update the allowedCmds map in the isNonadminEnabled block so it only permits
"client", "help", and "nonadmin" (remove "completion"); keep the loop over
c.Commands() and setting cmd.Hidden = true for any command whose cmd.Use is not
present in allowedCmds to ensure all other commands are hidden; this change
affects the allowedCmds variable inside the nonadmin branch in cmd/root.go where
isNonadminEnabled(config) is checked and c.Commands() is iterated.
Signed-off-by: Wesley Hayutin <weshayutin@gmail.com> co-authored-by: Cluade 4.6
|
/retest |
Why the changes were made
fixes: #128
How to test the changes made
Summary by CodeRabbit