Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load request config when intercepting request #1037

Merged
merged 1 commit into from
Mar 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down