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

dev.galasa.docker.internal.DockerContainerConfigImpl Maven / Gradle / Ivy

The newest version!
/*
 * Copyright contributors to the Galasa project
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package dev.galasa.docker.internal;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import dev.galasa.docker.IDockerContainerConfig;
import dev.galasa.docker.IDockerVolume;

/**
 * Implementation for the object that represents the container configurations that can be edited for container startup
 * 
 *   
 */
public class DockerContainerConfigImpl implements IDockerContainerConfig {
    private List     volumes     = new ArrayList<>();
    private HashMap  envs     = new HashMap<>();
    private List            ports   = new ArrayList<>();

    /**
     * Consturctors that sets all requested volumes to the config
     * 
     * @param volumes
     */
    public DockerContainerConfigImpl(List volumes) {
        this.volumes = volumes;
    }

    /**
     * Sets environment variables
     * 
     * @param envs
     */
    @Override
    public void setEnvs(HashMap envs) {
       this.envs = envs;
    }

    /**
     * Returns set Environment variables for this configuration.
     * 
     * @return envs
     */
    @Override
    public HashMap getEnvs() {
        return this.envs;
    }

    /**
     * Retruns a list of all the volumes in this configuration
     * 
     * @return volumes
     */
    @Override
    public List getVolumes() {
        return this.volumes;
    }

    /**
     * Returns a specific named volume from the configuration
     * 
     * @return volume
     */
    @Override
    public IDockerVolume getVolumeByTag(String volumeTag) {
        for (IDockerVolume volume : this.volumes) {
            if (volumeTag.equals(volume.getVolumeTag())) {
                return volume;
            }
        }
        return null;
    }

    /**
     * Allows ports to be exposed at container startup
     */
    @Override
    public void setExposedPorts(List ports) {
        this.ports = ports;
    }

    /**
     * Returns a list of ports exposed from the configuration
     * @return ports
     */
    @Override
    public List getExposedPorts() {
        return this.ports;
    }
    
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy