Class KubeConfig
- java.lang.Object
-
- com.google.jenkins.plugins.k8sengine.KubeConfig
-
public class KubeConfig extends Object
Encapsulates KubeConfig data, its construction from Cluster data, and its output to Yaml. NOTE(craigatgoogle): This is a temporary stop-gap measure which will be replaced once the GKE API supports a server-side method for this functionality: b/120097899.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
KubeConfig.Builder
Builder forKubeConfig
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static KubeConfig
fromCluster(String projectId, com.google.api.services.container.model.Cluster cluster, String accessToken)
Creates aKubeConfig
from the specifiedCluster
.com.google.common.collect.ImmutableList<Object>
getClusters()
com.google.common.collect.ImmutableList<Object>
getContexts()
String
getCurrentContext()
com.google.common.collect.ImmutableList<Object>
getUsers()
String
toYaml()
Write a Yaml dump of thisKubeConfig
's data to the specifiedWriter
.
-
-
-
Method Detail
-
getContexts
public com.google.common.collect.ImmutableList<Object> getContexts()
- Returns:
- This config's contexts.
-
getClusters
public com.google.common.collect.ImmutableList<Object> getClusters()
- Returns:
- This config's clusters.
-
getUsers
public com.google.common.collect.ImmutableList<Object> getUsers()
- Returns:
- This config's users.
-
getCurrentContext
public String getCurrentContext()
- Returns:
- This config's current context.
-
toYaml
public String toYaml() throws IOException
Write a Yaml dump of thisKubeConfig
's data to the specifiedWriter
. NOTE(craigatgoogle): The logic here is taken directly from the `gcloud containers clutsers get-credentials` command's implementation: link.- Returns:
- A string containing a Yaml dump of this
KubeConfig
. - Throws:
IOException
- If an error was encountered while exporting to Yaml.
-
fromCluster
public static KubeConfig fromCluster(String projectId, com.google.api.services.container.model.Cluster cluster, String accessToken)
Creates aKubeConfig
from the specifiedCluster
.- Parameters:
projectId
- The ID of the project the cluster resides in.cluster
- The cluster data will be drawn from.accessToken
- Access token for GKE API access.- Returns:
- A
KubeConfig
from the specifiedCluster
.
-
-