/** Converts {@link WorkspaceConfig} to {@link WorkspaceConfigDto}. */ public static WorkspaceConfigDto asDto(WorkspaceConfig workspace) { List<CommandDto> commands = workspace.getCommands().stream().map(DtoConverter::asDto).collect(toList()); List<ProjectConfigDto> projects = workspace.getProjects().stream().map(DtoConverter::asDto).collect(toList()); Map<String, EnvironmentDto> environments = workspace .getEnvironments() .entrySet() .stream() .collect(toMap(Map.Entry::getKey, entry -> asDto(entry.getValue()))); return newDto(WorkspaceConfigDto.class) .withName(workspace.getName()) .withDefaultEnv(workspace.getDefaultEnv()) .withCommands(commands) .withProjects(projects) .withEnvironments(environments) .withAttributes(workspace.getAttributes()) .withDescription(workspace.getDescription()); }
private void validateEnvironments(WorkspaceConfig config) throws ValidationException { boolean environmentIsNotSet = (config.getEnvironments() == null || config.getEnvironments().isEmpty()) && isNullOrEmpty(config.getDefaultEnv()); boolean isSidecarWorkspace = isSidecarBasedWorkspace(config.getAttributes()); if (environmentIsNotSet && isSidecarWorkspace) { // sidecar based workspaces allowed not to have environment return; } check(!isNullOrEmpty(config.getDefaultEnv()), "Workspace default environment name required"); checkNotNull(config.getEnvironments(), "Workspace must contain at least one environment"); check( config.getEnvironments().containsKey(config.getDefaultEnv()), "Workspace default environment configuration required"); for (Environment environment : config.getEnvironments().values()) { checkNotNull(environment, "Environment must not be null"); Recipe recipe = environment.getRecipe(); checkNotNull(recipe, "Environment recipe must not be null"); checkNotNull(recipe.getType(), "Environment recipe type must not be null"); for (Entry<String, ? extends MachineConfig> machineEntry : environment.getMachines().entrySet()) { validateMachine(machineEntry.getKey(), machineEntry.getValue()); } } }
public WorkspaceConfigImplBuilder fromConfig(WorkspaceConfig workspaceConfig) { this.name = workspaceConfig.getName(); this.description = workspaceConfig.getDescription(); this.defaultEnvName = workspaceConfig.getDefaultEnv(); this.projects = workspaceConfig.getProjects(); this.commands = workspaceConfig.getCommands(); this.environments = workspaceConfig.getEnvironments(); return this; }
public WorkspaceConfigImpl(WorkspaceConfig workspaceConfig) { this( workspaceConfig.getName(), workspaceConfig.getDescription(), workspaceConfig.getDefaultEnv(), workspaceConfig.getCommands(), workspaceConfig.getProjects(), workspaceConfig.getEnvironments(), workspaceConfig.getAttributes()); }
public WorkspaceConfigImpl(WorkspaceConfig workspaceConfig) { this( workspaceConfig.getName(), workspaceConfig.getDescription(), workspaceConfig.getDefaultEnv(), workspaceConfig.getCommands(), workspaceConfig.getProjects(), workspaceConfig.getEnvironments(), workspaceConfig.getAttributes()); }
config.getEnvironments().get(firstNonNull(envName, config.getDefaultEnv())); final ResourceImpl ramToUse = new ResourceImpl(