use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.
the class KubernetesServerExposerTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
container = new ContainerBuilder().withName("main").build();
Pod pod = new PodBuilder().withNewMetadata().withName("pod").endMetadata().withNewSpec().withContainers(container).endSpec().build();
kubernetesEnvironment = KubernetesEnvironment.builder().setPods(ImmutableMap.of("pod", pod)).build();
PodData podData = new PodData(pod.getSpec(), pod.getMetadata());
this.serverExposer = new KubernetesServerExposer<>(externalServerExposer, secureServerExposer, MACHINE_NAME, podData, container, kubernetesEnvironment);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.
the class KubernetesPluginsToolingApplierTest method throwsExceptionWhenTheNumberOfPodsIsNot1.
@Test(expectedExceptions = InfrastructureException.class, expectedExceptionsMessageRegExp = "Che plugins tooling configuration can be applied to a workspace with one pod only")
public void throwsExceptionWhenTheNumberOfPodsIsNot1() throws Exception {
PodData podData = new PodData(podSpec, meta);
when(internalEnvironment.getPodsData()).thenReturn(of("pod1", podData, "pod2", podData));
applier.apply(runtimeIdentity, internalEnvironment, singletonList(createChePlugin()));
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.
the class PassThroughProxyProvisionerTest method podWithName.
private static PodData podWithName() {
ObjectMeta meta = new ObjectMeta();
meta.setName("a-pod-name");
return new PodData(null, meta);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.
the class EnvVarsTest method shouldProvisionEnvIfContainersDoeNotHaveEnvAtAll.
@Test
public void shouldProvisionEnvIfContainersDoeNotHaveEnvAtAll() throws Exception {
// given
PodData pod = new PodData(new PodBuilder().withNewMetadata().withName("pod").endMetadata().withNewSpec().withInitContainers(new ContainerBuilder().withName("initContainer").build()).withContainers(new ContainerBuilder().withName("container").build()).endSpec().build());
// when
envVars.apply(pod, singletonList(new EnvImpl("TEST_ENV", "anyValue")));
// then
List<EnvVar> initCEnv = pod.getSpec().getInitContainers().get(0).getEnv();
assertEquals(initCEnv.size(), 1);
assertEquals(initCEnv.get(0), new EnvVar("TEST_ENV", "anyValue", null));
List<EnvVar> containerEnv = pod.getSpec().getContainers().get(0).getEnv();
assertEquals(containerEnv.size(), 1);
assertEquals(containerEnv.get(0), new EnvVar("TEST_ENV", "anyValue", null));
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.
the class EnvVarsTest method shouldProvisionEnvIntoK8SListIfContainerAlreadyHasSomeEnvVars.
@Test
public void shouldProvisionEnvIntoK8SListIfContainerAlreadyHasSomeEnvVars() throws Exception {
// given
EnvVar existingInitCEnvVar = new EnvVar("ENV", "value", null);
EnvVar existingCEnvVar = new EnvVar("ENV", null, new EnvVarSource());
PodData pod = new PodData(new PodBuilder().withNewMetadata().withName("pod").endMetadata().withNewSpec().withInitContainers(new ContainerBuilder().withName("initContainer").withEnv(copy(existingInitCEnvVar)).build()).withContainers(new ContainerBuilder().withName("container").withEnv(copy(existingCEnvVar)).build()).endSpec().build());
// when
envVars.apply(pod, singletonList(new EnvImpl("TEST_ENV", "anyValue")));
// then
List<EnvVar> initCEnv = pod.getSpec().getInitContainers().get(0).getEnv();
assertEquals(initCEnv.size(), 2);
assertEquals(initCEnv.get(0), existingInitCEnvVar);
assertEquals(initCEnv.get(1), new EnvVar("TEST_ENV", "anyValue", null));
List<EnvVar> containerEnv = pod.getSpec().getContainers().get(0).getEnv();
assertEquals(containerEnv.size(), 2);
assertEquals(containerEnv.get(0), existingCEnvVar);
assertEquals(containerEnv.get(1), new EnvVar("TEST_ENV", "anyValue", null));
}
Aggregations