type ConfigAccess … type PathOptions … var UseModifyConfigLock … func (o *PathOptions) GetEnvVarFiles() []string { … } func (o *PathOptions) GetLoadingPrecedence() []string { … } func (o *PathOptions) GetStartingConfig() (*clientcmdapi.Config, error) { … } func (o *PathOptions) GetDefaultFilename() string { … } func (o *PathOptions) IsExplicitFile() bool { … } func (o *PathOptions) GetExplicitFile() string { … } func NewDefaultPathOptions() *PathOptions { … } // ModifyConfig takes a Config object, iterates through Clusters, AuthInfos, and Contexts, uses the LocationOfOrigin if specified or // uses the default destination file to write the results into. This results in multiple file reads, but it's very easy to follow. // Preferences and CurrentContext should always be set in the default destination file. Since we can't distinguish between empty and missing values // (no nil strings), we're forced have separate handling for them. In the kubeconfig cases, newConfig should have at most one difference, // that means that this code will only write into a single file. If you want to relativizePaths, you must provide a fully qualified path in any // modified element. func ModifyConfig(configAccess ConfigAccess, newConfig clientcmdapi.Config, relativizePaths bool) error { … } func PersisterForUser(configAccess ConfigAccess, user string) restclient.AuthProviderConfigPersister { … } type persister … func (p *persister) Persist(config map[string]string) error { … } // writeCurrentContext takes three possible paths. // If newCurrentContext is the same as the startingConfig's current context, then we exit. // If newCurrentContext has a value, then that value is written into the default destination file. // If newCurrentContext is empty, then we find the config file that is setting the CurrentContext and clear the value from that file func writeCurrentContext(configAccess ConfigAccess, newCurrentContext string) error { … } func writePreferences(configAccess ConfigAccess, newPrefs clientcmdapi.Preferences) error { … } // getConfigFromFile tries to read a kubeconfig file and if it can't, returns an error. One exception, missing files result in empty configs, not an error. func getConfigFromFile(filename string) (*clientcmdapi.Config, error) { … } // GetConfigFromFileOrDie tries to read a kubeconfig file and if it can't, it calls exit. One exception, missing files result in empty configs, not an exit func GetConfigFromFileOrDie(filename string) *clientcmdapi.Config { … }