Merge branch 'master' into DELETE_ALL_PROFILES
commit
d13f58fc3b
6
Makefile
6
Makefile
|
@ -51,13 +51,13 @@ MINIKUBE_RELEASES_URL=https://github.com/kubernetes/minikube/releases/download
|
|||
|
||||
KERNEL_VERSION ?= 4.15
|
||||
# latest from https://github.com/golangci/golangci-lint/releases
|
||||
GOLINT_VERSION ?= v1.18.0
|
||||
GOLINT_VERSION ?= v1.20.0
|
||||
# Limit number of default jobs, to avoid the CI builds running out of memory
|
||||
GOLINT_JOBS ?= 4
|
||||
# see https://github.com/golangci/golangci-lint#memory-usage-of-golangci-lint
|
||||
GOLINT_GOGC ?= 8
|
||||
GOLINT_GOGC ?= 100
|
||||
# options for lint (golangci-lint)
|
||||
GOLINT_OPTIONS = --deadline 4m \
|
||||
GOLINT_OPTIONS = --timeout 4m \
|
||||
--build-tags "${MINIKUBE_INTEGRATION_BUILD_TAGS}" \
|
||||
--enable goimports,gocritic,golint,gocyclo,misspell,nakedret,stylecheck,unconvert,unparam \
|
||||
--exclude 'variable on range scope.*in function literal|ifElseChain'
|
||||
|
|
|
@ -47,6 +47,12 @@ var ProfileCmd = &cobra.Command{
|
|||
profile := args[0]
|
||||
if profile == "default" {
|
||||
profile = "minikube"
|
||||
} else {
|
||||
// not validating when it is default profile
|
||||
errProfile, ok := ValidateProfile(profile)
|
||||
if !ok && errProfile != nil {
|
||||
out.FailureT(errProfile.Msg)
|
||||
}
|
||||
}
|
||||
|
||||
if !pkgConfig.ProfileExists(profile) {
|
||||
|
|
|
@ -232,3 +232,42 @@ func EnableOrDisableStorageClasses(name, val string) error {
|
|||
|
||||
return EnableOrDisableAddon(name, val)
|
||||
}
|
||||
|
||||
// ErrValidateProfile Error to validate profile
|
||||
type ErrValidateProfile struct {
|
||||
Name string
|
||||
Msg string
|
||||
}
|
||||
|
||||
func (e ErrValidateProfile) Error() string {
|
||||
return e.Msg
|
||||
}
|
||||
|
||||
// ValidateProfile checks if the profile user is trying to switch exists, else throws error
|
||||
func ValidateProfile(profile string) (*ErrValidateProfile, bool) {
|
||||
|
||||
validProfiles, invalidProfiles, err := config.ListProfiles()
|
||||
if err != nil {
|
||||
out.FailureT(err.Error())
|
||||
}
|
||||
|
||||
// handling invalid profiles
|
||||
for _, invalidProf := range invalidProfiles {
|
||||
if profile == invalidProf.Name {
|
||||
return &ErrValidateProfile{Name: profile, Msg: fmt.Sprintf("%q is an invalid profile", profile)}, false
|
||||
}
|
||||
}
|
||||
|
||||
profileFound := false
|
||||
// valid profiles if found, setting profileFound to trueexpectedMsg
|
||||
for _, prof := range validProfiles {
|
||||
if prof.Name == profile {
|
||||
profileFound = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !profileFound {
|
||||
return &ErrValidateProfile{Name: profile, Msg: fmt.Sprintf("profile %q not found", profile)}, false
|
||||
}
|
||||
return nil, true
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
|
@ -111,3 +112,26 @@ func TestIsAddonAlreadySet(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateProfile(t *testing.T) {
|
||||
testCases := []struct {
|
||||
profileName string
|
||||
}{
|
||||
{
|
||||
profileName: "82374328742_2974224498",
|
||||
},
|
||||
{
|
||||
profileName: "minikube",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
profileNam := test.profileName
|
||||
expectedMsg := fmt.Sprintf("profile %q not found", test.profileName)
|
||||
|
||||
err, ok := ValidateProfile(profileNam)
|
||||
if !ok && err.Error() != expectedMsg {
|
||||
t.Errorf("Didnt receive expected message")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ Wants=crio.service
|
|||
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=/var/lib/minikube/binaries/v1.16.0/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --container-runtime=remote --container-runtime-endpoint=/var/run/crio/crio.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=/var/run/crio/crio.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m
|
||||
ExecStart=/var/lib/minikube/binaries/v1.16.1/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --container-runtime=remote --container-runtime-endpoint=/var/run/crio/crio.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=/var/run/crio/crio.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m
|
||||
|
||||
[Install]
|
||||
`,
|
||||
|
@ -84,7 +84,7 @@ Wants=containerd.service
|
|||
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=/var/lib/minikube/binaries/v1.16.0/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --container-runtime=remote --container-runtime-endpoint=unix:///run/containerd/containerd.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=unix:///run/containerd/containerd.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m
|
||||
ExecStart=/var/lib/minikube/binaries/v1.16.1/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --container-runtime=remote --container-runtime-endpoint=unix:///run/containerd/containerd.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=unix:///run/containerd/containerd.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m
|
||||
|
||||
[Install]
|
||||
`,
|
||||
|
@ -109,7 +109,7 @@ Wants=containerd.service
|
|||
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=/var/lib/minikube/binaries/v1.16.0/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --container-runtime=remote --container-runtime-endpoint=unix:///run/containerd/containerd.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=unix:///run/containerd/containerd.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.200 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m
|
||||
ExecStart=/var/lib/minikube/binaries/v1.16.1/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --container-runtime=remote --container-runtime-endpoint=unix:///run/containerd/containerd.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=unix:///run/containerd/containerd.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.200 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m
|
||||
|
||||
[Install]
|
||||
`,
|
||||
|
@ -128,7 +128,7 @@ Wants=docker.socket
|
|||
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=/var/lib/minikube/binaries/v1.16.0/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --container-runtime=docker --fail-swap-on=false --hostname-override=minikube --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-infra-container-image=docker-proxy-image.io/google_containers/pause:3.1 --pod-manifest-path=/etc/kubernetes/manifests
|
||||
ExecStart=/var/lib/minikube/binaries/v1.16.1/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --container-runtime=docker --fail-swap-on=false --hostname-override=minikube --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-infra-container-image=docker-proxy-image.io/google_containers/pause:3.1 --pod-manifest-path=/etc/kubernetes/manifests
|
||||
|
||||
[Install]
|
||||
`,
|
||||
|
|
|
@ -92,10 +92,10 @@ var DefaultISOURL = fmt.Sprintf("https://storage.googleapis.com/%s/minikube-%s.i
|
|||
var DefaultISOSHAURL = DefaultISOURL + SHASuffix
|
||||
|
||||
// DefaultKubernetesVersion is the default kubernetes version
|
||||
var DefaultKubernetesVersion = "v1.16.0"
|
||||
var DefaultKubernetesVersion = "v1.16.1"
|
||||
|
||||
// NewestKubernetesVersion is the newest Kubernetes version to test against
|
||||
var NewestKubernetesVersion = "v1.16.0"
|
||||
var NewestKubernetesVersion = "v1.16.1"
|
||||
|
||||
// OldestKubernetesVersion is the oldest Kubernetes version to test against
|
||||
var OldestKubernetesVersion = "v1.11.10"
|
||||
|
|
|
@ -18,6 +18,7 @@ limitations under the License.
|
|||
|
||||
package constants
|
||||
|
||||
// DefaultMountDir is the default mounting directory for Darwin
|
||||
var DefaultMountDir = "/Users"
|
||||
|
||||
// SupportedVMDrivers is a list of supported drivers on Darwin.
|
||||
|
|
|
@ -385,7 +385,7 @@ func checkKeyValueExpression(kvp *ast.KeyValueExpr, e *state) {
|
|||
|
||||
// Ok now this is just a mess
|
||||
if help, ok := kvp.Value.(*ast.BinaryExpr); ok {
|
||||
s := checkBinaryExpression(help, e)
|
||||
s := checkBinaryExpression(help)
|
||||
if s != "" {
|
||||
e.translations[s] = ""
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ func checkKeyValueExpression(kvp *ast.KeyValueExpr, e *state) {
|
|||
}
|
||||
|
||||
// checkBinaryExpression checks binary expressions, stuff of the form x + y, for strings and concats them
|
||||
func checkBinaryExpression(b *ast.BinaryExpr, e *state) string {
|
||||
func checkBinaryExpression(b *ast.BinaryExpr) string {
|
||||
// Check the left side
|
||||
var s string
|
||||
if l, ok := b.X.(*ast.BasicLit); ok {
|
||||
|
@ -410,7 +410,7 @@ func checkBinaryExpression(b *ast.BinaryExpr, e *state) string {
|
|||
}
|
||||
|
||||
if b1, ok := b.X.(*ast.BinaryExpr); ok {
|
||||
if x := checkBinaryExpression(b1, e); x != "" {
|
||||
if x := checkBinaryExpression(b1); x != "" {
|
||||
s += x
|
||||
}
|
||||
}
|
||||
|
@ -429,7 +429,7 @@ func checkBinaryExpression(b *ast.BinaryExpr, e *state) string {
|
|||
}
|
||||
|
||||
if b1, ok := b.Y.(*ast.BinaryExpr); ok {
|
||||
if x := checkBinaryExpression(b1, e); x != "" {
|
||||
if x := checkBinaryExpression(b1); x != "" {
|
||||
s += x
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,8 +122,8 @@ func (mgr *Manager) run(ctx context.Context, t controller, ready, check, done ch
|
|||
}
|
||||
}
|
||||
|
||||
func (mgr *Manager) cleanup(t controller) *Status {
|
||||
return t.cleanup()
|
||||
func (mgr *Manager) cleanup(t controller) {
|
||||
t.cleanup()
|
||||
}
|
||||
|
||||
// CleanupNotRunningTunnels cleans up tunnels that are not running
|
||||
|
|
Loading…
Reference in New Issue