Source:
public Tool from(String environmentName, EnvironmentImpl environment) throws WorkspaceExportException { checkArgument(environment != null, "The environment must not be null"); checkArgument(environmentName != null, "The environment must not be null"); checkArgument(environment.getRecipe() != null, "The environment recipe must not be null"); checkArgument( environment.getRecipe().getType().equals("dockerimage"), "The environment recipe must not be null"); RecipeImpl recipe = environment.getRecipe(); Tool dockerimageTool = new Tool(); dockerimageTool.setName(environmentName); dockerimageTool.setId(recipe.getContent()); if (environment.getMachines().isEmpty()) { return dockerimageTool; } if (environment.getMachines().size() > 1) { throw new WorkspaceExportException( "Environment with 'dockerimage' recipe must contains one machine configuration"); } MachineConfigImpl machineConfig = environment.getMachines().values().iterator().next(); for (Entry<String, ServerConfigImpl> serverEntry : machineConfig.getServers().entrySet()) { dockerimageTool.getEndpoints().add(toEndpoint(serverEntry.getKey(), serverEntry.getValue())); } for (Entry<String, VolumeImpl> volumeEntry : machineConfig.getVolumes().entrySet()) { dockerimageTool .getVolumes() .add(toDevfileVolume(volumeEntry.getKey(), volumeEntry.getValue())); } machineConfig .getEnv() .entrySet() .stream() .map(e -> new Env().withName(e.getKey()).withValue(e.getValue())) .forEach(e -> dockerimageTool.getEnv().add(e)); return dockerimageTool; }

Target:
public Tool from(String environmentName, EnvironmentImpl environment) throws WorkspaceExportException { checkArgument(environment != null, "The environment must not be null"); checkArgument(environmentName != null, "The environment name must not be null"); checkArgument(environment.getRecipe() != null, "The environment recipe must not be null"); checkArgument( environment.getRecipe().getType().equals(DOCKERIMAGE_RECIPE_TYPE), "The environment recipe must have recipe with 'dockerimage' tool"); RecipeImpl recipe = environment.getRecipe(); Tool dockerimageTool = new Tool(); dockerimageTool.setName(environmentName); dockerimageTool.setImage(recipe.getContent()); dockerimageTool.setType(DOCKERIMAGE_TOOL_TYPE); if (environment.getMachines().isEmpty()) { return dockerimageTool; } if (environment.getMachines().size() > 1) { throw new WorkspaceExportException( "Environment with 'dockerimage' recipe must contain only one machine configuration"); } MachineConfigImpl machineConfig = environment.getMachines().values().iterator().next(); for (Entry<String, ServerConfigImpl> serverEntry : machineConfig.getServers().entrySet()) { dockerimageTool.getEndpoints().add(toEndpoint(serverEntry.getKey(), serverEntry.getValue())); } for (Entry<String, VolumeImpl> volumeEntry : machineConfig.getVolumes().entrySet()) { if (volumeEntry.getKey().equals(PROJECTS_VOLUME_NAME)) { dockerimageTool.setMountSources(true); continue; } dockerimageTool .getVolumes() .add(toDevfileVolume(volumeEntry.getKey(), volumeEntry.getValue())); } dockerimageTool.setMemoryLimit(machineConfig.getAttributes().get(MEMORY_LIMIT_ATTRIBUTE)); machineConfig .getEnv() .entrySet() .stream() .map(e -> new Env().withName(e.getKey()).withValue(e.getValue())) .forEach(e -> dockerimageTool.getEnv().add(e)); return dockerimageTool; }