make profile name mandatory for config.Load
parent
2895971182
commit
35ad8e2915
|
@ -76,7 +76,7 @@ var ProfileCmd = &cobra.Command{
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exit.WithError("Setting profile failed", err)
|
exit.WithError("Setting profile failed", err)
|
||||||
}
|
}
|
||||||
cc, err := pkgConfig.Load()
|
cc, err := pkgConfig.Load(profile)
|
||||||
// might err when loading older version of cfg file that doesn't have KeepContext field
|
// might err when loading older version of cfg file that doesn't have KeepContext field
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
out.ErrT(out.Sad, `Error loading profile config: {{.error}}`, out.V{"error": err})
|
out.ErrT(out.Sad, `Error loading profile config: {{.error}}`, out.V{"error": err})
|
||||||
|
|
|
@ -23,6 +23,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/spf13/viper"
|
||||||
"k8s.io/minikube/pkg/minikube/assets"
|
"k8s.io/minikube/pkg/minikube/assets"
|
||||||
"k8s.io/minikube/pkg/minikube/cluster"
|
"k8s.io/minikube/pkg/minikube/cluster"
|
||||||
"k8s.io/minikube/pkg/minikube/command"
|
"k8s.io/minikube/pkg/minikube/command"
|
||||||
|
@ -137,7 +138,7 @@ func EnableOrDisableAddon(name string, val string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg, err := config.Load()
|
cfg, err := config.Load(viper.GetString(config.MachineProfile))
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
exit.WithCodeT(exit.Data, "Unable to load config: {{.error}}", out.V{"error": err})
|
exit.WithCodeT(exit.Data, "Unable to load config: {{.error}}", out.V{"error": err})
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import (
|
||||||
|
|
||||||
units "github.com/docker/go-units"
|
units "github.com/docker/go-units"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/spf13/viper"
|
||||||
"k8s.io/minikube/pkg/minikube/assets"
|
"k8s.io/minikube/pkg/minikube/assets"
|
||||||
"k8s.io/minikube/pkg/minikube/config"
|
"k8s.io/minikube/pkg/minikube/config"
|
||||||
"k8s.io/minikube/pkg/minikube/cruntime"
|
"k8s.io/minikube/pkg/minikube/cruntime"
|
||||||
|
@ -158,7 +159,7 @@ func IsValidRuntime(name string, runtime string) error {
|
||||||
|
|
||||||
// IsContainerdRuntime is a validator which returns an error if the current runtime is not containerd
|
// IsContainerdRuntime is a validator which returns an error if the current runtime is not containerd
|
||||||
func IsContainerdRuntime(_, _ string) error {
|
func IsContainerdRuntime(_, _ string) error {
|
||||||
config, err := config.Load()
|
config, err := config.Load(viper.GetString(config.MachineProfile))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("config.Load: %v", err)
|
return fmt.Errorf("config.Load: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,11 @@ import (
|
||||||
"github.com/pkg/browser"
|
"github.com/pkg/browser"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/spf13/viper"
|
||||||
configcmd "k8s.io/minikube/cmd/minikube/cmd/config"
|
configcmd "k8s.io/minikube/cmd/minikube/cmd/config"
|
||||||
"k8s.io/minikube/pkg/minikube/assets"
|
"k8s.io/minikube/pkg/minikube/assets"
|
||||||
"k8s.io/minikube/pkg/minikube/cluster"
|
"k8s.io/minikube/pkg/minikube/cluster"
|
||||||
|
"k8s.io/minikube/pkg/minikube/config"
|
||||||
pkg_config "k8s.io/minikube/pkg/minikube/config"
|
pkg_config "k8s.io/minikube/pkg/minikube/config"
|
||||||
"k8s.io/minikube/pkg/minikube/exit"
|
"k8s.io/minikube/pkg/minikube/exit"
|
||||||
"k8s.io/minikube/pkg/minikube/machine"
|
"k8s.io/minikube/pkg/minikube/machine"
|
||||||
|
@ -57,7 +59,7 @@ var dashboardCmd = &cobra.Command{
|
||||||
Short: "Access the kubernetes dashboard running within the minikube cluster",
|
Short: "Access the kubernetes dashboard running within the minikube cluster",
|
||||||
Long: `Access the kubernetes dashboard running within the minikube cluster`,
|
Long: `Access the kubernetes dashboard running within the minikube cluster`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
cc, err := pkg_config.Load()
|
cc, err := pkg_config.Load(viper.GetString(config.MachineProfile))
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
exit.WithError("Error loading profile config", err)
|
exit.WithError("Error loading profile config", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,8 +187,7 @@ func deleteProfile(profile *pkg_config.Profile) error {
|
||||||
return DeletionError{Err: delErr, Errtype: Fatal}
|
return DeletionError{Err: delErr, Errtype: Fatal}
|
||||||
}
|
}
|
||||||
defer api.Close()
|
defer api.Close()
|
||||||
|
cc, err := pkg_config.Load(profile.Name)
|
||||||
cc, err := pkg_config.Load()
|
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
delErr := profileDeletionErr(profile.Name, fmt.Sprintf("error loading profile config: %v", err))
|
delErr := profileDeletionErr(profile.Name, fmt.Sprintf("error loading profile config: %v", err))
|
||||||
return DeletionError{Err: delErr, Errtype: MissingProfile}
|
return DeletionError{Err: delErr, Errtype: MissingProfile}
|
||||||
|
|
|
@ -340,7 +340,7 @@ var dockerEnvCmd = &cobra.Command{
|
||||||
exit.WithError("Error getting client", err)
|
exit.WithError("Error getting client", err)
|
||||||
}
|
}
|
||||||
defer api.Close()
|
defer api.Close()
|
||||||
cc, err := config.Load()
|
cc, err := config.Load(viper.GetString(config.MachineProfile))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exit.WithError("Error getting config", err)
|
exit.WithError("Error getting config", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"github.com/docker/machine/libmachine/mcnerror"
|
"github.com/docker/machine/libmachine/mcnerror"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/spf13/viper"
|
||||||
"k8s.io/minikube/pkg/minikube/config"
|
"k8s.io/minikube/pkg/minikube/config"
|
||||||
"k8s.io/minikube/pkg/minikube/exit"
|
"k8s.io/minikube/pkg/minikube/exit"
|
||||||
"k8s.io/minikube/pkg/minikube/machine"
|
"k8s.io/minikube/pkg/minikube/machine"
|
||||||
|
@ -38,7 +39,7 @@ var ipCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
defer api.Close()
|
defer api.Close()
|
||||||
|
|
||||||
cc, err := config.Load()
|
cc, err := config.Load(viper.GetString(config.MachineProfile))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exit.WithError("Error getting config", err)
|
exit.WithError("Error getting config", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,8 @@ import (
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
"k8s.io/minikube/pkg/minikube/config"
|
||||||
pkg_config "k8s.io/minikube/pkg/minikube/config"
|
pkg_config "k8s.io/minikube/pkg/minikube/config"
|
||||||
"k8s.io/minikube/pkg/minikube/constants"
|
"k8s.io/minikube/pkg/minikube/constants"
|
||||||
"k8s.io/minikube/pkg/minikube/exit"
|
"k8s.io/minikube/pkg/minikube/exit"
|
||||||
|
@ -48,7 +50,7 @@ kubectl get pods --namespace kube-system`,
|
||||||
}
|
}
|
||||||
defer api.Close()
|
defer api.Close()
|
||||||
|
|
||||||
cc, err := pkg_config.Load()
|
cc, err := pkg_config.Load(viper.GetString(config.MachineProfile))
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
out.ErrLn("Error loading profile config: %v", err)
|
out.ErrLn("Error loading profile config: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ var logsCmd = &cobra.Command{
|
||||||
Short: "Gets the logs of the running instance, used for debugging minikube, not user code.",
|
Short: "Gets the logs of the running instance, used for debugging minikube, not user code.",
|
||||||
Long: `Gets the logs of the running instance, used for debugging minikube, not user code.`,
|
Long: `Gets the logs of the running instance, used for debugging minikube, not user code.`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
cfg, err := config.Load()
|
cfg, err := config.Load(viper.GetString(config.MachineProfile))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exit.WithError("Error getting config", err)
|
exit.WithError("Error getting config", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import (
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/spf13/viper"
|
||||||
"k8s.io/minikube/pkg/minikube/cluster"
|
"k8s.io/minikube/pkg/minikube/cluster"
|
||||||
"k8s.io/minikube/pkg/minikube/config"
|
"k8s.io/minikube/pkg/minikube/config"
|
||||||
"k8s.io/minikube/pkg/minikube/driver"
|
"k8s.io/minikube/pkg/minikube/driver"
|
||||||
|
@ -102,7 +103,7 @@ var mountCmd = &cobra.Command{
|
||||||
exit.WithError("Error getting client", err)
|
exit.WithError("Error getting client", err)
|
||||||
}
|
}
|
||||||
defer api.Close()
|
defer api.Close()
|
||||||
cc, err := config.Load()
|
cc, err := config.Load(viper.GetString(config.MachineProfile))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exit.WithError("Error getting config", err)
|
exit.WithError("Error getting config", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/spf13/viper"
|
||||||
"k8s.io/minikube/pkg/minikube/config"
|
"k8s.io/minikube/pkg/minikube/config"
|
||||||
"k8s.io/minikube/pkg/minikube/exit"
|
"k8s.io/minikube/pkg/minikube/exit"
|
||||||
"k8s.io/minikube/pkg/minikube/localpath"
|
"k8s.io/minikube/pkg/minikube/localpath"
|
||||||
|
@ -32,7 +33,7 @@ var sshKeyCmd = &cobra.Command{
|
||||||
Short: "Retrieve the ssh identity key path of the specified cluster",
|
Short: "Retrieve the ssh identity key path of the specified cluster",
|
||||||
Long: "Retrieve the ssh identity key path of the specified cluster.",
|
Long: "Retrieve the ssh identity key path of the specified cluster.",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
cc, err := config.Load()
|
cc, err := config.Load(viper.GetString(config.MachineProfile))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exit.WithError("Getting machine config failed", err)
|
exit.WithError("Getting machine config failed", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ var sshCmd = &cobra.Command{
|
||||||
exit.WithError("Error getting client", err)
|
exit.WithError("Error getting client", err)
|
||||||
}
|
}
|
||||||
defer api.Close()
|
defer api.Close()
|
||||||
cc, err := config.Load()
|
cc, err := config.Load(viper.GetString(config.MachineProfile))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exit.WithError("Error getting config", err)
|
exit.WithError("Error getting config", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ import (
|
||||||
"k8s.io/minikube/pkg/minikube/bootstrapper/kubeadm"
|
"k8s.io/minikube/pkg/minikube/bootstrapper/kubeadm"
|
||||||
"k8s.io/minikube/pkg/minikube/cluster"
|
"k8s.io/minikube/pkg/minikube/cluster"
|
||||||
"k8s.io/minikube/pkg/minikube/command"
|
"k8s.io/minikube/pkg/minikube/command"
|
||||||
|
"k8s.io/minikube/pkg/minikube/config"
|
||||||
cfg "k8s.io/minikube/pkg/minikube/config"
|
cfg "k8s.io/minikube/pkg/minikube/config"
|
||||||
"k8s.io/minikube/pkg/minikube/constants"
|
"k8s.io/minikube/pkg/minikube/constants"
|
||||||
"k8s.io/minikube/pkg/minikube/cruntime"
|
"k8s.io/minikube/pkg/minikube/cruntime"
|
||||||
|
@ -287,7 +288,7 @@ func runStart(cmd *cobra.Command, args []string) {
|
||||||
registryMirror = viper.GetStringSlice("registry_mirror")
|
registryMirror = viper.GetStringSlice("registry_mirror")
|
||||||
}
|
}
|
||||||
|
|
||||||
existing, err := cfg.Load()
|
existing, err := cfg.Load(viper.GetString(config.MachineProfile))
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
exit.WithCodeT(exit.Data, "Unable to load config: {{.error}}", out.V{"error": err})
|
exit.WithCodeT(exit.Data, "Unable to load config: {{.error}}", out.V{"error": err})
|
||||||
}
|
}
|
||||||
|
@ -729,7 +730,7 @@ func validateUser(drvName string) {
|
||||||
if !useForce {
|
if !useForce {
|
||||||
os.Exit(exit.Permissions)
|
os.Exit(exit.Permissions)
|
||||||
}
|
}
|
||||||
_, err = cfg.Load()
|
_, err = cfg.Load(viper.GetString(config.MachineProfile))
|
||||||
if err == nil || !os.IsNotExist(err) {
|
if err == nil || !os.IsNotExist(err) {
|
||||||
out.T(out.Tip, "Tip: To remove this root owned cluster, run: sudo {{.cmd}} delete", out.V{"cmd": minikubeCmd()})
|
out.T(out.Tip, "Tip: To remove this root owned cluster, run: sudo {{.cmd}} delete", out.V{"cmd": minikubeCmd()})
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import (
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/spf13/viper"
|
||||||
"k8s.io/minikube/pkg/minikube/config"
|
"k8s.io/minikube/pkg/minikube/config"
|
||||||
"k8s.io/minikube/pkg/minikube/exit"
|
"k8s.io/minikube/pkg/minikube/exit"
|
||||||
"k8s.io/minikube/pkg/minikube/machine"
|
"k8s.io/minikube/pkg/minikube/machine"
|
||||||
|
@ -76,11 +77,11 @@ var tunnelCmd = &cobra.Command{
|
||||||
cancel()
|
cancel()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
cc, err := config.Load()
|
cfg, err := config.Load(viper.GetString(config.MachineProfile))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exit.WithError("Error getting config", err)
|
exit.WithError("Error getting config", err)
|
||||||
}
|
}
|
||||||
done, err := manager.StartTunnel(ctx, cc.Name, api, config.DefaultLoader, clientset.CoreV1())
|
done, err := manager.StartTunnel(ctx, cfg.Name, api, config.DefaultLoader, clientset.CoreV1())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exit.WithError("error starting tunnel", err)
|
exit.WithError("error starting tunnel", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
|
||||||
"k8s.io/minikube/pkg/minikube/localpath"
|
"k8s.io/minikube/pkg/minikube/localpath"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -124,12 +123,8 @@ func encode(w io.Writer, m MinikubeConfig) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load loads the kubernetes and machine config for the current machine
|
// Load loads the kubernetes and machine config for the current machine
|
||||||
func Load(profile ...string) (*MachineConfig, error) {
|
func Load(profile string) (*MachineConfig, error) {
|
||||||
machine := viper.GetString(MachineProfile)
|
return DefaultLoader.LoadConfigFromFile(profile)
|
||||||
if len(profile) > 0 {
|
|
||||||
machine = profile[0]
|
|
||||||
}
|
|
||||||
return DefaultLoader.LoadConfigFromFile(machine)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loader loads the kubernetes and machine config based on the machine profile name
|
// Loader loads the kubernetes and machine config based on the machine profile name
|
||||||
|
|
|
@ -314,7 +314,7 @@ func configureAuth(p *BuildrootProvisioner) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
config, err := config.Load()
|
config, err := config.Load(p.Driver.GetMachineName())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "getting cluster config")
|
return errors.Wrap(err, "getting cluster config")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue