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 static io.fabric8.kubernetes.api.model.Cluster
getCluster(io.fabric8.kubernetes.api.model.Config config, io.fabric8.kubernetes.api.model.Context context)
Returns the currentCluster
for the current contextstatic io.fabric8.kubernetes.api.model.NamedContext
getCurrentContext(io.fabric8.kubernetes.api.model.Config config)
Returns the current context in the given configstatic int
getNamedUserIndexFromConfig(io.fabric8.kubernetes.api.model.Config config, String userName)
Get User index from Config objectstatic io.fabric8.kubernetes.api.model.AuthInfo
getUserAuthInfo(io.fabric8.kubernetes.api.model.Config config, io.fabric8.kubernetes.api.model.Context context)
Returns the currentAuthInfo
for the current context and userstatic 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 contextstatic io.fabric8.kubernetes.api.model.Config
parseConfig(File file)
static io.fabric8.kubernetes.api.model.Config
parseConfigFromString(String contents)
static void
persistKubeConfigIntoFile(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 currentAuthInfo
for the current context and user- Parameters:
config
- Config objectcontext
- Context object- Returns:
AuthInfo
for 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 currentCluster
for the current context- Parameters:
config
-Config
config objectcontext
-Context
context object- Returns:
- current
Cluster
for current context
-
getNamedUserIndexFromConfig
public static int getNamedUserIndexFromConfig(io.fabric8.kubernetes.api.model.Config config, String userName)
Get User index from Config object- Parameters:
config
-Config
Kube 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 IOException
Modify KUBECONFIG file- Parameters:
kubeConfig
- modifiedConfig
objectkubeConfigPath
- path to KUBECONFIG- Throws:
IOException
- in case of failure while writing to file
-
-