Search in sources :

Example 6 with FixedRegistryAuthSupplier

use of com.spotify.docker.client.auth.FixedRegistryAuthSupplier in project jackrabbit-oak by apache.

the class AzuriteDockerRule method apply.

@Override
public Statement apply(Statement statement, Description description) {
    try {
        DefaultDockerClient client = DefaultDockerClient.fromEnv().connectTimeoutMillis(5000L).readTimeoutMillis(20000L).registryAuthSupplier(new FixedRegistryAuthSupplier()).build();
        client.ping();
        client.pull(IMAGE);
        client.close();
    } catch (Throwable t) {
        Assume.assumeNoException(t);
    }
    return wrappedRule.apply(statement, description);
}
Also used : DefaultDockerClient(com.spotify.docker.client.DefaultDockerClient) FixedRegistryAuthSupplier(com.spotify.docker.client.auth.FixedRegistryAuthSupplier)

Example 7 with FixedRegistryAuthSupplier

use of com.spotify.docker.client.auth.FixedRegistryAuthSupplier in project docker-client by spotify.

the class PushPullIT method testBuildHubPrivateImageWithAuth.

@Test
public void testBuildHubPrivateImageWithAuth() throws Exception {
    final String dockerDirectory = Resources.getResource("dockerDirectoryNeedsAuth").getPath();
    final RegistryAuth registryAuth = RegistryAuth.builder().username(HUB_AUTH_USERNAME2).password(HUB_AUTH_PASSWORD2).build();
    final DockerClient client = DefaultDockerClient.fromEnv().registryAuthSupplier(new FixedRegistryAuthSupplier(registryAuth, RegistryConfigs.create(singletonMap(HUB_NAME, registryAuth)))).build();
    client.build(Paths.get(dockerDirectory), "testauth", BuildParam.pullNewerImage());
}
Also used : DockerClient(com.spotify.docker.client.DockerClient) DefaultDockerClient(com.spotify.docker.client.DefaultDockerClient) FixedRegistryAuthSupplier(com.spotify.docker.client.auth.FixedRegistryAuthSupplier) RegistryAuth(com.spotify.docker.client.messages.RegistryAuth) Test(org.junit.Test)

Example 8 with FixedRegistryAuthSupplier

use of com.spotify.docker.client.auth.FixedRegistryAuthSupplier in project docker-client by spotify.

the class PushPullIT method testPushHubPublicImageWithAuth.

@Test
public void testPushHubPublicImageWithAuth() throws Exception {
    // Push an image to a public repo on Docker Hub and check it succeeds
    final String dockerDirectory = Resources.getResource("dockerDirectory").getPath();
    final RegistryAuth registryAuth = RegistryAuth.builder().username(HUB_AUTH_USERNAME).password(HUB_AUTH_PASSWORD).build();
    final DockerClient client = DefaultDockerClient.fromEnv().registryAuthSupplier(new FixedRegistryAuthSupplier(registryAuth, RegistryConfigs.create(singletonMap(HUB_NAME, registryAuth)))).build();
    client.build(Paths.get(dockerDirectory), HUB_PUBLIC_IMAGE);
    client.push(HUB_PUBLIC_IMAGE);
}
Also used : DockerClient(com.spotify.docker.client.DockerClient) DefaultDockerClient(com.spotify.docker.client.DefaultDockerClient) FixedRegistryAuthSupplier(com.spotify.docker.client.auth.FixedRegistryAuthSupplier) RegistryAuth(com.spotify.docker.client.messages.RegistryAuth) Test(org.junit.Test)

Example 9 with FixedRegistryAuthSupplier

use of com.spotify.docker.client.auth.FixedRegistryAuthSupplier in project jackrabbit-oak by apache.

the class AzuriteDockerRule method apply.

@Override
public Statement apply(Statement statement, Description description) {
    try {
        DefaultDockerClient client = DefaultDockerClient.fromEnv().connectTimeoutMillis(5000L).readTimeoutMillis(20000L).registryAuthSupplier(new FixedRegistryAuthSupplier()).build();
        client.ping();
        client.pull(IMAGE);
        client.close();
    } catch (Throwable t) {
        Assume.assumeNoException(t);
    }
    return wrappedRule.apply(statement, description);
}
Also used : DefaultDockerClient(com.spotify.docker.client.DefaultDockerClient) FixedRegistryAuthSupplier(com.spotify.docker.client.auth.FixedRegistryAuthSupplier)

Aggregations

FixedRegistryAuthSupplier (com.spotify.docker.client.auth.FixedRegistryAuthSupplier)9 RegistryAuth (com.spotify.docker.client.messages.RegistryAuth)7 DefaultDockerClient (com.spotify.docker.client.DefaultDockerClient)6 DockerClient (com.spotify.docker.client.DockerClient)4 Test (org.junit.Test)4 Long.toHexString (java.lang.Long.toHexString)1 Path (java.nio.file.Path)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)1 Before (org.junit.Before)1