use of io.fabric8.openshift.api.model.User in project strimzi by strimzi.
the class KafkaConnectS2IClusterTest method testGenerateSourceImageStream.
@Test
public void testGenerateSourceImageStream() {
ImageStream is = kc.generateSourceImageStream();
assertEquals(kc.getSourceImageStreamName(), is.getMetadata().getName());
assertEquals(namespace, is.getMetadata().getNamespace());
assertEquals(ResourceUtils.labels(Labels.STRIMZI_CLUSTER_LABEL, cluster, Labels.STRIMZI_TYPE_LABEL, "kafka-connect-s2i", "my-user-label", "cromulent", Labels.STRIMZI_NAME_LABEL, kc.getSourceImageStreamName()), is.getMetadata().getLabels());
assertEquals(false, is.getSpec().getLookupPolicy().getLocal());
assertEquals(1, is.getSpec().getTags().size());
assertEquals(image.substring(image.lastIndexOf(":") + 1), is.getSpec().getTags().get(0).getName());
assertEquals("DockerImage", is.getSpec().getTags().get(0).getFrom().getKind());
assertEquals(image, is.getSpec().getTags().get(0).getFrom().getName());
}
use of io.fabric8.openshift.api.model.User in project strimzi by strimzi.
the class KafkaConnectS2IClusterTest method testGenerateTargetImageStream.
@Test
public void testGenerateTargetImageStream() {
ImageStream is = kc.generateTargetImageStream();
assertEquals(kc.kafkaConnectClusterName(cluster), is.getMetadata().getName());
assertEquals(namespace, is.getMetadata().getNamespace());
assertEquals(ResourceUtils.labels(Labels.STRIMZI_CLUSTER_LABEL, cluster, Labels.STRIMZI_TYPE_LABEL, "kafka-connect-s2i", "my-user-label", "cromulent", Labels.STRIMZI_NAME_LABEL, kc.kafkaConnectClusterName(cluster)), is.getMetadata().getLabels());
assertEquals(true, is.getSpec().getLookupPolicy().getLocal());
}
use of io.fabric8.openshift.api.model.User in project strimzi by strimzi.
the class KafkaConnectS2IClusterTest method testGenerateService.
@Test
public void testGenerateService() {
Service svc = kc.generateService();
assertEquals("ClusterIP", svc.getSpec().getType());
Map<String, String> expectedLabels = ResourceUtils.labels("my-user-label", "cromulent", Labels.STRIMZI_CLUSTER_LABEL, cluster, Labels.STRIMZI_TYPE_LABEL, "kafka-connect-s2i", Labels.STRIMZI_NAME_LABEL, kc.kafkaConnectClusterName(cluster));
assertEquals(expectedLabels, svc.getMetadata().getLabels());
assertEquals(expectedLabels, svc.getSpec().getSelector());
assertEquals(1, svc.getSpec().getPorts().size());
assertEquals(new Integer(KafkaConnectCluster.REST_API_PORT), svc.getSpec().getPorts().get(0).getPort());
assertEquals(KafkaConnectCluster.REST_API_PORT_NAME, svc.getSpec().getPorts().get(0).getName());
assertEquals("TCP", svc.getSpec().getPorts().get(0).getProtocol());
}
use of io.fabric8.openshift.api.model.User in project docker-maven-plugin by fabric8io.
the class RunService method createContainerConfig.
// visible for testing
ContainerCreateConfig createContainerConfig(String imageName, RunImageConfiguration runConfig, PortMapping mappedPorts, GavLabel gavLabel, Properties mavenProps, File baseDir) throws DockerAccessException {
try {
ContainerCreateConfig config = new ContainerCreateConfig(imageName).hostname(runConfig.getHostname()).domainname(runConfig.getDomainname()).user(runConfig.getUser()).workingDir(runConfig.getWorkingDir()).entrypoint(runConfig.getEntrypoint()).exposedPorts(mappedPorts.getContainerPorts()).environment(runConfig.getEnvPropertyFile(), runConfig.getEnv(), mavenProps).labels(mergeLabels(runConfig.getLabels(), gavLabel)).command(runConfig.getCmd()).hostConfig(createContainerHostConfig(runConfig, mappedPorts, baseDir));
RunVolumeConfiguration volumeConfig = runConfig.getVolumeConfiguration();
if (volumeConfig != null) {
resolveRelativeVolumeBindings(baseDir, volumeConfig);
config.binds(volumeConfig.getBind());
}
NetworkConfig networkConfig = runConfig.getNetworkingConfig();
if (networkConfig.isCustomNetwork() && networkConfig.hasAliases()) {
ContainerNetworkingConfig networkingConfig = new ContainerNetworkingConfig().aliases(networkConfig);
config.networkingConfig(networkingConfig);
}
return config;
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(String.format("Failed to create contained configuration for [%s]", imageName), e);
}
}
use of io.fabric8.openshift.api.model.User in project docker-maven-plugin by fabric8io.
the class AuthConfigFactory method readAwsCredentials.
private AuthConfig readAwsCredentials(CloseableHttpClient client, HttpGet request) throws IOException {
try (CloseableHttpResponse response = client.execute(request)) {
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
log.debug("No security credential found, return code was %d", response.getStatusLine().getStatusCode());
// no instance role found
return null;
}
// read instance role
try (Reader r = new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8)) {
JsonObject securityCredentials = new Gson().fromJson(r, JsonObject.class);
String user = securityCredentials.getAsJsonPrimitive("AccessKeyId").getAsString();
String password = securityCredentials.getAsJsonPrimitive("SecretAccessKey").getAsString();
String token = securityCredentials.getAsJsonPrimitive("Token").getAsString();
log.debug("Received temporary access key %s...", user.substring(0, 8));
return new AuthConfig(user, password, "none", token);
}
}
}
Aggregations