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

io.fabric8.maven.docker.config.RegistryAuthConfiguration Maven / Gradle / Ivy

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

import java.io.Serializable;
import java.util.Map;
import java.util.TreeMap;

import io.fabric8.maven.docker.util.AuthConfigFactory;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugins.annotations.Parameter;

public class RegistryAuthConfiguration implements Serializable {

    @Parameter
    private Map push;

    @Parameter
    private Map pull;

    @Parameter
    private String username;

    @Parameter
    private String password;

    @Parameter
    private String email;

    @Parameter
    private String authToken;

    public Map toMap() {
        final Map authMap = new TreeMap<>();

        if (push != null) {
            authMap.put("push", push);
        }
        if (pull != null) {
            authMap.put("pull", pull);
        }
        if (StringUtils.isNotBlank(username)) {
            authMap.put(AuthConfigFactory.AUTH_USERNAME, username);
        }
        if (StringUtils.isNotBlank(password)) {
            authMap.put(AuthConfigFactory.AUTH_PASSWORD, password);
        }
        if (StringUtils.isNotBlank(authToken)) {
            authMap.put(AuthConfigFactory.AUTH_AUTHTOKEN, authToken);
        }
        if (StringUtils.isNotBlank(email)) {
            authMap.put(AuthConfigFactory.AUTH_EMAIL,email);
        }
        return authMap;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy