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 static io.fabric8.kubernetes.api.model.ClustergetCluster(io.fabric8.kubernetes.api.model.Config config, io.fabric8.kubernetes.api.model.Context context)Returns the currentClusterfor the current contextstatic io.fabric8.kubernetes.api.model.NamedContextgetCurrentContext(io.fabric8.kubernetes.api.model.Config config)Returns the current context in the given configstatic intgetNamedUserIndexFromConfig(io.fabric8.kubernetes.api.model.Config config, String userName)Get User index from Config objectstatic io.fabric8.kubernetes.api.model.AuthInfogetUserAuthInfo(io.fabric8.kubernetes.api.model.Config config, io.fabric8.kubernetes.api.model.Context context)Returns the currentAuthInfofor the current context and userstatic StringgetUserToken(io.fabric8.kubernetes.api.model.Config config, io.fabric8.kubernetes.api.model.Context context)Returns the current user token for the config and current contextstatic io.fabric8.kubernetes.api.model.ConfigparseConfig(File file)static io.fabric8.kubernetes.api.model.ConfigparseConfigFromString(String contents)static voidpersistKubeConfigIntoFile(io.fabric8.kubernetes.api.model.Config kubeConfig, String kubeConfigPath)Modify KUBECONFIG file
-
-
-
Method Detail
-
parseConfig
public static io.fabric8.kubernetes.api.model.Config parseConfig(File file) throws IOException
- Throws:
IOException
-
parseConfigFromString
public static io.fabric8.kubernetes.api.model.Config parseConfigFromString(String contents) throws IOException
- Throws:
IOException
-
getCurrentContext
public static io.fabric8.kubernetes.api.model.NamedContext getCurrentContext(io.fabric8.kubernetes.api.model.Config config)
Returns the current context in the given config- Parameters:
config- Config object- Returns:
- returns context in config if found, otherwise null
-
getUserToken
public static String getUserToken(io.fabric8.kubernetes.api.model.Config config, io.fabric8.kubernetes.api.model.Context context)
Returns the current user token for the config and current context- Parameters:
config- Config objectcontext- Context object- Returns:
- returns current user based upon provided parameters.
-
getUserAuthInfo
public static io.fabric8.kubernetes.api.model.AuthInfo getUserAuthInfo(io.fabric8.kubernetes.api.model.Config config, io.fabric8.kubernetes.api.model.Context context)Returns the currentAuthInfofor the current context and user- Parameters:
config- Config objectcontext- Context object- Returns:
AuthInfofor current context
-
getCluster
public static io.fabric8.kubernetes.api.model.Cluster getCluster(io.fabric8.kubernetes.api.model.Config config, io.fabric8.kubernetes.api.model.Context context)Returns the currentClusterfor the current context- Parameters:
config-Configconfig objectcontext-Contextcontext object- Returns:
- current
Clusterfor current context
-
getNamedUserIndexFromConfig
public static int getNamedUserIndexFromConfig(io.fabric8.kubernetes.api.model.Config config, String userName)Get User index from Config object- Parameters:
config-ConfigKube ConfiguserName- username inside Config- Returns:
- index of user in users array
-
persistKubeConfigIntoFile
public static void persistKubeConfigIntoFile(io.fabric8.kubernetes.api.model.Config kubeConfig, String kubeConfigPath) throws IOExceptionModify KUBECONFIG file- Parameters:
kubeConfig- modifiedConfigobjectkubeConfigPath- path to KUBECONFIG- Throws:
IOException- in case of failure while writing to file
-
-