-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --vm flag for users who want to autoselect only VM's #7068
Conversation
Hi @vikkyomkar. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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 kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: vikkyomkar The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/assign @tstromberg |
Can one of the admins verify this patch? |
Codecov Report
@@ Coverage Diff @@
## master #7068 +/- ##
==========================================
+ Coverage 36.94% 36.95% +0.01%
==========================================
Files 146 146
Lines 9094 9102 +8
==========================================
+ Hits 3360 3364 +4
- Misses 5322 5325 +3
- Partials 412 413 +1
|
/ok-to-test |
pkg/minikube/driver/driver.go
Outdated
|
||
if vm { | ||
for _, ds := range options { | ||
if IsVM(ds.Name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Now that I see how this looks, rather than applying the filter in the Choices function, could you pass the value to registry.Available
and add the filtering in that function instead?
minikube/pkg/minikube/registry/global.go
Line 62 in 07e8420
func Available() []DriverState { |
This would be a slight performance improvement, as registry.Available()
would not have to calldriver.Status()
on non-VM drivers if the result is going to be ignored anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure I will make the suggested changes soon
Error: running mkcmp: exit status 1 |
Need any help with this PR? |
All Times minikube: [ 72.150463 74.829091 74.539236] Average minikube: 73.839596 Averages Time Per Log
|
@tstromberg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More comments to clean things up a bit, especially since there was some code duplication required. Thank you so much for your patience!
@@ -76,7 +110,13 @@ func Available() []DriverState { | |||
priority = Unhealthy | |||
} | |||
|
|||
sts = append(sts, DriverState{Name: d.Name, Priority: priority, State: s}) | |||
if vm { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With go, we try to avoid if/else statements when possible, particularly in a loop. Kind of along the lines of https://github.com/golang/go/wiki/CodeReviewComments#indent-error-flow
This would be clearer:
if vm && !IsVM(d.Name) {
continue
}
@@ -59,7 +93,7 @@ func Driver(name string) DriverDef { | |||
} | |||
|
|||
// Available returns a list of available drivers in the global registry | |||
func Available() []DriverState { | |||
func Available(vm bool) []DriverState { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might be clearer if it was named vmOnly
|
||
// IsVM checks if the driver is a VM | ||
func IsVM(name string) bool { | ||
if IsKIC(name) || IsMock(name) || BareMetal(name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you just copy and pasted the previous function, but because the other functions aren't used, just inline it:
if name == Docker || name == Mock || name == None || name == Podman {
return true
}
Then you can remove IsKic and IsMock.
} | ||
|
||
// IsVM checks if the driver is a VM | ||
func IsVM(name string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename this to isVM
-- it does not need to be made public.
Heads up: I plan to merge this PR in it's current state today, so that v1.9.0 users can enjoy an improved experience. We can always address the final code comments in a follow-up PR. Thank you again for contributing this. |
#7067