private InternalEnvironment getInternalEnvironment(Environment environment) throws InfrastructureException, ValidationException, NotFoundException { final String recipeType = environment.getRecipe().getType(); final InternalEnvironmentFactory factory = environmentFactories.get(recipeType); if (factory == null) { throw new NotFoundException( format("InternalEnvironmentFactory is not configured for recipe type: '%s'", recipeType)); } return factory.create(environment); } }
@VisibleForTesting Map<String, ServerConfig> normalizeServers(Map<String, ? extends ServerConfig> servers) { return servers .entrySet() .stream() .collect(Collectors.toMap(Entry::getKey, e -> normalizeServer(e.getValue()))); }
new InternalMachineConfig( installers, normalizeServers(machineConfig.getServers()), machineConfig.getEnv(), machineConfig.getAttributes(), T internalEnv = doCreate(recipe, machines, warnings);
@VisibleForTesting InternalEnvironment createInternalEnvironment( @Nullable Environment environment, Map<String, String> workspaceConfigAttributes, List<? extends Command> commands) throws InfrastructureException, ValidationException, NotFoundException { String recipeType; if (environment == null) { recipeType = Constants.NO_ENVIRONMENT_RECIPE_TYPE; } else { recipeType = environment.getRecipe().getType(); } InternalEnvironmentFactory factory = environmentFactories.get(recipeType); if (factory == null) { throw new NotFoundException( format("InternalEnvironmentFactory is not configured for recipe type: '%s'", recipeType)); } InternalEnvironment internalEnvironment = factory.create(environment); internalEnvironment.setAttributes(new HashMap<>(workspaceConfigAttributes)); internalEnvironment.setCommands( commands.stream().map(CommandImpl::new).collect(Collectors.toList())); return internalEnvironment; }
@Override public DockerImageEnvironment create(Environment sourceEnv) throws InfrastructureException, ValidationException { checkNotNull( sourceEnv, "Null environment is not supported by docker image environment factory"); if (sourceEnv.getRecipe().getLocation() != null) { // move image from location to content EnvironmentImpl envCopy = new EnvironmentImpl(sourceEnv); envCopy.getRecipe().setContent(sourceEnv.getRecipe().getLocation()); envCopy.getRecipe().setLocation(null); return super.create(envCopy); } return super.create(sourceEnv); }