const RecommendedConfigPathFlag … const RecommendedConfigPathEnvVar … const RecommendedHomeDir … const RecommendedFileName … const RecommendedSchemaName … var RecommendedConfigDir … var RecommendedHomeFile … var RecommendedSchemaFile … // currentMigrationRules returns a map that holds the history of recommended home directories used in previous versions. // Any future changes to RecommendedHomeFile and related are expected to add a migration rule here, in order to make // sure existing config files are migrated to their new locations properly. func currentMigrationRules() map[string]string { … } type ClientConfigLoader … type KubeconfigGetter … type ClientConfigGetter … var _ … func (g *ClientConfigGetter) Load() (*clientcmdapi.Config, error) { … } func (g *ClientConfigGetter) GetLoadingPrecedence() []string { … } func (g *ClientConfigGetter) GetStartingConfig() (*clientcmdapi.Config, error) { … } func (g *ClientConfigGetter) GetDefaultFilename() string { … } func (g *ClientConfigGetter) IsExplicitFile() bool { … } func (g *ClientConfigGetter) GetExplicitFile() string { … } func (g *ClientConfigGetter) IsDefaultConfig(config *restclient.Config) bool { … } type ClientConfigLoadingRules … type WarningHandler … func (handler WarningHandler) Warn(err error) { … } type MissingConfigError … func (c MissingConfigError) Error() string { … } var _ … // NewDefaultClientConfigLoadingRules returns a ClientConfigLoadingRules object with default fields filled in. You are not required to // use this constructor func NewDefaultClientConfigLoadingRules() *ClientConfigLoadingRules { … } // Load starts by running the MigrationRules and then // takes the loading rules and returns a Config object based on following rules. // // if the ExplicitPath, return the unmerged explicit file // Otherwise, return a merged config based on the Precedence slice // // A missing ExplicitPath file produces an error. Empty filenames or other missing files are ignored. // Read errors or files with non-deserializable content produce errors. // The first file to set a particular map key wins and map key's value is never changed. // BUT, if you set a struct value that is NOT contained inside of map, the value WILL be changed. // This results in some odd looking logic to merge in one direction, merge in the other, and then merge the two. // It also means that if two files specify a "red-user", only values from the first file's red-user are used. Even // non-conflicting entries from the second file's "red-user" are discarded. // Relative paths inside of the .kubeconfig files are resolved against the .kubeconfig file's parent folder // and only absolute file paths are returned. func (rules *ClientConfigLoadingRules) Load() (*clientcmdapi.Config, error) { … } // Migrate uses the MigrationRules map. If a destination file is not present, then the source file is checked. // If the source file is present, then it is copied to the destination file BEFORE any further loading happens. func (rules *ClientConfigLoadingRules) Migrate() error { … } // GetLoadingPrecedence implements ConfigAccess func (rules *ClientConfigLoadingRules) GetLoadingPrecedence() []string { … } // GetStartingConfig implements ConfigAccess func (rules *ClientConfigLoadingRules) GetStartingConfig() (*clientcmdapi.Config, error) { … } // GetDefaultFilename implements ConfigAccess func (rules *ClientConfigLoadingRules) GetDefaultFilename() string { … } // IsExplicitFile implements ConfigAccess func (rules *ClientConfigLoadingRules) IsExplicitFile() bool { … } // GetExplicitFile implements ConfigAccess func (rules *ClientConfigLoadingRules) GetExplicitFile() string { … } // IsDefaultConfig returns true if the provided configuration matches the default func (rules *ClientConfigLoadingRules) IsDefaultConfig(config *restclient.Config) bool { … } // LoadFromFile takes a filename and deserializes the contents into Config object func LoadFromFile(filename string) (*clientcmdapi.Config, error) { … } // Load takes a byte slice and deserializes the contents into Config object. // Encapsulates deserialization without assuming the source is a file. func Load(data []byte) (*clientcmdapi.Config, error) { … } // WriteToFile serializes the config to yaml and writes it out to a file. If not present, it creates the file with the mode 0600. If it is present // it stomps the contents func WriteToFile(config clientcmdapi.Config, filename string) error { … } func lockFile(filename string) error { … } func unlockFile(filename string) error { … } func lockName(filename string) string { … } // Write serializes the config to yaml. // Encapsulates serialization without assuming the destination is a file. func Write(config clientcmdapi.Config) ([]byte, error) { … } func (rules ClientConfigLoadingRules) ResolvePaths() bool { … } // ResolveLocalPaths resolves all relative paths in the config object with respect to the stanza's LocationOfOrigin // this cannot be done directly inside of LoadFromFile because doing so there would make it impossible to load a file without // modification of its contents. func ResolveLocalPaths(config *clientcmdapi.Config) error { … } // RelativizeClusterLocalPaths first absolutizes the paths by calling ResolveLocalPaths. This assumes that any NEW path is already // absolute, but any existing path will be resolved relative to LocationOfOrigin func RelativizeClusterLocalPaths(cluster *clientcmdapi.Cluster) error { … } // RelativizeAuthInfoLocalPaths first absolutizes the paths by calling ResolveLocalPaths. This assumes that any NEW path is already // absolute, but any existing path will be resolved relative to LocationOfOrigin func RelativizeAuthInfoLocalPaths(authInfo *clientcmdapi.AuthInfo) error { … } func RelativizeConfigPaths(config *clientcmdapi.Config, base string) error { … } func ResolveConfigPaths(config *clientcmdapi.Config, base string) error { … } func GetConfigFileReferences(config *clientcmdapi.Config) []*string { … } func GetClusterFileReferences(cluster *clientcmdapi.Cluster) []*string { … } func GetAuthInfoFileReferences(authInfo *clientcmdapi.AuthInfo) []*string { … } // ResolvePaths updates the given refs to be absolute paths, relative to the given base directory func ResolvePaths(refs []*string, base string) error { … } // RelativizePathWithNoBacksteps updates the given refs to be relative paths, relative to the given base directory as long as they do not require backsteps. // Any path requiring a backstep is left as-is as long it is absolute. Any non-absolute path that can't be relativized produces an error func RelativizePathWithNoBacksteps(refs []*string, base string) error { … } func MakeRelative(path, base string) (string, error) { … } // deduplicate removes any duplicated values and returns a new slice, keeping the order unchanged func deduplicate(s []string) []string { … }