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/config
which is updated when you use commands likeosc login
andosc project myproject
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static String
findExecutable(String command, String pathValue)
protected static List<String>
getAuthenticatorCommandFromExecConfig(io.fabric8.kubernetes.api.model.ExecConfig exec, File configFile, String systemPathValue)
protected static Config.ExecCredential
getExecCredentialFromExecConfig(io.fabric8.kubernetes.api.model.ExecConfig exec, File configFile)
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.static File
getFileWithNamedCluster(io.fabric8.kubernetes.api.model.NamedContext namedContext)
Returns the file containing the cluster information if it was loaded using KubeConfigUtils#parseConfig.static File
getFileWithNamedContext(io.fabric8.kubernetes.api.model.NamedContext namedContext)
Returns the file containing the context information if it was loaded using KubeConfigUtils#parseConfig.static void
merge(Config clientConfig, String context, io.fabric8.kubernetes.api.model.Config... kubeconfigs)
Merges the providedConfig
objects into the providedConfig
object.static io.fabric8.kubernetes.api.model.Config
parseConfig(File kubeconfig)
static io.fabric8.kubernetes.api.model.Config
parseConfigFromString(String contents)
static void
persistKubeConfigIntoFile(io.fabric8.kubernetes.api.model.Config kubeconfig, File kubeConfigPath)
Persist KUBECONFIG file from the providedConfig
object.
-
-
-
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 IOException
Persist KUBECONFIG file from the providedConfig
object.- Parameters:
kubeconfig
- modifiedConfig
object.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 providedConfig
objects into the providedConfig
object.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)
-
-