Class KubeConfigUtils
- java.lang.Object
-
- io.fabric8.kubernetes.client.internal.KubeConfigUtils
-
public class KubeConfigUtils extends Object
Helper class for working with the YAML config file thats located in~/.kube/configwhich is updated when you use commands likeosc loginandosc project myproject
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static StringfindExecutable(String command, String pathValue)protected static List<String>getAuthenticatorCommandFromExecConfig(io.fabric8.kubernetes.api.model.ExecConfig exec, File configFile, String systemPathValue)protected static Config.ExecCredentialgetExecCredentialFromExecConfig(io.fabric8.kubernetes.api.model.ExecConfig exec, File configFile)static FilegetFileWithNamedAuthInfo(io.fabric8.kubernetes.api.model.NamedContext namedContext)Returns the file containing the auth info information if it was loaded using KubeConfigUtils#parseConfig.static FilegetFileWithNamedCluster(io.fabric8.kubernetes.api.model.NamedContext namedContext)Returns the file containing the cluster information if it was loaded using KubeConfigUtils#parseConfig.static FilegetFileWithNamedContext(io.fabric8.kubernetes.api.model.NamedContext namedContext)Returns the file containing the context information if it was loaded using KubeConfigUtils#parseConfig.static voidmerge(Config clientConfig, String context, io.fabric8.kubernetes.api.model.Config... kubeconfigs)Merges the providedConfigobjects into the providedConfigobject.static io.fabric8.kubernetes.api.model.ConfigparseConfig(File kubeconfig)static io.fabric8.kubernetes.api.model.ConfigparseConfigFromString(String contents)static voidpersistKubeConfigIntoFile(io.fabric8.kubernetes.api.model.Config kubeconfig, File kubeConfigPath)Persist KUBECONFIG file from the providedConfigobject.
-
-
-
Method Detail
-
parseConfig
public static io.fabric8.kubernetes.api.model.Config parseConfig(File kubeconfig)
-
parseConfigFromString
public static io.fabric8.kubernetes.api.model.Config parseConfigFromString(String contents)
-
persistKubeConfigIntoFile
public static void persistKubeConfigIntoFile(io.fabric8.kubernetes.api.model.Config kubeconfig, File kubeConfigPath) throws IOExceptionPersist KUBECONFIG file from the providedConfigobject.- Parameters:
kubeconfig- modifiedConfigobject.kubeConfigPath- path to KUBECONFIG.- Throws:
IOException- in case of failure while writing to file.
-
getFileWithNamedContext
public static File getFileWithNamedContext(io.fabric8.kubernetes.api.model.NamedContext namedContext)
Returns the file containing the context information if it was loaded using KubeConfigUtils#parseConfig.- Parameters:
namedContext- the context to get the file from.- Returns:
- the file containing the context information if it was loaded using KubeConfigUtils#parseConfig or null.
-
getFileWithNamedCluster
public static File getFileWithNamedCluster(io.fabric8.kubernetes.api.model.NamedContext namedContext)
Returns the file containing the cluster information if it was loaded using KubeConfigUtils#parseConfig.- Parameters:
namedContext- the context to get the file from.- Returns:
- the file containing the cluster information if it was loaded using KubeConfigUtils#parseConfig or null.
-
getFileWithNamedAuthInfo
public static File getFileWithNamedAuthInfo(io.fabric8.kubernetes.api.model.NamedContext namedContext)
Returns the file containing the auth info information if it was loaded using KubeConfigUtils#parseConfig.- Parameters:
namedContext- the context to get the file from.- Returns:
- the file containing the auth info information if it was loaded using KubeConfigUtils#parseConfig or null.
-
merge
public static void merge(Config clientConfig, String context, io.fabric8.kubernetes.api.model.Config... kubeconfigs)
Merges the providedConfigobjects into the providedConfigobject.The following precedence is followed:
- Incomplete Contexts, Clusters, and Users are ignored
- Context argument provided by the user is used if provided and exists
- The first Config object to set a value wins
-
getExecCredentialFromExecConfig
protected static Config.ExecCredential getExecCredentialFromExecConfig(io.fabric8.kubernetes.api.model.ExecConfig exec, File configFile)
-
getAuthenticatorCommandFromExecConfig
protected static List<String> getAuthenticatorCommandFromExecConfig(io.fabric8.kubernetes.api.model.ExecConfig exec, File configFile, String systemPathValue)
-
-