use of org.eclipse.che.api.core.model.workspace.config.Command.MACHINE_NAME_ATTRIBUTE in project devspaces-images by redhat-developer.
the class DockerimageComponentToWorkspaceApplier method apply.
/**
* Applies changes on workspace config according to the specified dockerimage component.
*
* <p>Dockerimage component is provisioned as Deployment in Kubernetes recipe.<br>
* Generated deployment contains container with environment variables, memory limit, docker image,
* arguments and commands specified in component.<br>
* Also, environment is provisioned with machine config with volumes and servers specified, then
* Kubernetes infra will created needed PVC, Services, Ingresses, Routes according to specified
* configuration.
*
* @param workspaceConfig workspace config on which changes should be applied
* @param dockerimageComponent dockerimage component that should be applied
* @param contentProvider optional content provider that may be used for external component
* resource fetching
* @throws DevfileException if specified workspace config already has default environment where
* dockerimage component should be stored
* @throws IllegalArgumentException if specified workspace config or plugin component is null
* @throws IllegalArgumentException if specified component has type different from dockerimage
*/
@Override
public void apply(WorkspaceConfigImpl workspaceConfig, ComponentImpl dockerimageComponent, FileContentProvider contentProvider) throws DevfileException {
checkArgument(workspaceConfig != null, "Workspace config must not be null");
checkArgument(dockerimageComponent != null, "Component must not be null");
checkArgument(DOCKERIMAGE_COMPONENT_TYPE.equals(dockerimageComponent.getType()), format("Plugin must have `%s` type", DOCKERIMAGE_COMPONENT_TYPE));
String componentAlias = dockerimageComponent.getAlias();
String machineName = componentAlias == null ? toMachineName(dockerimageComponent.getImage()) : componentAlias;
MachineConfigImpl machineConfig = createMachineConfig(dockerimageComponent, componentAlias);
List<HasMetadata> componentObjects = createComponentObjects(dockerimageComponent, machineName);
k8sEnvProvisioner.provision(workspaceConfig, KubernetesEnvironment.TYPE, componentObjects, ImmutableMap.of(machineName, machineConfig));
workspaceConfig.getCommands().stream().filter(c -> componentAlias != null && componentAlias.equals(c.getAttributes().get(Constants.COMPONENT_ALIAS_COMMAND_ATTRIBUTE))).forEach(c -> c.getAttributes().put(MACHINE_NAME_ATTRIBUTE, machineName));
}
use of org.eclipse.che.api.core.model.workspace.config.Command.MACHINE_NAME_ATTRIBUTE in project che-server by eclipse-che.
the class DockerimageComponentToWorkspaceApplier method apply.
/**
* Applies changes on workspace config according to the specified dockerimage component.
*
* <p>Dockerimage component is provisioned as Deployment in Kubernetes recipe.<br>
* Generated deployment contains container with environment variables, memory limit, docker image,
* arguments and commands specified in component.<br>
* Also, environment is provisioned with machine config with volumes and servers specified, then
* Kubernetes infra will created needed PVC, Services, Ingresses, Routes according to specified
* configuration.
*
* @param workspaceConfig workspace config on which changes should be applied
* @param dockerimageComponent dockerimage component that should be applied
* @param contentProvider optional content provider that may be used for external component
* resource fetching
* @throws DevfileException if specified workspace config already has default environment where
* dockerimage component should be stored
* @throws IllegalArgumentException if specified workspace config or plugin component is null
* @throws IllegalArgumentException if specified component has type different from dockerimage
*/
@Override
public void apply(WorkspaceConfigImpl workspaceConfig, ComponentImpl dockerimageComponent, FileContentProvider contentProvider) throws DevfileException {
checkArgument(workspaceConfig != null, "Workspace config must not be null");
checkArgument(dockerimageComponent != null, "Component must not be null");
checkArgument(DOCKERIMAGE_COMPONENT_TYPE.equals(dockerimageComponent.getType()), format("Plugin must have `%s` type", DOCKERIMAGE_COMPONENT_TYPE));
String componentAlias = dockerimageComponent.getAlias();
String machineName = componentAlias == null ? toMachineName(dockerimageComponent.getImage()) : componentAlias;
MachineConfigImpl machineConfig = createMachineConfig(dockerimageComponent, componentAlias);
List<HasMetadata> componentObjects = createComponentObjects(dockerimageComponent, machineName);
k8sEnvProvisioner.provision(workspaceConfig, KubernetesEnvironment.TYPE, componentObjects, ImmutableMap.of(machineName, machineConfig));
workspaceConfig.getCommands().stream().filter(c -> componentAlias != null && componentAlias.equals(c.getAttributes().get(Constants.COMPONENT_ALIAS_COMMAND_ATTRIBUTE))).forEach(c -> c.getAttributes().put(MACHINE_NAME_ATTRIBUTE, machineName));
}
Aggregations