當前位置: 首頁>>代碼示例>>Golang>>正文


Golang config.NewDefaultPathOptions函數代碼示例

本文整理匯總了Golang中k8s/io/kubernetes/pkg/kubectl/cmd/config.NewDefaultPathOptions函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewDefaultPathOptions函數的具體用法?Golang NewDefaultPathOptions怎麽用?Golang NewDefaultPathOptions使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewDefaultPathOptions函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: SetupContext

// SetupContext creates a new cluster and context in ~/.kube using the provided API Server. If setCurrent is true, it is made the current context.
func SetupContext(clusterName, contextName, kubeAPIServer string, setCurrent bool) error {
	pathOpts := kubectlcfg.NewDefaultPathOptions()
	config, err := getConfig(pathOpts)
	if err != nil {
		return err
	}

	cluster, exists := config.Clusters[clusterName]
	if !exists {
		cluster = kubecfg.NewCluster()
	}

	// configure cluster
	cluster.Server = kubeAPIServer
	cluster.InsecureSkipTLSVerify = true
	config.Clusters[clusterName] = cluster

	context, exists := config.Contexts[contextName]
	if !exists {
		context = kubecfg.NewContext()
	}

	// configure context
	context.Cluster = clusterName
	config.Contexts[contextName] = context

	// set as current if requested
	if setCurrent {
		config.CurrentContext = contextName
	}

	return kubectlcfg.ModifyConfig(pathOpts, *config, true)
}
開發者ID:redspread,項目名稱:spread,代碼行數:34,代碼來源:context.go

示例2: defaultLoadingRules

// defaultLoadingRules use the same rules (as of 2/17/16) as kubectl.
func defaultLoadingRules() *clientcmd.ClientConfigLoadingRules {
	opts := config.NewDefaultPathOptions()

	loadingRules := opts.LoadingRules
	loadingRules.Precedence = opts.GetLoadingPrecedence()
	return loadingRules
}
開發者ID:redspread,項目名稱:spread,代碼行數:8,代碼來源:cluster.go

示例3: NewKubectlCommand

// NewKubectlCommand creates the `kubectl` command and its nested children.
func NewKubectlCommand(f *cmdutil.Factory, in io.Reader, out, err io.Writer) *cobra.Command {
	// Parent command to which all subcommands are added.
	cmds := &cobra.Command{
		Use:   "kubectl",
		Short: "kubectl controls the Kubernetes cluster manager",
		Long: `kubectl controls the Kubernetes cluster manager.

Find more information at https://github.com/kubernetes/kubernetes.`,
		Run: runHelp,
		BashCompletionFunction: bash_completion_func,
	}

	f.BindFlags(cmds.PersistentFlags())
	f.BindExternalFlags(cmds.PersistentFlags())

	// From this point and forward we get warnings on flags that contain "_" separators
	cmds.SetGlobalNormalizationFunc(flag.WarnWordSepNormalizeFunc)

	cmds.AddCommand(NewCmdGet(f, out))
	cmds.AddCommand(NewCmdDescribe(f, out))
	cmds.AddCommand(NewCmdCreate(f, out))
	cmds.AddCommand(NewCmdReplace(f, out))
	cmds.AddCommand(NewCmdPatch(f, out))
	cmds.AddCommand(NewCmdDelete(f, out))
	cmds.AddCommand(NewCmdEdit(f, out, err))
	cmds.AddCommand(NewCmdApply(f, out))

	cmds.AddCommand(NewCmdNamespace(out))
	cmds.AddCommand(NewCmdLogs(f, out))
	cmds.AddCommand(NewCmdRollingUpdate(f, out))
	cmds.AddCommand(NewCmdScale(f, out))
	cmds.AddCommand(NewCmdCordon(f, out))
	cmds.AddCommand(NewCmdDrain(f, out))
	cmds.AddCommand(NewCmdUncordon(f, out))

	cmds.AddCommand(NewCmdAttach(f, in, out, err))
	cmds.AddCommand(NewCmdExec(f, in, out, err))
	cmds.AddCommand(NewCmdPortForward(f))
	cmds.AddCommand(NewCmdProxy(f, out))

	cmds.AddCommand(NewCmdRun(f, in, out, err))
	cmds.AddCommand(NewCmdStop(f, out))
	cmds.AddCommand(NewCmdExposeService(f, out))
	cmds.AddCommand(NewCmdAutoscale(f, out))
	cmds.AddCommand(rollout.NewCmdRollout(f, out))

	cmds.AddCommand(NewCmdLabel(f, out))
	cmds.AddCommand(NewCmdAnnotate(f, out))

	cmds.AddCommand(cmdconfig.NewCmdConfig(cmdconfig.NewDefaultPathOptions(), out))
	cmds.AddCommand(NewCmdClusterInfo(f, out))
	cmds.AddCommand(NewCmdApiVersions(f, out))
	cmds.AddCommand(NewCmdVersion(f, out))
	cmds.AddCommand(NewCmdExplain(f, out))
	cmds.AddCommand(NewCmdConvert(f, out))

	return cmds
}
開發者ID:RomainVabre,項目名稱:origin,代碼行數:59,代碼來源:cmd.go

