use of io.fabric8.kubernetes.api.model.EnvVar in project fabric8-maven-plugin by fabric8io.
the class EnvVarHandlerTest method envVarHandlerWithoutNameTest.
@Test
public void envVarHandlerWithoutNameTest() {
// Environment Variable without name in Config
EnvVar var1 = new EnvVarBuilder().withName(null).withValue("OK").build();
env.clear();
env.put(null, var1.getValue());
EnvVarHandler envVarHandler = new EnvVarHandler(project);
new Expectations() {
{
externalEnvVarHandler.getExportedEnvironmentVariables(project, env);
ret.put(null, "OK");
result = ret;
}
};
List<EnvVar> envVars = envVarHandler.getEnvironmentVariables(env);
assertNotNull(envVars);
assertEquals(1, envVars.size());
assertTrue(!envVars.contains(var1));
assertEquals("KUBERNETES_NAMESPACE", envVars.get(0).getName());
assertTrue(envVars.contains(var4));
}
use of io.fabric8.kubernetes.api.model.EnvVar in project fabric8-maven-plugin by fabric8io.
the class EnvVarHandlerTest method emptyEnvVarHandlerTest.
@Test
public void emptyEnvVarHandlerTest() {
// Empty Environment Variable in Config
EnvVarHandler envVarHandler = new EnvVarHandler(project);
env.clear();
new Expectations() {
{
externalEnvVarHandler.getExportedEnvironmentVariables(project, env);
ret.putAll(env);
result = ret;
}
};
List<EnvVar> envVars = envVarHandler.getEnvironmentVariables(env);
assertNotNull(envVars);
assertEquals(1, envVars.size());
assertEquals("KUBERNETES_NAMESPACE", envVars.get(0).getName());
assertTrue(envVars.contains(var4));
}
use of io.fabric8.kubernetes.api.model.EnvVar in project fabric8-maven-plugin by fabric8io.
the class EnvVarHandler method convertToEnvVarMap.
// ==============================================================================================
private Map<String, EnvVar> convertToEnvVarMap(Map<String, String> envs) {
Map<String, EnvVar> envMap = new HashMap<>();
for (Map.Entry<String, String> entry : envs.entrySet()) {
String name = entry.getKey();
String value = entry.getValue();
if (name != null) {
EnvVar env = new EnvVarBuilder().withName(name).withValue(value).build();
envMap.put(name, env);
}
}
return envMap;
}
use of io.fabric8.kubernetes.api.model.EnvVar in project halyard by spinnaker.
the class ResourceBuilder method buildContainer.
static Container buildContainer(String name, ServiceSettings settings, List<ConfigSource> configSources, DeploymentEnvironment deploymentEnvironment) {
int port = settings.getPort();
List<EnvVar> envVars = settings.getEnv().entrySet().stream().map(e -> {
EnvVarBuilder envVarBuilder = new EnvVarBuilder();
return envVarBuilder.withName(e.getKey()).withValue(e.getValue()).build();
}).collect(Collectors.toList());
configSources.forEach(c -> {
c.getEnv().entrySet().forEach(envEntry -> {
EnvVarBuilder envVarBuilder = new EnvVarBuilder();
envVars.add(envVarBuilder.withName(envEntry.getKey()).withValue(envEntry.getValue()).build());
});
});
ProbeBuilder probeBuilder = new ProbeBuilder();
if (settings.getHealthEndpoint() != null) {
probeBuilder = probeBuilder.withNewHttpGet().withNewPort(port).withPath(settings.getHealthEndpoint()).endHttpGet();
} else {
probeBuilder = probeBuilder.withNewTcpSocket().withNewPort().withIntVal(port).endPort().endTcpSocket();
}
List<VolumeMount> volumeMounts = configSources.stream().map(c -> {
return new VolumeMountBuilder().withMountPath(c.getMountPath()).withName(c.getId()).build();
}).collect(Collectors.toList());
ContainerBuilder containerBuilder = new ContainerBuilder();
containerBuilder = containerBuilder.withName(name).withImage(settings.getArtifactId()).withPorts(new ContainerPortBuilder().withContainerPort(port).build()).withVolumeMounts(volumeMounts).withEnv(envVars).withReadinessProbe(probeBuilder.build()).withResources(buildResourceRequirements(name, deploymentEnvironment));
return containerBuilder.build();
}
use of io.fabric8.kubernetes.api.model.EnvVar in project kubernetes by ballerinax.
the class DeploymentHandler method populateEnvVar.
private List<EnvVar> populateEnvVar(Map<String, String> envMap) {
List<EnvVar> envVars = new ArrayList<>();
if (envMap == null) {
return envVars;
}
envMap.forEach((k, v) -> {
EnvVar envVar = new EnvVarBuilder().withName(k).withValue(v).build();
envVars.add(envVar);
});
return envVars;
}
Aggregations