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

io.fabric8.maven.docker.access.ContainerNetworkingConfig Maven / Gradle / Ivy

There is a newer version: 0.45.0
Show newest version
package io.fabric8.maven.docker.access;

import io.fabric8.maven.docker.config.NetworkConfig;
import org.json.JSONArray;
import org.json.JSONObject;

public class ContainerNetworkingConfig {

    private final JSONObject networkingConfig = new JSONObject();

    /**
     * Add networking aliases to a custom network
     *
     * @param config network config as configured in the pom.xml
     * @return this configuration
     */
    public ContainerNetworkingConfig aliases(NetworkConfig config) {
        JSONObject endPoints = new JSONObject();
        endPoints.put("Aliases",new JSONArray(config.getAliases()));

        JSONObject endpointConfigMap = new JSONObject();
        endpointConfigMap.put(config.getCustomNetwork(), endPoints);

        networkingConfig.put("EndpointsConfig", endpointConfigMap);
        return this;
    }

    public String toJson() {
        return networkingConfig.toString();
    }

    public Object toJsonObject() {
        return networkingConfig;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy