当前位置: 首页>>代码示例>>Java>>正文


Java Mount类代码示例

本文整理汇总了Java中com.spotify.docker.client.messages.mount.Mount的典型用法代码示例。如果您正苦于以下问题:Java Mount类的具体用法?Java Mount怎么用?Java Mount使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Mount类属于com.spotify.docker.client.messages.mount包,在下文中一共展示了Mount类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldBuildMountFromDockerMount

import com.spotify.docker.client.messages.mount.Mount; //导入依赖的package包/类
@Test
public void shouldBuildMountFromDockerMount() throws Exception {
    final DockerMounts dockerMounts = DockerMounts.fromString("source=namedVolume, target=/path/in/container\ntype=bind, src=/path/in/host, target=/path/in/container2, readonly");
    final Volume volume = mock(Volume.class);

    when(volume.name()).thenReturn("namedVolume");

    final List<Mount> mounts = dockerMounts.toMount(asList(volume));

    assertThat(mounts, hasSize(2));
    assertThat(mounts.get(0).type(), is("volume"));
    assertThat(mounts.get(0).source(), is("namedVolume"));
    assertThat(mounts.get(0).target(), is("/path/in/container"));
    assertThat(mounts.get(0).readOnly(), is(false));

    assertThat(mounts.get(1).type(), is("bind"));
    assertThat(mounts.get(1).source(), is("/path/in/host"));
    assertThat(mounts.get(1).target(), is("/path/in/container2"));
    assertThat(mounts.get(1).readOnly(), is(true));
}
 
开发者ID:gocd-contrib,项目名称:docker-swarm-elastic-agents,代码行数:21,代码来源:DockerMountsTest.java

示例2: shouldStartContainerWithMountedVolume

import com.spotify.docker.client.messages.mount.Mount; //导入依赖的package包/类
@Test
public void shouldStartContainerWithMountedVolume() throws Exception {
    requireDockerApiVersionAtLeast("1.26", "Docker volume mount.");

    final String volumeName = UUID.randomUUID().toString();

    final Volume volume = docker.createVolume(Volume.builder()
            .name(volumeName)
            .driver("local")
            .labels(Collections.singletonMap("cd.go.contrib.elasticagents.dockerswarm.elasticagent.DockerPlugin", ""))
            .build()
    );

    Map<String, String> properties = new HashMap<>();
    properties.put("Image", "alpine:latest");
    properties.put("Mounts", "source=" + volumeName + ", target=/path/in/container");

    DockerService service = DockerService.create(new CreateAgentRequest("key", properties, "prod", new JobIdentifier(100L)), createSettings(), docker);
    services.add(service.name());

    final Service inspectServiceInfo = docker.inspectService(service.name());
    final Mount mount = inspectServiceInfo.spec().taskTemplate().containerSpec().mounts().get(0);

    assertThat(mount.source(), is(volumeName));
    assertThat(mount.type(), is("volume"));
}
 
开发者ID:gocd-contrib,项目名称:docker-swarm-elastic-agents,代码行数:27,代码来源:DockerServiceTest.java

示例3: toMount

import com.spotify.docker.client.messages.mount.Mount; //导入依赖的package包/类
public List<Mount> toMount(List<Volume> volumes) {

        if (Util.isEmpty(volumes)) {
            LOG.debug("No volumes to mount.");
            return Collections.emptyList();
        }

        final Map<String, Volume> volumeMap = volumes.stream().collect(Collectors.toMap(o -> o.name(), o -> o));
        final List<Mount> mounts = new ArrayList<>();

        for (DockerMount dockerMount : this) {
            if (dockerMount.type().equals("volume")) {
                final Volume volume = volumeMap.get(dockerMount.source);

                if (volume == null) {
                    throw new RuntimeException(format("Volume with name `{0}` does not exist.", dockerMount.source()));
                }

                LOG.debug(format("Using volume `{0}`.", dockerMount.source()));
            }

            final Mount mount = Mount.builder()
                    .type(dockerMount.type())
                    .source(dockerMount.source())
                    .target(dockerMount.target())
                    .readOnly(dockerMount.readOnly())
                    .build();

            mounts.add(mount);
        }

        return mounts;
    }
 
开发者ID:gocd-contrib,项目名称:docker-swarm-elastic-agents,代码行数:34,代码来源:DockerMounts.java


注:本文中的com.spotify.docker.client.messages.mount.Mount类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。