// Login takes of authentication part and returns error if there any
Login takes of authentication part and returns error if there any
// Login takes of authentication part and returns error if there any
func Login(server, username, password, token, caAuth string, skipTLS bool) error {
	a := login.LoginOptions{
		Server:         server,
		CommandName:    "odo",
		CAFile:         caAuth,
		InsecureTLS:    skipTLS,
		Username:       username,
		Password:       password,
		Project:        "",
		Token:          token,
		PathOptions:    &clientcmd.PathOptions{GlobalFile: clientcmd.RecommendedHomeFile, EnvVar: clientcmd.RecommendedConfigPathEnvVar, ExplicitFileFlag: "config", LoadingRules: &clientcmd.ClientConfigLoadingRules{ExplicitPath: ""}},
		RequestTimeout: 0,
		IOStreams:      genericclioptions.IOStreams{Out: os.Stdout, In: os.Stdin},
	}
	loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
	configOverrides := &clientcmd.ConfigOverrides{}
	kubeConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, configOverrides)
	kubeconfig, _ := kubeConfig.RawConfig()
	a.StartingKubeConfig = &kubeconfig
	if len(a.Server) == 0 {
		if defaultContext, defaultContextExists := a.StartingKubeConfig.Contexts[a.StartingKubeConfig.CurrentContext]; defaultContextExists {
			if cluster, exists := a.StartingKubeConfig.Clusters[defaultContext.Cluster]; exists {
				a.Server = cluster.Server
			}
		}
	}
	err := a.Run()
	if err != nil {
		return err
	}
	return nil
}
func Login ( server , username , password , token , caAuth string , skipTLS bool ) error { a := login . LoginOptions { Server : server , CommandName : " " , CAFile : caAuth , InsecureTLS : skipTLS , Username : username , Password : password , Project : " " , Token : token , PathOptions : & clientcmd . PathOptions { GlobalFile : clientcmd . RecommendedHomeFile , EnvVar : clientcmd . RecommendedConfigPathEnvVar , ExplicitFileFlag : " " , LoadingRules : & clientcmd . ClientConfigLoadingRules { ExplicitPath : " " } } , RequestTimeout : 0 , IOStreams : genericclioptions . IOStreams { Out : os . Stdout , In : os . Stdin } , } loadingRules := clientcmd . NewDefaultClientConfigLoadingRules ( ) configOverrides := & clientcmd . ConfigOverrides { } kubeConfig := clientcmd . NewNonInteractiveDeferredLoadingClientConfig ( loadingRules , configOverrides ) kubeconfig , _ := kubeConfig . RawConfig ( ) a . StartingKubeConfig = & kubeconfig if len ( a . Server ) == 0 { if defaultContext , defaultContextExists := a . StartingKubeConfig . Contexts [ a . StartingKubeConfig . CurrentContext ] ; defaultContextExists { if cluster , exists := a . StartingKubeConfig . Clusters [ defaultContext . Cluster ] ; exists { a . Server = cluster . Server } } } err := a . Run ( ) if err != nil { return err } return nil }
Login takes of authentication part and returns error if there any
Login takes of authentication part and returns error if there any
// initialize client-go client and read starting kubeconfig file // if server URL is not given as argument, we will look for current context from kubeconfig file