fix(#12): correct elevate command in service login prompt - #13
fix(#12): correct elevate command in service login prompt#13fullsend-ai-coder[bot] wants to merge 1 commit into
Conversation
The service login prompt printed an incorrect elevate command with two issues: it used 'ocm backplane' instead of the shipped binary name 'ocm-backplane', and it was missing the -n flag (--no-reason) that prompts the user for an elevation reason. Fix the format string to use the correct binary name and include the -n flag. Add a test that captures stdout during service login and asserts the correct command format is printed. Closes #12
|
/fs-review |
|
🤖 Finished Review · ✅ Success · Started 2:34 AM UTC · Completed 2:40 AM UTC |
Review — PR #13: fix(#12): correct elevate command in service login promptVerdict: request-changes SummaryThis PR fixes the elevate command printed during service login ( Findings1. 🔴 HIGH — Double
|
| return fmt.Errorf("manifestworks are only available for hosted control plane clusters") | ||
| } | ||
| listManifestWork := fmt.Sprintf("ocm backplane elevate -- oc get manifestworks -n %s -l api.openshift.com/id=%s", managingClusterName, targetClusterID) | ||
| listManifestWork := fmt.Sprintf("ocm-backplane elevate -n -- oc get manifestworks -n %s -l api.openshift.com/id=%s", managingClusterName, targetClusterID) |
There was a problem hiding this comment.
[high] correctness
The printed elevate command includes 'oc' after '--', but with the '-n' flag, 'oc' is no longer consumed as the reason argument. The elevate command internally prepends 'oc' via exec.Command("oc", argv[1:]...), so the resulting execution would be 'oc oc get manifestworks...' which fails. All documented examples (CONTRIBUTING.md, README.md) confirm that 'oc' should NOT appear after '--'.
Suggested fix: Remove 'oc' from the format string: fmt.Sprintf("ocm-backplane elevate -n -- get manifestworks -n %s -l api.openshift.com/id=%s", managingClusterName, targetClusterID)
|
|
||
| Expect(err).To(BeNil()) | ||
| output := string(out) | ||
| Expect(output).To(ContainSubstring("ocm-backplane elevate -n --")) |
There was a problem hiding this comment.
[low] test-quality
The test assertions only check for substring presence of 'ocm-backplane elevate -n --' and absence of 'ocm backplane elevate --', but don't detect the double-'oc' bug. The assertions should verify the full command pattern including what follows '--'.
Suggested fix: Add assertion: Expect(output).To(ContainSubstring("-- get manifestworks")) and Expect(output).NotTo(ContainSubstring("-- oc "))
| mockClient.EXPECT().LoginCluster(gomock.Any(), gomock.Eq(serviceClusterID)).Return(fakeResp, nil) | ||
|
|
||
| // Capture stdout to verify the elevate command output | ||
| old := os.Stdout |
There was a problem hiding this comment.
[low] test-quality
os.Stdout is reassigned without a deferred restore. If runLogin or io.ReadAll panics, os.Stdout remains pointed at a closed pipe, corrupting subsequent test output. The os.Pipe() error is also silently discarded.
Suggested fix: Use 'defer func() { os.Stdout = old }()' immediately after saving the old value, and check the error from os.Pipe().
The service login prompt printed an incorrect elevate command with two issues: it used 'ocm backplane' instead of the shipped binary name 'ocm-backplane', and it was missing the -n flag (--no-reason) that prompts the user for an elevation reason.
Fix the format string to use the correct binary name and include the -n flag. Add a test that captures stdout during service login and asserts the correct command format is printed.
Closes #12
Post-script verification
agent/12-fix-elevate-command)ae64d7cf510a866657b8dcb2881b8c7dc3fe2a16..HEAD)