Print cluster info aftger login#561
Conversation
| "Name": clusterName}).Infoln("Target cluster") | ||
|
|
||
| //PrintClusterInfo After Login | ||
| if err := login.PrintClusterInfo(clusterID); err != nil { |
There was a problem hiding this comment.
Can we make this function as optional? Either control via a cmd flag or config file
There was a problem hiding this comment.
I believe it can be pass in as a flag if that's you think is the way to go. Let me see if I can get it done
|
working on suggestions |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #561 +/- ##
==========================================
+ Coverage 45.58% 45.92% +0.34%
==========================================
Files 84 85 +1
Lines 6268 6319 +51
==========================================
+ Hits 2857 2902 +45
Misses 3057 3057
- Partials 354 360 +6
|
| flags.BoolVar( | ||
| &args.clusterInfo, | ||
| "cluster-info", | ||
| false, "Print cluster information", |
There was a problem hiding this comment.
May be making the help text more clear: Print basic cluster information after login
| func GetAccessProtectionStatus(clusterID string) string { | ||
| ocmConnection, err := ocm.DefaultOCMInterface.SetupOCMConnection() | ||
| if err != nil { | ||
| fmt.Println("Error setting up OCM connection: ", err) |
There was a problem hiding this comment.
| fmt.Println("Error setting up OCM connection: ", err) | |
| logger.Error("Error setting up OCM connection: ", err) |
logger is initialized but is not consistently used for logging messages
| } | ||
|
|
||
| // Display cluster information | ||
| fmt.Printf("\n%-25s %s\n", "Cluster ID:", clusterInfo.ID()) |
There was a problem hiding this comment.
May be better to refactor the repeated code of fmt.Printf("%-25s ...") into a helper function like:
func printClusterField(fieldName string, value interface{}) {
fmt.Printf("%-25s %v\n", fieldName, value)
}
so you can use it like below and it can also improve the resusability in other parts of the codebase if needed.
printClusterField("Cluster ID:", clusterInfo.ID())
printClusterField("Cluster Name:", clusterInfo.Name())
...
|
Great work Yuri, the functionality works all good, just some nits from code's perspective. |
cb9e41e to
63c9d34
Compare
|
Pausing this PR as I've done something wrong while rebasing as it pulled some changes I haven't made. |
|
as was suggested in https://redhat-internal.slack.com/archives/C0326L38PEH/p1732854455926389 I've sync with upstream and added files |
63c9d34 to
933d29e
Compare
|
@diakovnec: all tests passed! 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. |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: diakovnec, xiaoyu74 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
feature to print cluster info after backplain login into a cluster
What this PR does / Why we need it?
Helps to get basic info while troubleshooting
Which Jira/Github issue(s) does this PR fix?
(https://issues.redhat.com/browse/OSD-25315)
Special notes for your reviewer
There a couple of things to mention:
PrintAccessProtectionStatus(clusterID)is called as its required to mock ocmConnectionUnexpected call to *mocks.MockOCMInterface.SetupOCMConnection([]) at /home/ydiakov/cards/osd-25315/attem_4/backplane-cli/pkg/login/printClusterInfoAfterLogin.go:40 because: there are no expected calls of the method "SetupOCMConnection" for that receiverUnit Test Coverage
Guidelines
Test coverage checks
Pre-checks (if applicable)