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


Java Secret类代码示例

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


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

示例1: shouldValidateValidSecretConfiguration

import com.spotify.docker.client.messages.swarm.Secret; //导入依赖的package包/类
@Test
public void shouldValidateValidSecretConfiguration() throws Exception {
    final Version version = mock(Version.class);
    final HashMap<String, String> properties = new HashMap<>();
    final Secret secret = mock(Secret.class);
    properties.put("Image", "alpine");
    properties.put("Secrets", "src=Foo");

    when(version.apiVersion()).thenReturn("1.27");
    when(dockerClient.version()).thenReturn(version);
    when(dockerClient.listSecrets()).thenReturn(asList(secret));
    when(secret.secretSpec()).thenReturn(SecretSpec.builder().name("Foo").build());
    when(secret.id()).thenReturn("service-id");

    ValidationResult validationResult = new DockerSecretValidator(pluginRequest, dockerClientFactory).validate(properties);

    assertFalse(validationResult.hasErrors());
}
 
开发者ID:gocd-contrib,项目名称:docker-swarm-elastic-agents,代码行数:19,代码来源:DockerMountsValidatorTest.java

示例2: shouldBuildSecretBindFromDockerSecretAndUseDefaultsWhenNotProvided

import com.spotify.docker.client.messages.swarm.Secret; //导入依赖的package包/类
@Test
public void shouldBuildSecretBindFromDockerSecretAndUseDefaultsWhenNotProvided() throws Exception {
    final DockerSecrets dockerSecrets = DockerSecrets.fromString("src=Username");
    final Secret secret = mock(Secret.class);

    when(secret.secretSpec()).thenReturn(SecretSpec.builder().name("Username").build());
    when(secret.id()).thenReturn("secret-id");

    final List<SecretBind> secretBinds = dockerSecrets.toSecretBind(asList(secret));

    assertThat(secretBinds, hasSize(1));
    assertThat(secretBinds.get(0).secretName(), is("Username"));
    assertThat(secretBinds.get(0).secretId(), is("secret-id"));

    assertThat(secretBinds.get(0).file().name(), is("Username"));
    assertThat(secretBinds.get(0).file().uid(), is("0"));
    assertThat(secretBinds.get(0).file().gid(), is("0"));
    assertThat(secretBinds.get(0).file().mode(), is(0444L));
}
 
开发者ID:gocd-contrib,项目名称:docker-swarm-elastic-agents,代码行数:20,代码来源:DockerSecretsTest.java

示例3: toSecretBind

import com.spotify.docker.client.messages.swarm.Secret; //导入依赖的package包/类
public List<SecretBind> toSecretBind(List<Secret> secrets) {
    final Map<String, Secret> secretMap = secrets.stream().collect(Collectors.toMap(o -> o.secretSpec().name(), o -> o));
    final List<SecretBind> secretBinds = new ArrayList<>();

    for (DockerSecret dockerSecret : this) {
        final Secret secret = secretMap.get(dockerSecret.src);

        if (secret == null) {
            throw new RuntimeException(format("Secret with name `{0}` does not exist.", dockerSecret.name()));
        }

        LOG.debug(format("Using secret `{0}` with id `{1}`.", dockerSecret.name(), secret.id()));
        final SecretFile secretFile = SecretFile.builder()
                .name(dockerSecret.file())
                .uid(dockerSecret.uid())
                .gid(dockerSecret.gid())
                .mode(dockerSecret.mode())
                .build();

        secretBinds.add(SecretBind.builder()
                .secretId(secret.id())
                .secretName(dockerSecret.name())
                .file(secretFile)
                .build());
    }

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

示例4: shouldBuildSecretBindFromDockerSecret

import com.spotify.docker.client.messages.swarm.Secret; //导入依赖的package包/类
@Test
public void shouldBuildSecretBindFromDockerSecret() throws Exception {
    final DockerSecrets dockerSecrets = DockerSecrets.fromString("src=Username, target=username, uid=uid, gid=gid, mode=0640\nsrc=Password, target=passwd, uid=uid, gid=gid, mode=0640");
    final Secret secretForUsername = mock(Secret.class);
    final Secret secretForPassword = mock(Secret.class);

    when(secretForUsername.secretSpec()).thenReturn(SecretSpec.builder().name("Username").build());
    when(secretForUsername.id()).thenReturn("username-secret-id");

    when(secretForPassword.secretSpec()).thenReturn(SecretSpec.builder().name("Password").build());
    when(secretForPassword.id()).thenReturn("password-secret-id");

    final List<SecretBind> secretBinds = dockerSecrets.toSecretBind(asList(secretForUsername, secretForPassword));

    assertThat(secretBinds, hasSize(2));
    assertThat(secretBinds.get(0).secretName(), is("Username"));
    assertThat(secretBinds.get(0).secretId(), is("username-secret-id"));
    assertThat(secretBinds.get(0).file().name(), is("username"));
    assertThat(secretBinds.get(0).file().uid(), is("uid"));
    assertThat(secretBinds.get(0).file().gid(), is("gid"));
    assertThat(secretBinds.get(0).file().mode(), is(0640L));

    assertThat(secretBinds.get(1).secretName(), is("Password"));
    assertThat(secretBinds.get(1).secretId(), is("password-secret-id"));
    assertThat(secretBinds.get(1).file().name(), is("passwd"));
    assertThat(secretBinds.get(1).file().uid(), is("uid"));
    assertThat(secretBinds.get(1).file().gid(), is("gid"));
    assertThat(secretBinds.get(1).file().mode(), is(0640L));
}
 
开发者ID:gocd-contrib,项目名称:docker-swarm-elastic-agents,代码行数:30,代码来源:DockerSecretsTest.java

示例5: shouldErrorOutWhenSecretDoesNotExist

import com.spotify.docker.client.messages.swarm.Secret; //导入依赖的package包/类
@Test
public void shouldErrorOutWhenSecretDoesNotExist() throws Exception {
    final DockerSecrets dockerSecrets = DockerSecrets.fromString("src=Username\nsrc=Password");
    final Secret secret = mock(Secret.class);

    when(secret.secretSpec()).thenReturn(SecretSpec.builder().name("Username").build());
    when(secret.id()).thenReturn("secret-id");

    thrown.expect(RuntimeException.class);
    thrown.expectMessage("Secret with name `Password` does not exist.");

    dockerSecrets.toSecretBind(asList(secret));
}
 
开发者ID:gocd-contrib,项目名称:docker-swarm-elastic-agents,代码行数:14,代码来源:DockerSecretsTest.java

示例6: listSecrets

import com.spotify.docker.client.messages.swarm.Secret; //导入依赖的package包/类
@Override
public List<Secret> listSecrets() {
    throw new IllegalStateException(DISCONNECTED); 
}
 
开发者ID:amihaiemil,项目名称:comdor,代码行数:5,代码来源:Disconnected.java

示例7: inspectSecret

import com.spotify.docker.client.messages.swarm.Secret; //导入依赖的package包/类
@Override
public Secret inspectSecret(String string) {
    throw new IllegalStateException(DISCONNECTED); 
}
 
开发者ID:amihaiemil,项目名称:comdor,代码行数:5,代码来源:Disconnected.java


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