| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Required when creating an image with a FROM command, using a private registry.
Removed basic auth parameters from DockerClientConfig. Created first AbstractHttpFeature: HttpBasicAuthenticationFeature.
AbstractDockerClientTest class.
Conflicts: src/main/java/com/github/dockerjava/api/command/BuildImageCmd.java src/main/java/com/github/dockerjava/core/DockerClientImpl.java src/main/java/com/github/dockerjava/core/command/BuildImageCmdImpl.java src/main/java/com/github/dockerjava/jaxrs/BuildImageCmdExec.java src/main/java/com/github/dockerjava/jaxrs/DockerCmdExecFactoryImpl.java
|
@ericfjosne I've pushed a branch 'refact-config' (#226) where I've factored out all JAXRS/ApacheConnector implementation specific parameters from DockerClientConfig. These and any additional ClientResponseFilters can be configured then via DockerCmdExecFactoryImpl directly. Please take a look at it to see if you could implement your use case this way. Any comments are really welcome. Thanks! |
Sorry, something went wrong.
|
Good morning Marcus, Sorry for the long delay. I only had the chance to take a look at your suggestions tonight. For the reminder, my fork added the 3 following features to your project: Basic HTTP authentication on the docker API The ClientResponseFilters only applies after the communication is performed, while I needed something to adapt it beforehand. I tweaked your branch code (refact-config) a bit and managed to get it all working for me. Here is what I changed: In your DockerCmdExecFactoryImpl, i changed the following: private ClientRequestFilter[] clientRequestFilters; // instead of Class<? extends ClientResponseFilter>[] clientResponseFilters @OverRide I then created my custom client request filter, like this: public class MyCustomClientRequestFilter implements ClientRequestFilter{ private String user;
private String pass;
private int connectTimeout;
public MyCustomClientRequestFilter(int connectTimeout, String nginxUser, String nginxPass) {
this.user = nginxUser;
this.pass = nginxPass;
this.connectTimeout = connectTimeout;
}
private String getBasicAuthentication() {
String token = this.user + ":" + this.pass;
try {
return "BASIC " + DatatypeConverter.printBase64Binary(token.getBytes("UTF-8"));
} catch (UnsupportedEncodingException ex) {
throw new IllegalStateException("Cannot encode with UTF-8", ex);
}
}
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
requestContext.setProperty(ClientProperties.CONNECT_TIMEOUT, connectTimeout);
requestContext.setProperty(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.BUFFERED);
requestContext.getHeaders().add("Authorization", getBasicAuthentication());
}
} And this is how I create my DockerClient instance: public static DockerClient getDockerClient(String dockerRemoteApiUrl, String nginxUser, String nginxPass, String registryUser, String registryPass, String registryMail, String registryUrl){ ClientRequestFilter[] filters = new ClientRequestFilter[]{
new MyCustomClientRequestFilter(200, nginxUser, nginxPass),
};
DockerCmdExecFactoryImpl dockerCmdExecFactory = new DockerCmdExecFactoryImpl()
.withDockerClientConfig(config)
.withClientRequestFilters(filters);
return DockerClientBuilder.getInstance(config).withDockerCmdExecFactory(dockerCmdExecFactory).build();
} I am not quite satisfied with the way I created the DockerClient instance. Eventually, your readTimeout, maxTotalConnection and maxPerRouteConnection could also be implemented within a ClientRequestFilter, although it might not be super obvious for integrators. If this is okay for you, I would really love for this to become mainstream in the docker-java project :-) Small detail though: connectTimeout is a quite common parameter for any connectivity implementation. Again, thanks for your time and support. Have a good day, Eric Fjøsne
|
Sorry, something went wrong.
|
Good morning again, FYI, I pushed your refactored “refact-config” branch with my changes to my repository, with the same branch name. Have a good day ! Eric Fjøsne
|
Sorry, something went wrong.
|
Hi Eric, would it be possible to you to pull the latest changes from master into your branch and/or create a fresh PR? Cheers |
Sorry, something went wrong.
|
@ericfjosne I've created a fresh PR #282 Please review if this works for your use cases. Thanks! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
I needed to add BasicAuthentication for the calls to the API.
This pull request allows an optional custom list of AbstractHttpFeatures to be given to the DockerClientBuilder.getInstance method. It also implements the HttpBasicAuthenticationFeature class I needed.
This branch is based on today's (13/05/2015) master branch from the main repo.