Search in sources :

Example 51 with ChePlugin

use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project che-server by eclipse-che.

the class KubernetesPluginsToolingApplierTest method applyPluginContainerWithOneVolume.

@Test
public void applyPluginContainerWithOneVolume() throws InfrastructureException {
    lenient().when(podSpec.getContainers()).thenReturn(new ArrayList<>());
    ChePlugin chePlugin = createChePlugin();
    CheContainer cheContainer = chePlugin.getContainers().get(0);
    applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
    verifyPodAndContainersNumber(1);
    Container container = getOneAndOnlyNonUserContainer(internalEnvironment);
    verifyContainer(container);
    verify(chePluginsVolumeApplier).applyVolumes(any(PodData.class), eq(container), eq(cheContainer.getVolumes()), eq(internalEnvironment));
}
Also used : PodData(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData) 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 52 with ChePlugin

use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin 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 53 with ChePlugin

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

the class SidecarToolingProvisioner method provision.

@Traced
@Beta
public void provision(RuntimeIdentity identity, StartSynchronizer startSynchronizer, E environment, Map<String, String> startOptions) throws InfrastructureException {
    Collection<PluginFQN> pluginFQNs = pluginFQNParser.parsePlugins(environment.getAttributes());
    if (pluginFQNs.isEmpty()) {
        return;
    }
    LOG.debug("Started sidecar tooling provisioning workspace '{}'", identity.getWorkspaceId());
    String recipeType = environment.getType();
    ChePluginsApplier pluginsApplier = workspaceNextAppliers.get(recipeType);
    if (pluginsApplier == null) {
        throw new InfrastructureException("Sidecar tooling configuration is not supported with environment type " + recipeType);
    }
    boolean isEphemeral = EphemeralWorkspaceUtility.isEphemeral(environment.getAttributes());
    boolean mergePlugins = shouldMergePlugins(environment.getAttributes());
    List<ChePlugin> chePlugins = pluginBrokerManager.getTooling(identity, startSynchronizer, pluginFQNs, isEphemeral, mergePlugins, startOptions);
    pluginsApplier.apply(identity, environment, chePlugins);
    artifactsBrokerApplier.apply(environment, identity, pluginFQNs, mergePlugins);
    LOG.debug("Finished sidecar tooling provisioning workspace '{}'", identity.getWorkspaceId());
}
Also used : ChePlugin(org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin) PluginFQN(org.eclipse.che.api.workspace.server.wsplugins.model.PluginFQN) ChePluginsApplier(org.eclipse.che.api.workspace.server.wsplugins.ChePluginsApplier) InfrastructureException(org.eclipse.che.api.workspace.server.spi.InfrastructureException) Traced(org.eclipse.che.commons.annotation.Traced) Beta(com.google.common.annotations.Beta)

Example 54 with ChePlugin

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

the class KubernetesPluginsToolingApplierTest method createChePlugin.

private ChePlugin createChePlugin(String id, List<CheContainer> containers, List<CheContainer> initContainers) {
    String[] splittedId = id.split("/");
    ChePlugin plugin = new ChePlugin();
    plugin.setPublisher(splittedId[0]);
    plugin.setName(splittedId[1]);
    plugin.setVersion(splittedId[2]);
    plugin.setId(id);
    plugin.setContainers(containers);
    plugin.setInitContainers(initContainers);
    internalEnvironment.getDevfile().getComponents().add(new ComponentImpl("chePlugin", id));
    return plugin;
}
Also used : ChePlugin(org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin) ComponentImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl)

Example 55 with ChePlugin

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

the class KubernetesPluginsToolingApplierTest method setsSourceAndPluginAttributeForMachineAssociatedWithSidecar.

@Test
public void setsSourceAndPluginAttributeForMachineAssociatedWithSidecar() throws Exception {
    ChePlugin chePlugin = createChePlugin();
    applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
    InternalMachineConfig machineConfig = getOneAndOnlyNonUserMachine(internalEnvironment);
    Map<String, String> attributes = machineConfig.getAttributes();
    assertEquals(attributes.get(CONTAINER_SOURCE_ATTRIBUTE), TOOL_CONTAINER_SOURCE);
    assertEquals(attributes.get(PLUGIN_MACHINE_ATTRIBUTE), chePlugin.getId());
}
Also used : InternalMachineConfig(org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig) ChePlugin(org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin) Test(org.testng.annotations.Test)

Aggregations

ChePlugin (org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin)68 Test (org.testng.annotations.Test)58 CheContainer (org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer)32 Container (io.fabric8.kubernetes.api.model.Container)30 InternalMachineConfig (org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig)20 ChePluginEndpoint (org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint)12 CommandImpl (org.eclipse.che.api.workspace.server.model.impl.CommandImpl)10 ComponentImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl)10 PodData (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData)10 CheContainerPort (org.eclipse.che.api.workspace.server.wsplugins.model.CheContainerPort)8 Beta (com.google.common.annotations.Beta)6 Service (io.fabric8.kubernetes.api.model.Service)6 InfrastructureException (org.eclipse.che.api.workspace.server.spi.InfrastructureException)6 ChePluginsApplier (org.eclipse.che.api.workspace.server.wsplugins.ChePluginsApplier)6 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 String.format (java.lang.String.format)4