示例4: GetCurrentContext

// GetCurrentContext returns the context currently being used by kubectl
func GetCurrentContext() (string, error) {
	pathOpts := kubectlcfg.NewDefaultPathOptions()
	config, err := getConfig(pathOpts)
	if err != nil {
		return "", err
	}

	return config.CurrentContext, nil
}
開發者ID:redspread,項目名稱:spread,代碼行數:10,代碼來源:context.go

示例5: SetCurrentContext

// SetCurrentContext changes the kubectl context to the given value
func SetCurrentContext(context string) error {
	pathOpts := kubectlcfg.NewDefaultPathOptions()
	config, err := getConfig(pathOpts)
	if err != nil {
		return err
	}

	config.CurrentContext = context
	return kubectlcfg.ModifyConfig(pathOpts, *config, true)
}
開發者ID:redspread,項目名稱:spread,代碼行數:11,代碼來源:context.go

示例6: ValidateToken

// ValidateToken validates that the given token is valid on the given server
//
// It returns a client config if successful, or an error
func ValidateToken(server string, token string) (*kclient.Config, error) {
	opts := &cmd.LoginOptions{
		Server:             server,
		Token:              token,
		InsecureTLS:        true,
		APIVersion:         api.Version,
		StartingKubeConfig: kclientcmdapi.NewConfig(),
		PathOptions:        kcmdconfig.NewDefaultPathOptions(),
		Out:                ioutil.Discard,
	}

	// check the token
	if err := opts.GatherInfo(); err != nil {
		return nil, err
	}

	return opts.Config, nil
}
開發者ID:AXA-GROUP-SOLUTIONS,項目名稱:openshift-cucumber,代碼行數:21,代碼來源:login.go

示例7: Login

// Login uses the given server/username/password to login on an openshift instance
//
// It returns a client config if successful, or an error
func Login(server string, username string, password string) (*kclient.Config, error) {
	opts := &cmd.LoginOptions{
		Server:             server,
		Username:           username,
		Password:           password,
		InsecureTLS:        true,
		APIVersion:         api.Version,
		StartingKubeConfig: kclientcmdapi.NewConfig(),
		PathOptions:        kcmdconfig.NewDefaultPathOptions(),
		Out:                ioutil.Discard,
	}

	// perform the login, and store a new token in opts
	if err := opts.GatherInfo(); err != nil {
		return nil, err
	}

	return opts.Config, nil
}
開發者ID:AXA-GROUP-SOLUTIONS,項目名稱:openshift-cucumber,代碼行數:22,代碼來源:login.go


注:本文中的k8s/io/kubernetes/pkg/kubectl/cmd/config.NewDefaultPathOptions函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。