Skip to content

Commit

Permalink
making interceptor name constants, removing todo, splitting lines
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Dec 9, 2021
1 parent b2e97d6 commit 12cf9b9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ protected void handleDelete(URL requestUrl, long gracePeriodSeconds, DeletionPro
* @throws IOException IOException
*/
protected <T, I> T handleCreate(I resource, Class<T> outputType) throws InterruptedException, IOException {
HttpRequest.Builder requestBuilder = httpClient.newHttpRequestBuilder().post(JSON, JSON_MAPPER.writeValueAsString(resource)).url(getResourceURLForWriteOperation(getResourceUrl(checkNamespace(resource), null)));
HttpRequest.Builder requestBuilder = httpClient.newHttpRequestBuilder()
.post(JSON, JSON_MAPPER.writeValueAsString(resource))
.url(getResourceURLForWriteOperation(getResourceUrl(checkNamespace(resource), null)));
return handleResponse(requestBuilder, outputType, Collections.<String, String>emptyMap());
}

Expand Down Expand Up @@ -404,7 +406,10 @@ protected <T> T handlePatch(T current, Map<String, Object> patchForUpdate, Class
*/
protected <T> T handlePatch(PatchContext patchContext, T current, String patchForUpdate, Class<T> type, boolean status) throws InterruptedException, IOException {
String bodyContentType = getContentTypeFromPatchContextOrDefault(patchContext);
HttpRequest.Builder requestBuilder = httpClient.newHttpRequestBuilder().patch(bodyContentType, patchForUpdate).url(getResourceURLForPatchOperation(getResourceUrl(checkNamespace(current), checkName(current), status), patchContext));
HttpRequest.Builder requestBuilder = httpClient.newHttpRequestBuilder()
.patch(bodyContentType, patchForUpdate)
.url(getResourceURLForPatchOperation(getResourceUrl(checkNamespace(current), checkName(current), status),
patchContext));
return handleResponse(requestBuilder, type, Collections.emptyMap());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public interface Builder extends BasicBuilder {

Builder uri(String uri);

// TODO: should be uri
Builder url(URL url);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import java.util.regex.Matcher;

public class BackwardsCompatibilityInterceptor implements Interceptor {

public static final String NAME = "BACKWARDS";

private static final int API_GROUP = 1;
private static final int API_VERSION = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ public void before(BasicBuilder builder, HttpHeaders headers) {
}
});
// Impersonator Interceptor
interceptors.put("IMPERSONATOR", new ImpersonatorInterceptor(config));
interceptors.put(ImpersonatorInterceptor.NAME, new ImpersonatorInterceptor(config));
// Token Refresh Interceptor
interceptors.put(TokenRefreshInterceptor.NAME, new TokenRefreshInterceptor(config, factory));
// Backwards Compatibility Interceptor
String shouldDisableBackwardsCompatibilityInterceptor = Utils.getSystemPropertyOrEnvVar(KUBERNETES_BACKWARDS_COMPATIBILITY_INTERCEPTOR_DISABLE, "false");
if (!Boolean.parseBoolean(shouldDisableBackwardsCompatibilityInterceptor)) {
interceptors.put("BACKWARDS", new BackwardsCompatibilityInterceptor());
interceptors.put(BackwardsCompatibilityInterceptor.NAME, new BackwardsCompatibilityInterceptor());
}

return interceptors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import static io.fabric8.kubernetes.client.utils.Utils.isNotNullOrEmpty;

public class ImpersonatorInterceptor implements Interceptor {

public static final String NAME = "IMPERSONATOR";

private final Config config;
public ImpersonatorInterceptor(Config config) {
this.config = config;
Expand Down

0 comments on commit 12cf9b9

Please sign in to comment.