OCPBUGS-87029: nutanix: fix ccoctl to accept directory for --credentials-source-filepath#1036
Conversation
…path When a directory is passed to --credentials-source-filepath, the code was failing with an unhelpful 'is a directory' OS error. The flag now also accepts a directory path and automatically looks for a file named 'credentials' inside it, consistent with the default ~/.nutanix/credentials path and the official OCP documentation. Also updated the flag description in the binary help output to clearly state that both a file path and a directory are accepted. Assisted-by: Claude Sonnet 4.6 Co-authored-by: Cursor <cursoragent@cursor.com>
WalkthroughThe PR extends the Nutanix ChangesDirectory path support for Nutanix credentials
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 13 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (13 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
Hi @vdurgam10. Thanks for your PR. I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: vdurgam10 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@vdurgam10: This pull request references Jira Issue OCPBUGS-87029, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/ok-to-test |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1036 +/- ##
==========================================
+ Coverage 47.06% 47.08% +0.02%
==========================================
Files 97 97
Lines 12560 12565 +5
==========================================
+ Hits 5911 5916 +5
Misses 5994 5994
Partials 655 655
🚀 New features to boost your workflow:
|
|
/retest |
|
@vdurgam10: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Problem
When a directory path is passed to
--credentials-source-filepath,ccoctl nutanix create-shared-secretsfails with a cryptic error:The root cause is that
os.Stat()succeeds silently for directories, andos.ReadFile()then throws an unhelpful OS-level error.This is also inconsistent with the official OCP documentation (4.16, 4.21), which describes
--credentials-source-filepathas accepting a directory path.Fix
getCredentialsFromFile(), added anIsDir()check afteros.Stat(). If a directory is provided, the code now automatically appendscredentialsto construct the full file path (e.g.install-dir/→install-dir/credentials), consistent with how the default~/.nutanix/credentialspath is constructed.-h) to clearly state that both a file path and a directory containing a file namedcredentialsare accepted.Testing
Added two new test cases:
Directory provided for credentials-source-filepath with credentials file inside— verifies successful secret generation when a directory is passedDirectory provided for credentials-source-filepath without credentials file inside— verifies a clear error message when the directory has nocredentialsfileAll 9 tests pass.
Made with Cursor
Summary by CodeRabbit
New Features
--credentials-source-filepathflag now accepts both direct credentials file paths and directories containing acredentialsfile.