config

package
v1.31.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 43 Imported by: 61

Documentation

Index

Constants

View Source
const Bootstrapper = "bootstrapper"

Bootstrapper is the name for bootstrapper

Variables

View Source
var AddonsCmd = &cobra.Command{
	Use:   "addons SUBCOMMAND [flags]",
	Short: "Enable or disable a minikube addon",
	Long:  `addons modifies minikube addons files using subcommands like "minikube addons enable dashboard"`,
	Run: func(cmd *cobra.Command, args []string) {
		if err := cmd.Help(); err != nil {
			klog.Errorf("help: %v", err)
		}
	},
}

AddonsCmd represents the addons command

View Source
var ConfigCmd = &cobra.Command{
	Use:   "config SUBCOMMAND [flags]",
	Short: "Modify persistent configuration values",
	Long: `config modifies minikube config files using subcommands like "minikube config set driver kvm2"
Configurable fields: ` + "\n\n" + configurableFields(),
	Run: func(cmd *cobra.Command, args []string) {
		if err := cmd.Help(); err != nil {
			klog.ErrorS(err, "help")
		}
	},
}

ConfigCmd represents the config command

View Source
var ProfileCmd = &cobra.Command{
	Use:   "profile [MINIKUBE_PROFILE_NAME].  You can return to the default minikube profile by running `minikube profile default`",
	Short: "Get or list the current profiles (clusters)",
	Long:  "profile sets the current minikube profile, or gets the current profile if no arguments are provided.  This is used to run and manage multiple minikube instance.  You can return to the default minikube profile by running `minikube profile default`",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			profile := ClusterFlagValue()
			out.Styled(style.Empty, profile)
			os.Exit(0)
		}

		if len(args) > 1 {
			exit.Message(reason.Usage, "usage: minikube profile [MINIKUBE_PROFILE_NAME]")
		}

		profile := args[0]

		if !config.ProfileNameValid(profile) {
			out.WarningT("Profile name '{{.profilename}}' is not valid", out.V{"profilename": profile})
			exit.Message(reason.Usage, "Only alphanumeric and dashes '-' are permitted. Minimum 1 character, starting with alphanumeric.")
		}

		if config.ProfileNameInReservedKeywords(profile) {
			exit.Message(reason.InternalReservedProfile, `Profile name "{{.profilename}}" is reserved keyword. To delete this profile, run: "{{.cmd}}"`, out.V{"profilename": profile, "cmd": mustload.ExampleCmd(profile, "delete")})
		}

		if profile == "default" {
			profile = "minikube"
		} else {

			errProfile, ok := ValidateProfile(profile)
			if !ok && errProfile != nil {
				out.FailureT(errProfile.Msg)
			}
		}

		if !config.ProfileExists(profile) {
			out.ErrT(style.Tip, `if you want to create a profile you can by this command: minikube start -p {{.profile_name}}`, out.V{"profile_name": profile})
			os.Exit(0)
		}

		err := Set(config.ProfileName, profile)
		if err != nil {
			exit.Error(reason.InternalConfigSet, "Setting profile failed", err)
		}
		cc, err := config.Load(profile)

		if err != nil && !config.IsNotExist(err) {
			out.ErrT(style.Sad, `Error loading profile config: {{.error}}`, out.V{"error": err})
		}
		if err == nil {
			if cc.KeepContext {
				out.SuccessT("Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.", out.V{"profile_name": profile})
				out.SuccessT("To connect to this cluster, use: kubectl --context={{.profile_name}}", out.V{"profile_name": profile})
			} else {
				err := kubeconfig.SetCurrentContext(profile, kubeconfig.PathFromEnv())
				if err != nil {
					out.ErrT(style.Sad, `Error while setting kubectl current context :  {{.error}}`, out.V{"error": err})
				}
			}
			out.SuccessT("minikube profile was successfully set to {{.profile_name}}", out.V{"profile_name": profile})
		}
	},
}

ProfileCmd represents the profile command

Functions

func AddToConfigMap added in v0.24.0

func AddToConfigMap(name string, images []string) error

AddToConfigMap adds entries to a map in the config file

func AskForPasswordValue added in v0.21.0

func AskForPasswordValue(s string) string

AskForPasswordValue asks for a password value, while hiding the input

func AskForStaticValidatedValue added in v1.10.0

func AskForStaticValidatedValue(s string, validator func(s string) bool) string

