Class KubectlWrapper
- java.lang.Object
-
- com.google.jenkins.plugins.k8sengine.KubectlWrapper
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
KubectlWrapper.Builder
Builder forKubectlWrapper
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
getObject(String kind, String name)
Using the kubectl CLI tool as the API client for the caller, this method unmarshalls the JSON output of the CLI to a JSON Object.com.google.common.collect.ImmutableList<Object>
getObjectsThatMatchLabels(String kind, Map<String,String> labels)
Using the kubectl CLI tool as the API client for the caller, this method unmarshalls the JSON output of objects matching the supplied labels.String
runKubectlCommand(String command, com.google.common.collect.ImmutableList<String> args)
Runs the specified kubectl command.
-
-
-
Method Detail
-
runKubectlCommand
public String runKubectlCommand(String command, com.google.common.collect.ImmutableList<String> args) throws IOException, InterruptedException
Runs the specified kubectl command.- Parameters:
command
- The kubectl command to be run.args
- Arguments for the command.- Returns:
- result From kubectl command.
- Throws:
IOException
- If an error occurred while executing the command.InterruptedException
- If an error occured while executing the command.
-
getObject
public Object getObject(String kind, String name) throws IOException, InterruptedException
Using the kubectl CLI tool as the API client for the caller, this method unmarshalls the JSON output of the CLI to a JSON Object.- Parameters:
kind
- The kind of Kubernetes Object.name
- The name of the Kubernetes Object.- Returns:
- The JSON object unmarshalled from the kubectl get command's output.
- Throws:
IOException
- If an error occurred while executing the command.InterruptedException
- If an error occurred while executing the command.
-
getObjectsThatMatchLabels
public com.google.common.collect.ImmutableList<Object> getObjectsThatMatchLabels(String kind, Map<String,String> labels) throws IOException, InterruptedException, com.jayway.jsonpath.InvalidJsonException
Using the kubectl CLI tool as the API client for the caller, this method unmarshalls the JSON output of objects matching the supplied labels.- Parameters:
kind
- The kind of Kubernetes Object.labels
- The key-value labels set represented as a map.- Returns:
- A list of JSON Objects unmarshalled from the kubectl get command's output.
- Throws:
IOException
- If an error occurred while executing the command.InterruptedException
- If an error occurred while executing the command.com.jayway.jsonpath.InvalidJsonException
- If an error occurred parsing the JSON return value.
-
-