diff --git a/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/auth/AuthConfigFactory.java b/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/auth/AuthConfigFactory.java index 625197f017..fee1181bfb 100644 --- a/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/auth/AuthConfigFactory.java +++ b/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/auth/AuthConfigFactory.java @@ -61,19 +61,12 @@ public class AuthConfigFactory { static final String DOCKER_LOGIN_DEFAULT_REGISTRY = "https://index.docker.io/v1/"; - private KitLogger log; + private final KitLogger log; private static final String[] DEFAULT_REGISTRIES = new String[]{ "docker.io", "index.docker.io", "registry.hub.docker.com" }; - /** - * Constructor which should be used during startup phase of a plugin - * - */ - public AuthConfigFactory() { - } - - public void setLog(KitLogger log) { + public AuthConfigFactory(KitLogger log) { this.log = log; } diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/AbstractDockerMojo.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/AbstractDockerMojo.java index 8da398e298..55b6d4e1f9 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/AbstractDockerMojo.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/AbstractDockerMojo.java @@ -428,7 +428,6 @@ public abstract class AbstractDockerMojo extends AbstractMojo implements ConfigH @Override public void contextualize(Context context) throws ContextException { plexusContainer = ((PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY)); - authConfigFactory = new AuthConfigFactory(); } @Override @@ -436,14 +435,12 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (!skip) { boolean ansiRestore = Ansi.isEnabled(); log = new AnsiLogger(getLog(), useColorForLogging(), verbose, !settings.getInteractiveMode(), getLogPrefix()); + authConfigFactory = new AuthConfigFactory(log); + imageConfigResolver.setLog(log); try { - authConfigFactory.setLog(log); - imageConfigResolver.setLog(log); - LogOutputSpecFactory logSpecFactory = new LogOutputSpecFactory(useColor, logStdout, logDate); - DockerAccess access = null; try { JKubeProject jkubeProject = MavenUtil.convertMavenProjectToJKubeProject(project, session); @@ -575,7 +572,7 @@ protected void processDmpPluginDescription(URL pluginDesc, File outputDir) throw } } - protected RegistryService.RegistryConfig getRegistryConfig(String specificRegistry) throws MojoExecutionException { + protected RegistryService.RegistryConfig getRegistryConfig(String specificRegistry) { return new RegistryService.RegistryConfig.Builder() .settings(MavenUtil.getRegistryServerFromMavenSettings(settings)) .authConfig(authConfig != null ? authConfig.toMap() : null) diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/BuildMojo.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/BuildMojo.java index 9432488da8..6d7bdc72cc 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/BuildMojo.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/BuildMojo.java @@ -18,6 +18,7 @@ import org.eclipse.jkube.kit.build.service.docker.ServiceHub; import org.eclipse.jkube.kit.build.service.docker.access.DockerAccess; import org.eclipse.jkube.kit.build.service.docker.access.log.LogOutputSpecFactory; +import org.eclipse.jkube.kit.build.service.docker.auth.AuthConfigFactory; import org.eclipse.jkube.kit.build.service.docker.config.ConfigHelper; import org.eclipse.jkube.kit.common.util.AnsiLogger; import org.eclipse.jkube.kit.common.util.MavenUtil; @@ -86,7 +87,7 @@ public void executeInternal(ServiceHub hub) throws MojoExecutionException { public void executeDockerBuild() throws MojoExecutionException, MojoFailureException { if (!skip) { log = new AnsiLogger(getLog(), useColor, verbose, !settings.getInteractiveMode(), getLogPrefix()); - authConfigFactory.setLog(log); + authConfigFactory = new AuthConfigFactory(log); imageConfigResolver.setLog(log); LogOutputSpecFactory logSpecFactory = new LogOutputSpecFactory(useColor, logStdout, logDate); diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/PushMojo.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/PushMojo.java index df88799eca..cd46560176 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/PushMojo.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/PushMojo.java @@ -60,11 +60,6 @@ public void execute() throws MojoExecutionException, MojoFailureException { super.execute(); } - @Override - public void contextualize(Context context) throws ContextException { - authConfigFactory = new AuthConfigFactory(); - } - @Override public void executeInternal(ServiceHub serviceHub) throws MojoExecutionException { if (skipPush) { diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/WatchMojo.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/WatchMojo.java index b9f8cf7f09..8dccd96d8e 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/WatchMojo.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/WatchMojo.java @@ -160,11 +160,6 @@ public class WatchMojo extends AbstractDockerMojo { private KubernetesClient kubernetes; private ServiceHub hub; - @Override - public void contextualize(Context context) throws ContextException { - authConfigFactory = new AuthConfigFactory(); - } - @Override public void execute() throws MojoExecutionException, MojoFailureException { if (skip) { diff --git a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/AbstractDockerMojo.java b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/AbstractDockerMojo.java index a45d0cfd30..b45361fae5 100644 --- a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/AbstractDockerMojo.java +++ b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/AbstractDockerMojo.java @@ -22,6 +22,7 @@ import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.eclipse.jkube.generator.api.GeneratorContext; +import org.eclipse.jkube.kit.build.api.auth.AuthConfig; import org.eclipse.jkube.kit.build.core.GavLabel; import org.eclipse.jkube.kit.build.core.JKubeBuildContext; import org.eclipse.jkube.kit.build.core.config.JKubeBuildConfiguration; @@ -428,7 +429,6 @@ public abstract class AbstractDockerMojo extends AbstractMojo implements ConfigH @Override public void contextualize(Context context) throws ContextException { plexusContainer = ((PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY)); - authConfigFactory = new AuthConfigFactory(); } @Override @@ -436,14 +436,12 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (!skip) { boolean ansiRestore = Ansi.isEnabled(); log = new AnsiLogger(getLog(), useColorForLogging(), verbose, !settings.getInteractiveMode(), getLogPrefix()); + authConfigFactory = new AuthConfigFactory(log); + imageConfigResolver.setLog(log); try { - authConfigFactory.setLog(log); - imageConfigResolver.setLog(log); - LogOutputSpecFactory logSpecFactory = new LogOutputSpecFactory(useColor, logStdout, logDate); - DockerAccess access = null; try { ConfigHelper.validateExternalPropertyActivation(MavenUtil.convertMavenProjectToJKubeProject(project, session), images); @@ -574,7 +572,7 @@ protected void processDmpPluginDescription(URL pluginDesc, File outputDir) throw } } - protected RegistryService.RegistryConfig getRegistryConfig(String specificRegistry) throws MojoExecutionException { + protected RegistryService.RegistryConfig getRegistryConfig(String specificRegistry) { return new RegistryService.RegistryConfig.Builder() .settings(MavenUtil.getRegistryServerFromMavenSettings(settings)) .authConfig(authConfig != null ? authConfig.toMap() : null) diff --git a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/BuildMojo.java b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/BuildMojo.java index e7eb125974..6b85265dd8 100644 --- a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/BuildMojo.java +++ b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/BuildMojo.java @@ -49,9 +49,6 @@ @Mojo(name = "build", defaultPhase = LifecyclePhase.PRE_INTEGRATION_TEST, requiresDependencyResolution = ResolutionScope.COMPILE) public class BuildMojo extends AbstractDockerMojo implements Contextualizable { - // Handler dealing with authentication credentials - private AuthConfigFactory authConfigFactory; - @Override protected boolean isDockerAccessRequired() { boolean ret = false; @@ -74,11 +71,6 @@ public void execute() throws MojoExecutionException, MojoFailureException { executeDockerBuild(); } - @Override - public void contextualize(Context context) throws ContextException { - authConfigFactory = new AuthConfigFactory(); - } - @Override public void executeInternal(ServiceHub hub) throws MojoExecutionException { if (skipBuild) { @@ -114,7 +106,7 @@ public void executeInternal(ServiceHub hub) throws MojoExecutionException { public void executeDockerBuild() throws MojoExecutionException, MojoFailureException { if (!skip) { log = new AnsiLogger(getLog(), useColor, verbose, !settings.getInteractiveMode(), getLogPrefix()); - authConfigFactory.setLog(log); + authConfigFactory = new AuthConfigFactory(log); imageConfigResolver.setLog(log); LogOutputSpecFactory logSpecFactory = new LogOutputSpecFactory(useColor, logStdout, logDate); diff --git a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/WatchMojo.java b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/WatchMojo.java index 8c71789885..0c6b1a870d 100644 --- a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/WatchMojo.java +++ b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/WatchMojo.java @@ -160,11 +160,6 @@ public class WatchMojo extends AbstractDockerMojo { private KubernetesClient kubernetes; private ServiceHub hub; - @Override - public void contextualize(Context context) throws ContextException { - authConfigFactory = new AuthConfigFactory(); - } - @Override public void execute() throws MojoExecutionException, MojoFailureException { if (skip) {