From a29add18a88bbf030f0d3be05c296a9e3d94ef26 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Tue, 20 Mar 2018 10:09:55 +0100 Subject: [PATCH] Load request config when intercepting request --- .../fabric8/kubernetes/client/utils/HttpClientUtils.java | 2 +- .../kubernetes/client/utils/ImpersonatorInterceptor.java | 8 +++++--- .../fabric8/openshift/client/DefaultOpenShiftClient.java | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/HttpClientUtils.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/HttpClientUtils.java index 8a66641e9f2..227ceccf59b 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/HttpClientUtils.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/HttpClientUtils.java @@ -94,7 +94,7 @@ public Response intercept(Chain chain) throws IOException { } return chain.proceed(request); } - }).addInterceptor(new ImpersonatorInterceptor(config.getRequestConfig())); + }).addInterceptor(new ImpersonatorInterceptor(config)); Logger reqLogger = LoggerFactory.getLogger(HttpLoggingInterceptor.class); if (reqLogger.isTraceEnabled()) { diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/ImpersonatorInterceptor.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/ImpersonatorInterceptor.java index b500a1f6095..589d951b406 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/ImpersonatorInterceptor.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/ImpersonatorInterceptor.java @@ -15,6 +15,7 @@ */ package io.fabric8.kubernetes.client.utils; +import io.fabric8.kubernetes.client.Config; import io.fabric8.kubernetes.client.RequestConfig; import okhttp3.Interceptor; import okhttp3.Request; @@ -26,14 +27,15 @@ import static io.fabric8.kubernetes.client.utils.Utils.isNotNullOrEmpty; public class ImpersonatorInterceptor implements Interceptor { - private final RequestConfig requestConfig; - public ImpersonatorInterceptor(RequestConfig requestConfig) { - this.requestConfig = requestConfig; + private final Config config; + public ImpersonatorInterceptor(Config config) { + this.config = config; } @Override public Response intercept(Chain chain) throws IOException { Request request = chain.request(); + RequestConfig requestConfig = config.getRequestConfig(); if (isNotNullOrEmpty(requestConfig.getImpersonateUsername())) { Request.Builder requestBuilder = chain.request().newBuilder(); diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/DefaultOpenShiftClient.java b/openshift-client/src/main/java/io/fabric8/openshift/client/DefaultOpenShiftClient.java index 8a3307b737f..89e9c8afb6e 100644 --- a/openshift-client/src/main/java/io/fabric8/openshift/client/DefaultOpenShiftClient.java +++ b/openshift-client/src/main/java/io/fabric8/openshift/client/DefaultOpenShiftClient.java @@ -147,7 +147,7 @@ private OkHttpClient clientWithOpenShiftOAuthInterceptor(OkHttpClient httpClient OkHttpClient.Builder builder = httpClient.newBuilder(); builder.interceptors().clear(); return builder.addInterceptor(new OpenShiftOAuthInterceptor(httpClient, OpenShiftConfig.wrap(getConfiguration()))) - .addInterceptor(new ImpersonatorInterceptor(getConfiguration().getRequestConfig())) + .addInterceptor(new ImpersonatorInterceptor(getConfiguration())) .build(); }