AskForStaticValidatedValue asks for a single value to enter and check for valid input

func AskForStaticValue added in v0.17.0

func AskForStaticValue(s string) string

AskForStaticValue asks for a single value to enter

func AskForStaticValueOptional added in v0.22.0

func AskForStaticValueOptional(s string) string

AskForStaticValueOptional asks for a optional single value to enter, can just skip enter

func AskForYesNoConfirmation added in v0.17.0

func AskForYesNoConfirmation(s string, posResponses, negResponses []string) bool

AskForYesNoConfirmation asks the user for confirmation. A user must type in "yes" or "no" and then press enter. It has fuzzy matching, so "y", "Y", "yes", "YES", and "Yes" all count as confirmations. If the input is not recognized, it will ask again. The function does not return until it gets a valid response from the user.

func ClusterFlagValue added in v1.9.0

func ClusterFlagValue() string

ClusterFlagValue returns the current cluster name based on flags

func DeleteFromConfigMap added in v0.24.0

func DeleteFromConfigMap(name string, images []string) error

DeleteFromConfigMap deletes entries from a map in the config file

func Get added in v1.0.0

func Get(name string) (string, error)

Get gets a property

func IsPositive

func IsPositive(name, val string) error

IsPositive checks if an integer is positive

func IsURLExists added in v0.31.0

func IsURLExists(_, location string) error

IsURLExists checks if a location actually exists

func IsValidCIDR

func IsValidCIDR(_, cidr string) error

IsValidCIDR checks if a string parses as a CIDR

func IsValidCPUs added in v1.22.0

func IsValidCPUs(name, cpus string) error

IsValidCPUs checks if a string is a valid number of CPUs

func IsValidDiskSize

func IsValidDiskSize(_, disksize string) error

IsValidDiskSize checks if a string is a valid disk size

func IsValidDriver

func IsValidDriver(_, name string) error

IsValidDriver checks if a driver is supported

func IsValidMemory added in v1.19.0

func IsValidMemory(_, memsize string) error

IsValidMemory checks if a string is a valid memory size

func IsValidPath

func IsValidPath(name, path string) error

IsValidPath checks if a string is a valid path

func IsValidRuntime added in v1.6.0

func IsValidRuntime(_, runtime string) error

IsValidRuntime checks if a string is a valid runtime

func IsValidURL added in v0.14.0

func IsValidURL(_, location string) error

IsValidURL checks if a location is a valid URL

func ListConfigMap added in v0.25.0

func ListConfigMap(name string) ([]string, error)

ListConfigMap list entries from config file

func RequiresRestartMsg

func RequiresRestartMsg(_, _ string) error

RequiresRestartMsg returns the "requires restart" message

func Set added in v0.11.0

func Set(name string, value string) error

Set sets a property to a value

func SetBool

func SetBool(m config.MinikubeConfig, name string, val string) error

SetBool sets a bool value

func SetConfigMap added in v0.24.0

func SetConfigMap(m config.MinikubeConfig, name string, val string) error

SetConfigMap sets a config map value

func SetInt

func SetInt(m config.MinikubeConfig, name string, val string) error

SetInt sets an int value

func SetMap added in v0.24.0

func SetMap(m config.MinikubeConfig, name string, val map[string]interface{}) error

SetMap sets a map value

func SetString

func SetString(m config.MinikubeConfig, name string, val string) error

SetString sets a string value

func Unset added in v1.3.0

func Unset(name string) error

Unset unsets a property

func View added in v1.0.0

func View() error

View displays the current config

Types

type AddonListTemplate added in v0.12.0

type AddonListTemplate struct {
	AddonName   string
	AddonStatus string
}

AddonListTemplate represents the addon list template

type ErrValidateProfile added in v1.5.0

type ErrValidateProfile struct {
	Name string
	Msg  string
}

ErrValidateProfile Error to validate profile

func ValidateProfile added in v1.5.0

func ValidateProfile(profile string) (*ErrValidateProfile, bool)

ValidateProfile checks if the profile user is trying to switch exists, else throws error

func (ErrValidateProfile) Error added in v1.5.0

func (e ErrValidateProfile) Error() string

type Setting

type Setting struct {
	// contains filtered or unexported fields
}

Setting represents a setting

type ViewTemplate added in v1.0.0

type ViewTemplate struct {
	ConfigKey   string
	ConfigValue interface{}
}

ViewTemplate represents the view template

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL