Skip to content

Commit

Permalink
remove thrown KubernetesClientException
Browse files Browse the repository at this point in the history
  • Loading branch information
arghya88 committed Nov 5, 2020
1 parent ca0a124 commit 189bea4
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@

public class AppsAPIGroupClient extends BaseClient implements AppsAPIGroupDSL {

public AppsAPIGroupClient() throws KubernetesClientException {
public AppsAPIGroupClient() {
super();
}

public AppsAPIGroupClient(OkHttpClient httpClient, final Config config) throws KubernetesClientException {
public AppsAPIGroupClient(OkHttpClient httpClient, final Config config) {
super(httpClient, config);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,19 @@ public class AutoAdaptableKubernetesClient extends DefaultKubernetesClient {

private KubernetesClient delegate;

public AutoAdaptableKubernetesClient() throws KubernetesClientException {
public AutoAdaptableKubernetesClient() {
delegate = adapt(new DefaultKubernetesClient());
}

public AutoAdaptableKubernetesClient(OkHttpClient httpClient, Config config) throws KubernetesClientException {
public AutoAdaptableKubernetesClient(OkHttpClient httpClient, Config config) {
delegate = adapt(new DefaultKubernetesClient(httpClient, config));
}

public AutoAdaptableKubernetesClient(Config config) throws KubernetesClientException {
public AutoAdaptableKubernetesClient(Config config) {
delegate = adapt(new DefaultKubernetesClient(config));
}

public AutoAdaptableKubernetesClient(String masterUrl) throws KubernetesClientException {
public AutoAdaptableKubernetesClient(String masterUrl) {
delegate = adapt(new DefaultKubernetesClient(masterUrl));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ public abstract class BaseClient implements Client, HttpClientAware {
private String namespace;
private Config configuration;

public BaseClient() throws KubernetesClientException {
public BaseClient() {
this(new ConfigBuilder().build());
}

public BaseClient(String masterUrl) throws KubernetesClientException {
public BaseClient(String masterUrl) {
this(new ConfigBuilder().withMasterUrl(masterUrl).build());
}

public BaseClient(final Config config) throws KubernetesClientException {
public BaseClient(final Config config) {
this(HttpClientUtils.createHttpClient(config), config);
}

public BaseClient(final OkHttpClient httpClient, Config config) throws KubernetesClientException {
public BaseClient(final OkHttpClient httpClient, Config config) {
try {
this.httpClient = httpClient;
this.namespace = config.getNamespace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@

public class BatchAPIGroupClient extends BaseClient implements BatchAPIGroupDSL {

public BatchAPIGroupClient() throws KubernetesClientException {
public BatchAPIGroupClient() {
super();
}

public BatchAPIGroupClient(OkHttpClient httpClient, final Config config) throws KubernetesClientException {
public BatchAPIGroupClient(OkHttpClient httpClient, final Config config) {
super(httpClient, config);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@

public class ExtensionsAPIGroupClient extends BaseClient implements ExtensionsAPIGroupDSL {

public ExtensionsAPIGroupClient() throws KubernetesClientException {
public ExtensionsAPIGroupClient() {
super();
}

public ExtensionsAPIGroupClient(OkHttpClient httpClient, final Config config) throws KubernetesClientException {
public ExtensionsAPIGroupClient(OkHttpClient httpClient, final Config config) {
super(httpClient, config);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
import okhttp3.OkHttpClient;

public class MetricAPIGroupClient extends BaseClient implements MetricAPIGroupDSL {
public MetricAPIGroupClient() throws KubernetesClientException {
public MetricAPIGroupClient() {
super();
}

public MetricAPIGroupClient(OkHttpClient httpClient, final Config config) throws KubernetesClientException {
public MetricAPIGroupClient(OkHttpClient httpClient, final Config config) {
super(httpClient, config);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@

public class NetworkAPIGroupClient extends BaseClient implements NetworkAPIGroupDSL {

public NetworkAPIGroupClient() throws KubernetesClientException {
public NetworkAPIGroupClient() {
super();
}

public NetworkAPIGroupClient(OkHttpClient httpClient, final Config config) throws KubernetesClientException {
public NetworkAPIGroupClient(OkHttpClient httpClient, final Config config) {
super(httpClient, config);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@

public class RbacAPIGroupClient extends BaseClient implements RbacAPIGroupDSL {

public RbacAPIGroupClient() throws KubernetesClientException {
public RbacAPIGroupClient() {
super();
}

public RbacAPIGroupClient(OkHttpClient httpClient, final Config config) throws KubernetesClientException {
public RbacAPIGroupClient(OkHttpClient httpClient, final Config config) {
super(httpClient, config);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import okhttp3.OkHttpClient;

public class SchedulingAPIGroupClient extends BaseClient implements SchedulingAPIGroupDSL {
public SchedulingAPIGroupClient(OkHttpClient httpClient, final Config config) throws KubernetesClientException {
public SchedulingAPIGroupClient(OkHttpClient httpClient, final Config config) {
super(httpClient, config);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import okhttp3.OkHttpClient;

public class SettingsAPIGroupClient extends BaseClient implements SettingsAPIGroupDSL {
public SettingsAPIGroupClient(OkHttpClient httpClient, final Config config) throws KubernetesClientException {
public SettingsAPIGroupClient(OkHttpClient httpClient, final Config config) {
super(httpClient, config);
}
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@

public class StorageAPIGroupClient extends BaseClient implements StorageAPIGroupDSL {

public StorageAPIGroupClient() throws KubernetesClientException {
public StorageAPIGroupClient() {
super();
}

public StorageAPIGroupClient(OkHttpClient httpClient, final Config config) throws KubernetesClientException {
public StorageAPIGroupClient(OkHttpClient httpClient, final Config config) {
super(httpClient, config);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package io.fabric8.kubernetes.client.dsl.base;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -243,10 +242,9 @@ protected void handleDelete(URL requestUrl, long gracePeriodSeconds, DeletionPro
* @return returns de-serialized version of apiserver response in form of type provided
* @throws ExecutionException Execution Exception
* @throws InterruptedException Interrupted Exception
* @throws KubernetesClientException KubernetesClientException
* @throws IOException IOException
*/
protected <T, I> T handleCreate(I resource, Class<T> outputType) throws ExecutionException, InterruptedException, KubernetesClientException, IOException {
protected <T, I> T handleCreate(I resource, Class<T> outputType) throws ExecutionException, InterruptedException, IOException {
RequestBody body = RequestBody.create(JSON, JSON_MAPPER.writeValueAsString(resource));
Request.Builder requestBuilder = new Request.Builder().post(body).url(getNamespacedUrl(checkNamespace(resource)));
return handleResponse(requestBuilder, outputType, Collections.<String, String>emptyMap());
Expand All @@ -263,10 +261,9 @@ protected <T, I> T handleCreate(I resource, Class<T> outputType) throws Executio
* @return returns de-serialized version of api server response
* @throws ExecutionException Execution Exception
* @throws InterruptedException Interrupted Exception
* @throws KubernetesClientException KubernetesClientException
* @throws IOException IOException
*/
protected <T> T handleReplace(T updated, Class<T> type) throws ExecutionException, InterruptedException, KubernetesClientException, IOException {
protected <T> T handleReplace(T updated, Class<T> type) throws ExecutionException, InterruptedException, IOException {
return handleReplace(updated, type, Collections.<String, String>emptyMap());
}

Expand All @@ -281,10 +278,9 @@ protected <T> T handleReplace(T updated, Class<T> type) throws ExecutionExceptio
* @return returns de-serialized version of api server response.
* @throws ExecutionException Execution Exception
* @throws InterruptedException Interrupted Exception
* @throws KubernetesClientException KubernetesClientException
* @throws IOException IOException
*/
protected <T> T handleReplace(T updated, Class<T> type, Map<String, String> parameters) throws ExecutionException, InterruptedException, KubernetesClientException, IOException {
protected <T> T handleReplace(T updated, Class<T> type, Map<String, String> parameters) throws ExecutionException, InterruptedException, IOException {
RequestBody body = RequestBody.create(JSON, JSON_MAPPER.writeValueAsString(updated));
Request.Builder requestBuilder = new Request.Builder().put(body).url(getResourceUrl(checkNamespace(updated), checkName(updated)));
return handleResponse(requestBuilder, type, parameters);
Expand All @@ -307,10 +303,9 @@ protected <T> T handleStatusUpdate(T updated, Class<T> type) throws ExecutionExc
* @return returns de-serialized version of api server response
* @throws ExecutionException Execution Exception
* @throws InterruptedException Interrupted Exception
* @throws KubernetesClientException KubernetesClientException
* @throws IOException IOException
*/
protected <T> T handlePatch(T current, T updated, Class<T> type) throws ExecutionException, InterruptedException, KubernetesClientException, IOException {
protected <T> T handlePatch(T current, T updated, Class<T> type) throws ExecutionException, InterruptedException, IOException {
JsonNode diff = JsonDiff.asJson(patchMapper().valueToTree(current), patchMapper().valueToTree(updated));
RequestBody body = RequestBody.create(JSON_PATCH, JSON_MAPPER.writeValueAsString(diff));
Request.Builder requestBuilder = new Request.Builder().patch(body).url(getResourceUrl(checkNamespace(updated), checkName(updated)));
Expand All @@ -328,7 +323,6 @@ protected <T> T handlePatch(T current, T updated, Class<T> type) throws Executio
* @return returns de-serialized version of api server response
* @throws ExecutionException Execution Exception
* @throws InterruptedException Interrupted Exception
* @throws KubernetesClientException KubernetesClientException
* @throws IOException IOException
*/
protected <T> T handlePatch(T current, Map<String, Object> patchForUpdate, Class<T> type) throws ExecutionException, InterruptedException, IOException {
Expand All @@ -345,12 +339,9 @@ protected <T> T handlePatch(T current, Map<String, Object> patchForUpdate, Class
* @return updated Scale object
* @throws ExecutionException in case of any execution exception
* @throws InterruptedException in case thread is interrupted
* @throws KubernetesClientException in case error from Kubernetes API
* @throws MalformedURLException in case URL formed in invalid
* @throws JsonProcessingException in case Json processing fails
* @throws IOException in some other I/O problem
*/
protected Scale handleScale(String resourceUrl, Scale scale) throws ExecutionException, InterruptedException, KubernetesClientException, MalformedURLException, JsonProcessingException, IOException {
protected Scale handleScale(String resourceUrl, Scale scale) throws ExecutionException, InterruptedException, IOException {
Request.Builder requestBuilder;
if (scale != null) {
RequestBody body = RequestBody.create(JSON, JSON_MAPPER.writeValueAsString(scale));
Expand All @@ -369,12 +360,9 @@ protected Scale handleScale(String resourceUrl, Scale scale) throws ExecutionExc
* @return Status
* @throws ExecutionException in case of any execution exception
* @throws InterruptedException in case thread is interrupted
* @throws KubernetesClientException in case error from Kubernetes API
* @throws MalformedURLException in case URL formed in invalid
* @throws JsonProcessingException in case Json processing fails
* @throws IOException in some other I/O problem
*/
protected Status handleDeploymentRollback(String resourceUrl, DeploymentRollback deploymentRollback) throws ExecutionException, InterruptedException, KubernetesClientException, MalformedURLException, JsonProcessingException, IOException {
protected Status handleDeploymentRollback(String resourceUrl, DeploymentRollback deploymentRollback) throws ExecutionException, InterruptedException, IOException {
RequestBody body = RequestBody.create(JSON, JSON_MAPPER.writeValueAsString(deploymentRollback));
Request.Builder requestBuilder = new Request.Builder().post(body).url(resourceUrl + "/rollback");
return handleResponse(requestBuilder, Status.class);
Expand All @@ -390,10 +378,9 @@ protected Status handleDeploymentRollback(String resourceUrl, DeploymentRollback
* @return returns a deserialized object as api server response of provided type.
* @throws ExecutionException Execution Exception
* @throws InterruptedException Interrupted Exception
* @throws KubernetesClientException KubernetesClientException
* @throws IOException IOException
*/
protected <T> T handleGet(URL resourceUrl, Class<T> type) throws ExecutionException, InterruptedException, KubernetesClientException, IOException {
protected <T> T handleGet(URL resourceUrl, Class<T> type) throws ExecutionException, InterruptedException, IOException {
return handleGet(resourceUrl, type, Collections.<String, String>emptyMap());
}

Expand All @@ -408,10 +395,9 @@ protected <T> T handleGet(URL resourceUrl, Class<T> type) throws ExecutionExcept
* @return Returns a deserialized object as api server response of provided type.
* @throws ExecutionException Execution Exception
* @throws InterruptedException Interrupted Exception
* @throws KubernetesClientException KubernetesClientException
* @throws IOException IOException
*/
protected <T> T handleGet(URL resourceUrl, Class<T> type, Map<String, String> parameters) throws ExecutionException, InterruptedException, KubernetesClientException, IOException {
protected <T> T handleGet(URL resourceUrl, Class<T> type, Map<String, String> parameters) throws ExecutionException, InterruptedException, IOException {
Request.Builder requestBuilder = new Request.Builder().get().url(resourceUrl);
return handleResponse(requestBuilder, type, parameters);
}
Expand All @@ -426,10 +412,9 @@ protected <T> T handleGet(URL resourceUrl, Class<T> type, Map<String, String> pa
* @return Returns a de-serialized object as api server response of provided type.
* @throws ExecutionException Execution Exception
* @throws InterruptedException Interrupted Exception
* @throws KubernetesClientException KubernetesClientException
* @throws IOException IOException
*/
protected <T> T handleResponse(Request.Builder requestBuilder, Class<T> type) throws ExecutionException, InterruptedException, KubernetesClientException, IOException {
protected <T> T handleResponse(Request.Builder requestBuilder, Class<T> type) throws ExecutionException, InterruptedException, IOException {
return handleResponse(requestBuilder, type, Collections.<String, String>emptyMap());
}

Expand All @@ -444,10 +429,9 @@ protected <T> T handleResponse(Request.Builder requestBuilder, Class<T> type) th
* @return Returns a de-serialized object as api server response of provided type.
* @throws ExecutionException Execution Exception
* @throws InterruptedException Interrupted Exception
* @throws KubernetesClientException KubernetesClientException
* @throws IOException IOException
*/
protected <T> T handleResponse(Request.Builder requestBuilder, Class<T> type, Map<String, String> parameters) throws ExecutionException, InterruptedException, KubernetesClientException, IOException {
protected <T> T handleResponse(Request.Builder requestBuilder, Class<T> type, Map<String, String> parameters) throws ExecutionException, InterruptedException, IOException {
return handleResponse(client, requestBuilder, type, parameters);
}

Expand All @@ -462,10 +446,9 @@ protected <T> T handleResponse(Request.Builder requestBuilder, Class<T> type, Ma
* @return Returns a de-serialized object as api server response of provided type.
* @throws ExecutionException Execution Exception
* @throws InterruptedException Interrupted Exception
* @throws KubernetesClientException KubernetesClientException
* @throws IOException IOException
*/
protected <T> T handleResponse(OkHttpClient client, Request.Builder requestBuilder, Class<T> type) throws ExecutionException, InterruptedException, KubernetesClientException, IOException {
protected <T> T handleResponse(OkHttpClient client, Request.Builder requestBuilder, Class<T> type) throws ExecutionException, InterruptedException, IOException {
return handleResponse(client, requestBuilder, type, Collections.<String, String>emptyMap());
}

Expand All @@ -481,10 +464,9 @@ protected <T> T handleResponse(OkHttpClient client, Request.Builder requestBuild
* @return Returns a de-serialized object as api server response of provided type.
* @throws ExecutionException Execution Exception
* @throws InterruptedException Interrupted Exception
* @throws KubernetesClientException KubernetesClientException
* @throws IOException IOException
*/
protected <T> T handleResponse(OkHttpClient client, Request.Builder requestBuilder, Class<T> type, Map<String, String> parameters) throws ExecutionException, InterruptedException, KubernetesClientException, IOException {
protected <T> T handleResponse(OkHttpClient client, Request.Builder requestBuilder, Class<T> type, Map<String, String> parameters) throws ExecutionException, InterruptedException, IOException {
VersionUsageUtils.log(this.resourceT, this.apiGroupVersion);
Request request = requestBuilder.build();
Response response = client.newCall(request).execute();
Expand Down Expand Up @@ -514,7 +496,6 @@ protected <T> T handleResponse(OkHttpClient client, Request.Builder requestBuild
*
* @param request The {#link Request} object.
* @param response The {@link Response} object.
* @throws KubernetesClientException When the response code is not the expected.
*/
protected void assertResponseCode(Request request, Response response) {
int statusCode = response.code();
Expand Down Expand Up @@ -598,15 +579,15 @@ public static KubernetesClientException requestException(Request request, Except
return new KubernetesClientException(sb.toString(), e);
}

protected static <T> T unmarshal(InputStream is) throws KubernetesClientException {
protected static <T> T unmarshal(InputStream is) {
return Serialization.unmarshal(is);
}

protected static <T> T unmarshal(InputStream is, final Class<T> type) throws KubernetesClientException {
protected static <T> T unmarshal(InputStream is, final Class<T> type) {
return Serialization.unmarshal(is, type);
}

protected static <T> T unmarshal(InputStream is, TypeReference<T> type) throws KubernetesClientException {
protected static <T> T unmarshal(InputStream is, TypeReference<T> type) {
return Serialization.unmarshal(is, type);
}

Expand Down
Loading

0 comments on commit 189bea4

Please sign in to comment.