use of com.spotify.docker.client.messages.swarm.ConfigBind in project docker-client by spotify.
the class DefaultDockerClientUnitTest method testCreateServiceWithConfig.
@Test
public void testCreateServiceWithConfig() throws Exception {
final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
// build() calls /version to check what format of header to send
enqueueServerApiVersion("1.30");
enqueueServerApiResponse(201, "fixtures/1.30/configCreateResponse.json");
final ConfigSpec configSpec = ConfigSpec.builder().data(Base64.encodeAsString("foobar")).name("foo.yaml").build();
final ConfigCreateResponse configCreateResponse = dockerClient.createConfig(configSpec);
assertThat(configCreateResponse.id(), equalTo("ktnbjxoalbkvbvedmg1urrz8h"));
final ConfigBind configBind = ConfigBind.builder().configName(configSpec.name()).configId(configCreateResponse.id()).file(ConfigFile.builder().gid("1000").uid("1000").mode(600L).name(configSpec.name()).build()).build();
final TaskSpec taskSpec = TaskSpec.builder().containerSpec(ContainerSpec.builder().image("this_image_is_found_in_the_registry").configs(ImmutableList.of(configBind)).build()).build();
final ServiceSpec spec = ServiceSpec.builder().name("test").taskTemplate(taskSpec).build();
enqueueServerApiVersion("1.30");
enqueueServerApiResponse(201, "fixtures/1.30/createServiceResponse.json");
final ServiceCreateResponse response = dockerClient.createService(spec);
assertThat(response.id(), equalTo("ak7w3gjqoa3kuz8xcpnyy0pvl"));
}
Aggregations