Search in sources :

Example 31 with CheContainer

use of org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer in project devspaces-images by redhat-developer.

the class KubernetesPluginsToolingValidator method validatePluginNames.

public void validatePluginNames(List<? extends ChePlugin> plugins) throws ValidationException {
    for (ChePlugin plugin : plugins) {
        if (plugin.getName() != null) {
            final String formattedPluginName = plugin.getName().toLowerCase();
            checkValid(formattedPluginName, "Plugin name `%s` contains unacceptable symbols and cannot be used as part of container naming.");
        }
        for (CheContainer container : plugin.getContainers()) {
            if (container.getName() != null) {
                final String formattedContainerName = container.getName().toLowerCase();
                checkValid(formattedContainerName, "Container name `%s` contains unacceptable symbols and cannot be used as part of container naming.");
            }
        }
    }
}
Also used : CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer) ChePlugin(org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin)

Example 32 with CheContainer

use of org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer in project devspaces-images by redhat-developer.

the class KubernetesPluginsToolingApplierTest method createContainer.

private CheContainer createContainer(List<String> command, List<String> args) {
    CheContainer container = createContainer();
    container.setCommand(command);
    container.setArgs(args);
    return container;
}
Also used : CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer)

Example 33 with CheContainer

use of org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer in project devspaces-images by redhat-developer.

the class KubernetesPluginsToolingApplierTest method addToolingInitContainerWithCommand.

@Test
public void addToolingInitContainerWithCommand() throws InfrastructureException {
    List<String> command = Arrays.asList("cp", "-rf", "test-file", "/some-volume/test");
    lenient().when(podSpec.getInitContainers()).thenReturn(new ArrayList<>());
    ChePlugin chePlugin = createChePlugin();
    List<CheContainer> initContainers = singletonList(createContainer(command, null));
    chePlugin.setInitContainers(initContainers);
    applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
    verifyPodAndInitContainersNumber(1);
    Container toolingInitContainer = getOnlyOneInitContainerFromPod(internalEnvironment);
    verifyContainer(toolingInitContainer);
    assertEquals(toolingInitContainer.getCommand(), command);
}
Also used : CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer) Container(io.fabric8.kubernetes.api.model.Container) CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer) ChePlugin(org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin) Test(org.testng.annotations.Test)

Example 34 with CheContainer

use of org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer in project devspaces-images by redhat-developer.

the class KubernetesPluginsToolingApplierTest method addToolingContainerWithArgs.

@Test
public void addToolingContainerWithArgs() throws InfrastructureException {
    List<String> args = Arrays.asList("tail", "-f", "/dev/null");
    lenient().when(podSpec.getContainers()).thenReturn(new ArrayList<>());
    ChePlugin chePlugin = createChePlugin();
    List<CheContainer> containers = singletonList(createContainer(null, args));
    chePlugin.setContainers(containers);
    applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
    verifyPodAndContainersNumber(1);
    Container toolingContainer = getOneAndOnlyNonUserContainer(internalEnvironment);
    verifyContainer(toolingContainer);
    assertEquals(toolingContainer.getArgs(), args);
}
Also used : CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer) Container(io.fabric8.kubernetes.api.model.Container) CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer) ChePlugin(org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin) Test(org.testng.annotations.Test)

Example 35 with CheContainer

use of org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer in project devspaces-images by redhat-developer.

the class KubernetesPluginsToolingApplierTest method createContainer.

private CheContainer createContainer(String name, Command... commands) {
    CheContainer cheContainer = new CheContainer();
    cheContainer.setImage(TEST_IMAGE);
    cheContainer.setName(name);
    cheContainer.setEnv(singletonList(new EnvVar().name(ENV_VAR).value(ENV_VAR_VALUE)));
    cheContainer.setVolumes(singletonList(new Volume().name(VOLUME_NAME).mountPath(VOLUME_MOUNT_PATH)));
    cheContainer.setCommands(Arrays.asList(commands));
    return cheContainer;
}
Also used : CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer) Volume(org.eclipse.che.api.workspace.server.wsplugins.model.Volume) EnvVar(org.eclipse.che.api.workspace.server.wsplugins.model.EnvVar)

Aggregations

CheContainer (org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer)38 Container (io.fabric8.kubernetes.api.model.Container)28 ChePlugin (org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin)26 Test (org.testng.annotations.Test)22 PodData (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData)10 ComponentImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl)8 InternalMachineConfig (org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig)6 ChePluginEndpoint (org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint)6 Beta (com.google.common.annotations.Beta)4 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)4 Sets (com.google.common.collect.Sets)4 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)4 Pod (io.fabric8.kubernetes.api.model.Pod)4 PodBuilder (io.fabric8.kubernetes.api.model.PodBuilder)4 Service (io.fabric8.kubernetes.api.model.Service)4 String.format (java.lang.String.format)4 Collection (java.util.Collection)4 Collections.emptyList (java.util.Collections.emptyList)4 List (java.util.List)4 Map (java.util.Map)4