@Override protected DockerImageEnvironment doCreate( @Nullable InternalRecipe recipe, Map<String, InternalMachineConfig> machines, List<Warning> warnings) throws InfrastructureException, ValidationException { checkNotNull(recipe, "Null recipe is not supported by docker image environment factory"); if (!DockerImageEnvironment.TYPE.equals(recipe.getType())) { throw new ValidationException( format( "Docker image environment parser doesn't support recipe type '%s'", recipe.getType())); } String dockerImage = recipe.getContent(); checkArgument(dockerImage != null, "Docker image should not be null."); addRamAttributes(machines); return new DockerImageEnvironment(dockerImage, recipe, machines, warnings); }
throws InfrastructureException, ValidationException { checkNotNull(recipe, "Null recipe is not supported by compose environment factory"); String contentType = recipe.getContentType(); checkNotNull(contentType, "Recipe content type should not be null"); String recipeContent = recipe.getContent(); if (!ComposeEnvironment.TYPE.equals(recipe.getType())) { throw new ValidationException( format("Compose environment parser doesn't support recipe type '%s'", recipe.getType()));
warnings.addAll(sourceWarnings); String content = recipe.getContent(); String contentType = recipe.getContentType(); checkNotNull(contentType, "OpenShift Recipe content type should not be null");
protected InternalEnvironment( InternalRecipe recipe, Map<String, InternalMachineConfig> machines, List<Warning> warnings) { this.recipe = recipe; this.machines = machines; this.warnings = new CopyOnWriteArrayList<>(); if (warnings != null) { this.warnings.addAll(warnings); } this.type = recipe != null ? recipe.getType() : null; }
/** * Returns content of recipe either by getting it from provided {@link Recipe} object or by * retrieving it from location set in provided recipe. * * @param recipe recipe of {@link org.eclipse.che.api.core.model.workspace.config.Environment} * @return recipe content * @throws NullPointerException when recipe is null * @throws IllegalArgumentException when both recipe content and location are null or empty */ public InternalRecipe getRecipe(Recipe recipe) throws InfrastructureException { Objects.requireNonNull(recipe, "Recipe should not be null"); Objects.requireNonNull(recipe.getType(), "Recipe type should not be null"); return new InternalRecipe(recipe.getType(), recipe.getContentType(), retrieveContent(recipe)); }
protected InternalEnvironment(InternalEnvironment internalEnvironment) { this.recipe = internalEnvironment.getRecipe(); this.type = recipe != null ? recipe.getType() : null; this.machines = internalEnvironment.getMachines(); this.warnings = new CopyOnWriteArrayList<>(internalEnvironment.getWarnings()); this.attributes = internalEnvironment.getAttributes(); this.commands = internalEnvironment.getCommands(); }
@Override protected DockerfileEnvironment doCreate( @Nullable InternalRecipe recipe, Map<String, InternalMachineConfig> machines, List<Warning> warnings) throws InfrastructureException, ValidationException { checkNotNull(recipe, "Null recipe is not supported by docker file environment factory"); if (!DockerfileEnvironment.TYPE.equals(recipe.getType())) { throw new ValidationException( format( "Dockerfile environment parser doesn't support recipe type '%s'", recipe.getType())); } String dockerfile = recipe.getContent(); checkArgument(dockerfile != null, "Dockerfile content should not be null."); addRamAttributes(machines); return new DockerfileEnvironment(dockerfile, recipe, machines, warnings); }