All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.atlassian.bamboo.specs.api.builders.pbc.PerBuildContainerForEnvironment Maven / Gradle / Ivy

The newest version!
package com.atlassian.bamboo.specs.api.builders.pbc;

import com.atlassian.bamboo.specs.api.builders.deployment.configuration.EnvironmentPluginConfiguration;
import com.atlassian.bamboo.specs.api.model.pbc.ExtraContainerProperties;
import com.atlassian.bamboo.specs.api.model.pbc.PerBuildContainerForEnvironmentProperties;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

/**
 * Per Build Container definition for Deployment Environments.
 */
public class PerBuildContainerForEnvironment
        extends EnvironmentPluginConfiguration {

    private String image;
    private boolean enabled = true;
    private String size = ContainerSize.REGULAR.name();
    private String awsRole;
    private String architecture;
    private List extraContainers = new ArrayList<>();
    private HashSet featureFlags = new HashSet<>();

    public PerBuildContainerForEnvironment() {}

    /**
     * Marks PBC as enabled for given job. Default value is true.
     */
    public PerBuildContainerForEnvironment enabled(boolean enabled) {
        this.enabled = enabled;
        return this;
    }

    public PerBuildContainerForEnvironment image(String image) {
        this.image = image;
        return this;
    }
    /**
     * Symbolic name for size of the container.
     * See ContainerSize enum for allowed values.
     * The default value is 'REGULAR'.
     */
    public PerBuildContainerForEnvironment size(String size) {
        this.size = size;
        return this;
    }

    /**
     * Symbolic name for size of the container.
     * The default value is 'REGULAR'.
     */
    public PerBuildContainerForEnvironment size(ContainerSize size) {
        this.size = size != null ? size.name() : null;
        return this;
    }

    /**
     * AWS Role of the current deployment.
     * Optional. Needs to be supported by the runtime environment.
     */
    public PerBuildContainerForEnvironment awsRole(String awsRole) {
        this.awsRole = awsRole;
        return this;
    }

    /**
     * Architecture the build should run on
     * Optional. If specified, the Bamboo server must have this configured as one of the available architectures.
     */
    public PerBuildContainerForEnvironment architecture(Architecture architecture) {
        this.architecture = architecture.toString();
        return this;
    }

    /**
     * This method will not be removed, but it should not be used unless you have a need for a specific architecture
     * not specified in the Architecture enum. You should use {@code .architecture(Architecture a)} instead.
     * @param architecture A string which is the name of the architecture
     */
    @Deprecated
    public PerBuildContainerForEnvironment architecture(String architecture) {
        this.architecture = architecture;
        return this;
    }

    public PerBuildContainerForEnvironment extraContainers(ExtraContainer... extraContainers) {
        extraContainers(Arrays.asList(extraContainers));
        return this;
    }

    public PerBuildContainerForEnvironment extraContainers(List extraContainers) {
        extraContainers.stream().map(ExtraContainer::build).forEach(this.extraContainers::add);
        return this;
    }

    public PerBuildContainerForEnvironment withFeatureFlag(String featureFlag) {
        featureFlags.add(featureFlag);
        return this;
    }

    public PerBuildContainerForEnvironment withFeatureFlags(HashSet featureFlags) {
        this.featureFlags.addAll(featureFlags);
        return this;
    }

    @Override
    protected PerBuildContainerForEnvironmentProperties build() {
        return new PerBuildContainerForEnvironmentProperties(
                enabled, image, size, extraContainers, awsRole, architecture, featureFlags);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy