package com.nirima.jenkins.plugins.docker;

import hudson.Extension;
import jenkins.model.GlobalConfiguration;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.StaplerRequest;

@Extension
public class DockerPluginConfiguration extends GlobalConfiguration {

    /**
     * Work around option.
     */
    public Boolean pullFix;

    /**
     * Returns this singleton instance.
     *
     * @return the singleton.
     */
    public static DockerPluginConfiguration get() {
        return GlobalConfiguration.all().get(DockerPluginConfiguration.class);
    }

    public DockerPluginConfiguration() {
        load();
    }

    @Override
    public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
        req.bindJSON(this, json);
        return true;
    }

    public final boolean getPullFix() {
        if( pullFix == null )
            pullFix = true;
        return pullFix;
    }

    @DataBoundSetter
    public final void setPullFix(boolean pullFix) {
        this.pullFix = pullFix;
    }

}

@@ -223,16 +223,70 @@
 quest;%0A%0A
+import java.util.Collections;%0Aimport java.util.List;%0A%0A
 @Extensi
@@ -406,21 +406,22 @@
 */%0A    p
-ublic
+rivate
  Boolean
@@ -431,16 +431,132 @@
 llFix;%0A%0A
+    /**%0A     * List of registries%0A     */%0A    private List%3CDockerRegistry%3E registryList = Collections.emptyList();%0A%0A
     /**%0A
@@ -971,17 +971,16 @@
 ON(this,
- 
 json);%0A 
@@ -1143,114 +1143,610 @@
     
-@DataBoundSetter%0A    public final void setPullFix(boolean pullFix) %7B%0A        this.pullFix = pullFix;%0A    %7D%0A
+public DockerRegistry getRegistryByName(String registryName) %7B%0A        for(DockerRegistry registry : registryList) %7B%0A            if( registry.registry.equalsIgnoreCase(registryName))%0A                return registry;%0A        %7D%0A        // Not found%0A        return null;%0A    %7D%0A%0A%0A    public final void setPullFix(boolean pullFix) %7B%0A        this.pullFix = pullFix;%0A        save();%0A    %7D%0A%0A    public void setRegistryList(List%3CDockerRegistry%3E registryList) %7B%0A        this.registryList = registryList;%0A        save();%0A    %7D%0A%0A    public List%3CDockerRegistry%3E getRegistryList() %7B%0A        return registryList;%0A    %7D
 %0A%7D%0A

Add list of registries into the docker config.