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
added condition for the case when user try to enable addons without kubernetes #13508
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: NikhilSharmaWe 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 |
Can one of the admins verify this patch? |
@spowelljr and @SilkeDH is my thinking correct here for adding the improvement. If yes,
|
You have to move the logic you added out to a function to keep the cyclomatic complexity low. Also, this PR is not catching the case if the user starts minikube and then run |
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.
thank you for this PR just a lint comment
and plz paste the output the PR before and after this PR
cmd/minikube/cmd/start.go
Outdated
@@ -1236,6 +1236,10 @@ func validateFlags(cmd *cobra.Command, drvName string) { | |||
exit.Message(reason.Usage, "Sorry, please set the --output flag to one of the following valid options: [text,json]") | |||
} | |||
|
|||
if viper.GetStringSlice(config.AddonListFlag) != nil && viper.GetBool(noKubernetes) { |
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.
consider adding it to a helper func to fix the lint error "cyclomatic complexity 31"
helper could be caled
validateNoAddonsForNoKubernetes(config...)
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.
- Is the function
validateNoAddonsForNoKubernetes()
correctly added ? - I have called func
validateNoAddonsForNoKubernetes()
inside the funcprovisionWithDriver()
, funcvalidateFlags()
was also called here, so is it a correct place to call it ?
c980f7e
to
f7526ff
Compare
@spowelljr I am not able to understand your point when you say :
Could you explain me that what case actually we have tackled in this PR till now and how can we deal with the other case you have mentioned in this comment ? |
Right now you're checking the case where the user runs:
But also need to check for the case where user starts minikube and then enables the addon after:
|
f7526ff
to
f8641e6
Compare
|
cmd/minikube/cmd/config/enable.go
Outdated
@@ -40,6 +40,9 @@ var addonsEnableCmd = &cobra.Command{ | |||
if len(args) != 1 { | |||
exit.Message(reason.Usage, "usage: minikube addons enable ADDON_NAME") | |||
} | |||
if ClusterFlagValue() == constants.NoKubernetesVersion { |
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.
ClusterFlagValue()
returns the profile, so it doesn't make any sense to compare that against a Kubernetes version.
cmd/minikube/cmd/start.go
Outdated
@@ -1652,3 +1653,9 @@ func exitGuestProvision(err error) { | |||
} | |||
exit.Error(reason.GuestProvision, "error provisioning guest", err) | |||
} | |||
|
|||
func validateNoAddonsForNoKubernetes() { | |||
if viper.GetStringSlice(config.AddonListFlag) != nil && viper.GetBool(noKubernetes) { |
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.
viper.GetStringSlice(config.AddonListFlag)
isn't nil when no addons
flag is passed, try running minikube start --no-kubernetes
yourself.
|
8b15e2c
to
a3a8e09
Compare
a3a8e09
to
9931451
Compare
@spowelljr and @medyagh
Do these changes solves the issue occurring before ? Please inform. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
@@ -40,6 +40,11 @@ var addonsEnableCmd = &cobra.Command{ | |||
if len(args) != 1 { | |||
exit.Message(reason.Usage, "usage: minikube addons enable ADDON_NAME") | |||
} | |||
if ClusterConfig, err := config.Load(ClusterFlagValue()); err == nil { |
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.
if ClusterConfig, err := config.Load(ClusterFlagValue()); err == nil { | |
if clusterConfig, err := config.Load(ClusterFlagValue()); err == nil { |
As per Go naming conventions
@@ -40,6 +40,11 @@ var addonsEnableCmd = &cobra.Command{ | |||
if len(args) != 1 { | |||
exit.Message(reason.Usage, "usage: minikube addons enable ADDON_NAME") | |||
} | |||
if ClusterConfig, err := config.Load(ClusterFlagValue()); err == nil { | |||
if ClusterConfig.KubernetesConfig.KubernetesVersion == constants.NoKubernetesVersion { |
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.
if ClusterConfig.KubernetesConfig.KubernetesVersion == constants.NoKubernetesVersion { | |
if clusterConfig.KubernetesConfig.KubernetesVersion == constants.NoKubernetesVersion { |
@@ -1652,3 +1653,11 @@ func exitGuestProvision(err error) { | |||
} | |||
exit.Error(reason.GuestProvision, "error provisioning guest", err) | |||
} | |||
|
|||
func validateNoAddonsForNoKubernetes() { | |||
if ClusterConfig, err := config.Load(ClusterFlagValue()); err == nil { |
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.
if ClusterConfig, err := config.Load(ClusterFlagValue()); err == nil { | |
if clusterConfig, err := config.Load(ClusterFlagValue()); err == nil { |
|
||
func validateNoAddonsForNoKubernetes() { | ||
if ClusterConfig, err := config.Load(ClusterFlagValue()); err == nil { | ||
if ClusterConfig.KubernetesConfig.KubernetesVersion == constants.NoKubernetesVersion { |
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.
if ClusterConfig.KubernetesConfig.KubernetesVersion == constants.NoKubernetesVersion { | |
if clusterConfig.KubernetesConfig.KubernetesVersion == constants.NoKubernetesVersion { |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closed this PR. In 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 kubernetes/test-infra repository. |
Fixes #13487
--no-kubernetes=true
an output should be logged informing that it is not possible to enable addons with--no-kubernetes
passed. This PR works on logging that output.