From 8fef0c37cda898dfbd354bc89e7d92a2a6720032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Grani=C3=A9?= Date: Thu, 14 Dec 2023 14:44:07 +0000 Subject: [PATCH 1/5] Add new pull policy newer Fixes #95 --- .../command/podman/PodmanBuildCommand.java | 20 ++------ .../AbstractImageBuildConfiguration.java | 46 ++++--------------- .../image/batch/BatchImageConfiguration.java | 8 +--- .../podman/enumeration/PullPolicy.java | 46 +++++++++++++++++++ .../podman/service/PodmanExecutorService.java | 12 ++--- .../lexemmens/podman/BatchBuildMojoTest.java | 10 ++-- .../TestBatchImageConfigurationBuilder.java | 11 ++--- .../TestSingleImageConfigurationBuilder.java | 11 ++--- .../service/PodmanExecutorServiceTest.java | 31 ++----------- 9 files changed, 82 insertions(+), 113 deletions(-) create mode 100644 src/main/java/nl/lexemmens/podman/enumeration/PullPolicy.java diff --git a/src/main/java/nl/lexemmens/podman/command/podman/PodmanBuildCommand.java b/src/main/java/nl/lexemmens/podman/command/podman/PodmanBuildCommand.java index 8811e431..df584b3d 100644 --- a/src/main/java/nl/lexemmens/podman/command/podman/PodmanBuildCommand.java +++ b/src/main/java/nl/lexemmens/podman/command/podman/PodmanBuildCommand.java @@ -23,8 +23,7 @@ public class PodmanBuildCommand extends AbstractPodmanCommand { private static final String LAYERS_CMD = "--layers"; private static final String BUILD_FORMAT_CMD = "--format"; private static final String CONTAINERFILE_CMD = "--file"; - private static final String PULL_CMD = "--pull"; - private static final String PULL_ALWAYS_CMD = "--pull-always"; + private static final String PULL_POLICY_CMD = "--pull"; private static final String NO_CACHE_CMD = "--no-cache"; private static final String BUILD_ARG_CMD = "--build-arg"; private static final String PLATFORM_CMD = "--platform"; @@ -109,11 +108,11 @@ public Builder setContainerFile(Path containerFile) { /** * Sets whether the base image should be pulled * - * @param pull Sets whether to pull the image + * @param pullPolicy Sets whether to pull the image * @return This builder instance */ - public Builder setPull(Boolean pull) { - command.withOption(PULL_CMD, pull.toString()); + public Builder setPullPolicy(String pullPolicy) { + command.withOption(PULL_POLICY_CMD, pullPolicy); return this; } @@ -128,17 +127,6 @@ public Builder setNoCache(boolean noCache) { return this; } - /** - * Sets whether base images should always be pushed - * - * @param pullAlways Sets the value of the pullAlways property - * @return This builder instance - */ - public Builder setPullAllways(Boolean pullAlways) { - command.withOption(PULL_ALWAYS_CMD, pullAlways.toString()); - return this; - } - /** * Sets the platform for the resulting image rather using the default of the build system * diff --git a/src/main/java/nl/lexemmens/podman/config/image/AbstractImageBuildConfiguration.java b/src/main/java/nl/lexemmens/podman/config/image/AbstractImageBuildConfiguration.java index 43c31206..448af310 100644 --- a/src/main/java/nl/lexemmens/podman/config/image/AbstractImageBuildConfiguration.java +++ b/src/main/java/nl/lexemmens/podman/config/image/AbstractImageBuildConfiguration.java @@ -1,6 +1,8 @@ package nl.lexemmens.podman.config.image; import nl.lexemmens.podman.enumeration.ContainerFormat; +import nl.lexemmens.podman.enumeration.PullPolicy; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.annotations.Parameter; @@ -54,20 +56,8 @@ public abstract class AbstractImageBuildConfiguration { * Configures whether from-images should be pulled so that the image will * always be build on the latest base. */ - @Parameter - protected Boolean pull; - - /** - * Configures whether from-images should always be pulled from the first registry it is found in. - *

- * From Podman docs: - * Pull the image from the first registry it is found in as listed in registries.conf. - * Raise an error if not found in the registries, even if the image is present locally. - * - * @see --pull-always on docs.podman.io - */ - @Parameter - protected Boolean pullAlways; + @Parameter(defaultValue = "missing") + protected PullPolicy pullPolicy; /** * Array consisting of one or more tags to attach to a container image. @@ -194,17 +184,8 @@ public boolean isNoCache() { * * @return When set to true, podman will build with --pull */ - public Optional getPull() { - return Optional.ofNullable(pull); - } - - /** - * Returns if the --pull-always property should be used - * - * @return When set to true, podman will build with --pull-always - */ - public Optional getPullAlways() { - return Optional.ofNullable(pullAlways); + public Optional getPullPolicy() { + return Optional.ofNullable(pullPolicy); } public void validate(MavenProject project) { @@ -448,19 +429,10 @@ public void setNoCache(boolean noCache) { * Configures whether from-images should be pulled so that the image will * always be build on the latest base. * - * @param pull The value to set - */ - public void setPull(Boolean pull) { - this.pull = pull; - } - - /** - * Configures whether from-images should always be pulled from the first registry it is found in. - * - * @param pullAlways The value to set + * @param pullPolicy The value to set */ - public void setPullAlways(Boolean pullAlways) { - this.pullAlways = pullAlways; + public void setPullPolicy(PullPolicy pullPolicy) { + this.pullPolicy = pullPolicy; } /** diff --git a/src/main/java/nl/lexemmens/podman/config/image/batch/BatchImageConfiguration.java b/src/main/java/nl/lexemmens/podman/config/image/batch/BatchImageConfiguration.java index e879dc6f..6abea26c 100644 --- a/src/main/java/nl/lexemmens/podman/config/image/batch/BatchImageConfiguration.java +++ b/src/main/java/nl/lexemmens/podman/config/image/batch/BatchImageConfiguration.java @@ -76,17 +76,13 @@ private List convertToSingleImageConfigurations(Log lo buildConfiguration.setCreateLatestTag(getBuild().isCreateLatestTag()); buildConfiguration.setLabels(getBuild().getLabels()); - if(getBuild().getPull().isPresent()) { - buildConfiguration.setPull(getBuild().getPull().get()); + if(getBuild().getPullPolicy().isPresent()) { + buildConfiguration.setPullPolicy(getBuild().getPullPolicy().get()); } buildConfiguration.setNoCache(getBuild().isNoCache()); buildConfiguration.setTags(getBuild().getTags()); - if(getBuild().getPullAlways().isPresent()) { - buildConfiguration.setPullAlways(getBuild().getPullAlways().get()); - } - buildConfiguration.setTagWithMavenProjectVersion(getBuild().isTagWithMavenProjectVersion()); imageConfiguration.setBuild(buildConfiguration); diff --git a/src/main/java/nl/lexemmens/podman/enumeration/PullPolicy.java b/src/main/java/nl/lexemmens/podman/enumeration/PullPolicy.java new file mode 100644 index 00000000..12865aac --- /dev/null +++ b/src/main/java/nl/lexemmens/podman/enumeration/PullPolicy.java @@ -0,0 +1,46 @@ +package nl.lexemmens.podman.enumeration; + +/** + * Defines the pullpolicy of the built image's manifest and configuration data. Recognised values include oci and docker. + * @see Manual of podman build + */ +public enum PullPolicy { + + /** + * Always pull the image and throw an error if the pull fails. + */ + ALWAYS("always"), + + /** + * Only pull the image when it does not exist in the local containers storage. Throw an error if no image is found and the pull fails. + */ + MISSING("missing"), + + /** + * Never pull the image but use the one from the local containers storage. Throw an error when no image is found. + */ + NEVER("never"), + + /** + * Pull if the image on the registry is newer than the one in the local containers storage. An image is considered to be newer when the digests are different. Comparing the time stamps is prone to errors. Pull errors are suppressed if a local image was found. + */ + NEWER("newer"); + + private final String pullPolicy; + + /** + * Constructor + * @param pullPolicy The pullpolicy to set + */ + PullPolicy(String pullPolicy) { + this.pullPolicy = pullPolicy; + } + + /** + * Returns the selected pullpolicy + * @return the selected pullpolicy + */ + public String getValue() { + return pullPolicy; + } +} diff --git a/src/main/java/nl/lexemmens/podman/service/PodmanExecutorService.java b/src/main/java/nl/lexemmens/podman/service/PodmanExecutorService.java index 8328c806..80100dd2 100644 --- a/src/main/java/nl/lexemmens/podman/service/PodmanExecutorService.java +++ b/src/main/java/nl/lexemmens/podman/service/PodmanExecutorService.java @@ -3,6 +3,7 @@ import nl.lexemmens.podman.command.podman.*; import nl.lexemmens.podman.config.image.single.SingleImageConfiguration; import nl.lexemmens.podman.config.podman.PodmanConfiguration; +import nl.lexemmens.podman.enumeration.PullPolicy; import nl.lexemmens.podman.executor.CommandExecutorDelegate; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; @@ -66,14 +67,9 @@ public List build(SingleImageConfiguration image) throws MojoExecutionEx builder = builder.setLayers(image.getBuild().getLayers()); } - Optional pullOptional = image.getBuild().getPull(); - if (pullOptional.isPresent()) { - builder = builder.setPull(pullOptional.get()); - } - - Optional pullAlwaysOptional = image.getBuild().getPullAlways(); - if (pullAlwaysOptional.isPresent()) { - builder = builder.setPullAllways(pullAlwaysOptional.get()); + Optional pullPolicyOptional = image.getBuild().getPullPolicy(); + if (pullPolicyOptional.isPresent()) { + builder = builder.setPullPolicy(pullPolicyOptional.get().getValue()); } Optional platform = image.getBuild().getPlatform(); diff --git a/src/test/java/nl/lexemmens/podman/BatchBuildMojoTest.java b/src/test/java/nl/lexemmens/podman/BatchBuildMojoTest.java index 569e3eee..32b0f145 100644 --- a/src/test/java/nl/lexemmens/podman/BatchBuildMojoTest.java +++ b/src/test/java/nl/lexemmens/podman/BatchBuildMojoTest.java @@ -8,6 +8,7 @@ import nl.lexemmens.podman.config.podman.TestPodmanConfigurationBuilder; import nl.lexemmens.podman.config.skopeo.SkopeoConfiguration; import nl.lexemmens.podman.enumeration.ContainerFormat; +import nl.lexemmens.podman.enumeration.PullPolicy; import nl.lexemmens.podman.enumeration.TlsVerify; import nl.lexemmens.podman.service.ContainerfileDecorator; import org.apache.maven.model.Build; @@ -186,8 +187,7 @@ public void testConversionWithCustomValues() throws MojoExecutionException { BatchImageConfiguration image = new TestBatchImageConfigurationBuilder("sample-image-%d") .setContainerfile("Containerfile") - .setPull(true) - .setPullAlways(true) + .setPullPolicy(PullPolicy.ALWAYS) .setStages(new StageConfiguration[]{stageCfg}) .setLabels(Collections.singletonMap("KEY", "VALUE")) .setTags(new String[]{"latest"}) @@ -218,10 +218,8 @@ public void testConversionWithCustomValues() throws MojoExecutionException { assertNotNull(image1.getBuild()); assertEquals(1, image1.getBuild().getAllTags().size()); assertEquals("latest", image1.getBuild().getAllTags().get(0)); - assertTrue(image1.getBuild().getPull().isPresent()); - assertTrue(image1.getBuild().getPull().get()); - assertTrue(image1.getBuild().getPullAlways().isPresent()); - assertTrue(image1.getBuild().getPullAlways().get()); + assertTrue(image1.getBuild().getPullPolicy().isPresent()); + assertEquals(PullPolicy.ALWAYS, image1.getBuild().getPullPolicy().get()); assertEquals(ContainerFormat.DOCKER, image1.getBuild().getFormat()); } diff --git a/src/test/java/nl/lexemmens/podman/config/image/batch/TestBatchImageConfigurationBuilder.java b/src/test/java/nl/lexemmens/podman/config/image/batch/TestBatchImageConfigurationBuilder.java index 76191457..f8cb3115 100644 --- a/src/test/java/nl/lexemmens/podman/config/image/batch/TestBatchImageConfigurationBuilder.java +++ b/src/test/java/nl/lexemmens/podman/config/image/batch/TestBatchImageConfigurationBuilder.java @@ -2,6 +2,8 @@ import nl.lexemmens.podman.config.image.StageConfiguration; import nl.lexemmens.podman.enumeration.ContainerFormat; +import nl.lexemmens.podman.enumeration.PullPolicy; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; @@ -38,8 +40,8 @@ public TestBatchImageConfigurationBuilder setNoCache(boolean noCache) { return this; } - public TestBatchImageConfigurationBuilder setPull(boolean pull) { - image.getBuild().setPull(pull); + public TestBatchImageConfigurationBuilder setPullPolicy(PullPolicy pullPolicy) { + image.getBuild().setPullPolicy(pullPolicy); return this; } @@ -104,11 +106,6 @@ public TestBatchImageConfigurationBuilder addCustomImageNameForBuildStage(String return this; } - public TestBatchImageConfigurationBuilder setPullAlways(boolean pullAlways) { - image.getBuild().setPullAlways(pullAlways); - return this; - } - public BatchImageConfiguration build() { return image; } diff --git a/src/test/java/nl/lexemmens/podman/config/image/single/TestSingleImageConfigurationBuilder.java b/src/test/java/nl/lexemmens/podman/config/image/single/TestSingleImageConfigurationBuilder.java index 59099276..8abe84b6 100644 --- a/src/test/java/nl/lexemmens/podman/config/image/single/TestSingleImageConfigurationBuilder.java +++ b/src/test/java/nl/lexemmens/podman/config/image/single/TestSingleImageConfigurationBuilder.java @@ -2,6 +2,8 @@ import nl.lexemmens.podman.config.image.StageConfiguration; import nl.lexemmens.podman.enumeration.ContainerFormat; +import nl.lexemmens.podman.enumeration.PullPolicy; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; @@ -37,8 +39,8 @@ public TestSingleImageConfigurationBuilder setNoCache(boolean noCache) { return this; } - public TestSingleImageConfigurationBuilder setPull(boolean pull) { - image.getBuild().setPull(pull); + public TestSingleImageConfigurationBuilder setPullPolicy(PullPolicy pullPolicy) { + image.getBuild().setPullPolicy(pullPolicy); return this; } @@ -118,11 +120,6 @@ public TestSingleImageConfigurationBuilder addCustomImageNameForBuildStage(Strin return this; } - public TestSingleImageConfigurationBuilder setPullAlways(boolean pullAlways) { - image.getBuild().setPullAlways(pullAlways); - return this; - } - public TestSingleImageConfigurationBuilder setTargetStage(String targetStage){ image.getBuild().setTargetStage(targetStage); return this; diff --git a/src/test/java/nl/lexemmens/podman/service/PodmanExecutorServiceTest.java b/src/test/java/nl/lexemmens/podman/service/PodmanExecutorServiceTest.java index 193aad24..3f300ef0 100644 --- a/src/test/java/nl/lexemmens/podman/service/PodmanExecutorServiceTest.java +++ b/src/test/java/nl/lexemmens/podman/service/PodmanExecutorServiceTest.java @@ -5,6 +5,7 @@ import nl.lexemmens.podman.config.podman.PodmanConfiguration; import nl.lexemmens.podman.config.podman.TestPodmanConfigurationBuilder; import nl.lexemmens.podman.enumeration.CGroupManager; +import nl.lexemmens.podman.enumeration.PullPolicy; import nl.lexemmens.podman.executor.CommandExecutorDelegate; import org.apache.commons.lang3.StringUtils; import org.apache.maven.model.Build; @@ -23,6 +24,7 @@ import org.zeroturnaround.exec.ProcessExecutor; import java.io.File; +import java.security.PublicKey; import java.util.*; import static nl.lexemmens.podman.enumeration.ContainerFormat.DOCKER; @@ -453,14 +455,14 @@ public void testBuildPlatform() throws MojoExecutionException { } @Test - public void testBuildPullAlways() throws MojoExecutionException { + public void testBuildPullPolicy() throws MojoExecutionException { when(mavenProject.getBuild()).thenReturn(build); when(build.getDirectory()).thenReturn("target"); PodmanConfiguration podmanConfig = new TestPodmanConfigurationBuilder().setTlsVerify(TRUE).initAndValidate(mavenProject, log).build(); SingleImageConfiguration image = new TestSingleImageConfigurationBuilder("test_image") .setFormat(OCI) - .setPullAlways(true) + .setPullPolicy(PullPolicy.ALWAYS) .setContainerfileDir("src/test/resources") .initAndValidate(mavenProject, log, true) .build(); @@ -472,30 +474,7 @@ public void testBuildPullAlways() throws MojoExecutionException { podmanExecutorService.build(image); Assertions.assertEquals("podman build --tls-verify=true --format=oci --file=" + image.getBuild().getTargetContainerFile() + " --no-cache=false " + - "--pull-always=true .", delegate.getCommandAsString()); - } - - @Test - public void testBuildPull() throws MojoExecutionException { - when(mavenProject.getBuild()).thenReturn(build); - when(build.getDirectory()).thenReturn("target"); - - PodmanConfiguration podmanConfig = new TestPodmanConfigurationBuilder().setTlsVerify(TRUE).initAndValidate(mavenProject, log).build(); - SingleImageConfiguration image = new TestSingleImageConfigurationBuilder("test_image") - .setFormat(OCI) - .setPull(true) - .setContainerfileDir("src/test/resources") - .initAndValidate(mavenProject, log, true) - .build(); - - String sampleImageHash = "this_would_normally_be_an_image_hash"; - InterceptorCommandExecutorDelegate delegate = new InterceptorCommandExecutorDelegate(Collections.singletonList(sampleImageHash)); - podmanExecutorService = new PodmanExecutorService(log, podmanConfig, delegate); - - podmanExecutorService.build(image); - - Assertions.assertEquals("podman build --tls-verify=true --format=oci --file=" + image.getBuild().getTargetContainerFile() + " --no-cache=false " + - "--pull=true .", delegate.getCommandAsString()); + "--pull=always .", delegate.getCommandAsString()); } @Test From fb94dac15af774eed53b333d690f22699825004c Mon Sep 17 00:00:00 2001 From: Granie Laurent Date: Thu, 14 Dec 2023 17:46:59 +0100 Subject: [PATCH 2/5] Add missing pull policies true & false --- .../podman/config/image/AbstractImageBuildConfiguration.java | 2 +- src/main/java/nl/lexemmens/podman/enumeration/PullPolicy.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/nl/lexemmens/podman/config/image/AbstractImageBuildConfiguration.java b/src/main/java/nl/lexemmens/podman/config/image/AbstractImageBuildConfiguration.java index 448af310..e0d3f43f 100644 --- a/src/main/java/nl/lexemmens/podman/config/image/AbstractImageBuildConfiguration.java +++ b/src/main/java/nl/lexemmens/podman/config/image/AbstractImageBuildConfiguration.java @@ -56,7 +56,7 @@ public abstract class AbstractImageBuildConfiguration { * Configures whether from-images should be pulled so that the image will * always be build on the latest base. */ - @Parameter(defaultValue = "missing") + @Parameter protected PullPolicy pullPolicy; /** diff --git a/src/main/java/nl/lexemmens/podman/enumeration/PullPolicy.java b/src/main/java/nl/lexemmens/podman/enumeration/PullPolicy.java index 12865aac..def0e585 100644 --- a/src/main/java/nl/lexemmens/podman/enumeration/PullPolicy.java +++ b/src/main/java/nl/lexemmens/podman/enumeration/PullPolicy.java @@ -10,6 +10,7 @@ public enum PullPolicy { * Always pull the image and throw an error if the pull fails. */ ALWAYS("always"), + TRUE("true"), /** * Only pull the image when it does not exist in the local containers storage. Throw an error if no image is found and the pull fails. @@ -20,6 +21,7 @@ public enum PullPolicy { * Never pull the image but use the one from the local containers storage. Throw an error when no image is found. */ NEVER("never"), + FALSE("false"), /** * Pull if the image on the registry is newer than the one in the local containers storage. An image is considered to be newer when the digests are different. Comparing the time stamps is prone to errors. Pull errors are suppressed if a local image was found. From 25eca2084e4931f3e5bcd8fcef43bd8fae7344bb Mon Sep 17 00:00:00 2001 From: Granie Laurent Date: Thu, 14 Dec 2023 17:47:12 +0100 Subject: [PATCH 3/5] Update doc --- docs/modules/ROOT/pages/goals/build.adoc | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/docs/modules/ROOT/pages/goals/build.adoc b/docs/modules/ROOT/pages/goals/build.adoc index 64b23a9c..0ae0c712 100644 --- a/docs/modules/ROOT/pages/goals/build.adoc +++ b/docs/modules/ROOT/pages/goals/build.adoc @@ -54,24 +54,15 @@ Note: You can also override the default value of layers by setting the BUILDAH_L **Default value is**: `false` |pull -|When the option is specified or set to “true”, pull the image. Raise an error if the image could not be pulled, even if the image is present locally. +|When the option is specified or set, pull the image. Raise an error if the image could not be pulled, even if the image is present locally. -If the option is disabled (with `false`) or not specified, pull the image from the registry only if the image is not present locally. Raise an error if the image is not found in the registries and is not present locally. - -When this option is specified _and_ `pullAlways` is also specified, builds will fail as Podman does not support both options to be enabled at the same time. +If the option is disabled (with `never`) or not specified, pull the image from the registry only if the image is not present locally. Raise an error if the image is not found in the registries and is not present locally. **Default value is**: `null` (not specified). -**See**: https://docs.podman.io/en/latest/markdown/podman-build.1.html - -|pullAlways -|Pull the image from the first registry it is found in as listed in registries.conf. Raise an error if not found in the registries, even if the image is present locally. - -When this option is specified _and_ `pullAlways` is also specified, builds will fail as Podman does not support both options to be enabled at the same time. +**Supported values are:** ALWAYS, TRUE, MISSING, NEVER, FALSE, NEWER -**Default value is**: `null` (not specified). - -**See**: https://docs.podman.io/en/latest/markdown/podman-build.1.html +**See**: https://docs.podman.io/en/latest/markdown/podman-build.1.html#pull-policy |squash |Squash all of the image’s new layers into a single new layer; any preexisting layers are not squashed. @@ -152,8 +143,7 @@ Supported values are: your-image-name - true - false + always sampleTagValue From e1acd38c6fd9f2d14166759a53a9abd984ba461d Mon Sep 17 00:00:00 2001 From: Granie Laurent Date: Tue, 2 Apr 2024 18:16:03 +0200 Subject: [PATCH 4/5] Remove unused import --- .../config/skopeo/copy/TestSkopeoCopyConfigurationBuilder.java | 2 -- .../nl/lexemmens/podman/service/PodmanExecutorServiceTest.java | 1 - .../nl/lexemmens/podman/service/SecurityContextServiceTest.java | 2 -- .../nl/lexemmens/podman/service/SkopeoExecutorServiceTest.java | 1 - 4 files changed, 6 deletions(-) diff --git a/src/test/java/nl/lexemmens/podman/config/skopeo/copy/TestSkopeoCopyConfigurationBuilder.java b/src/test/java/nl/lexemmens/podman/config/skopeo/copy/TestSkopeoCopyConfigurationBuilder.java index 95b82ab1..4d74a7a6 100644 --- a/src/test/java/nl/lexemmens/podman/config/skopeo/copy/TestSkopeoCopyConfigurationBuilder.java +++ b/src/test/java/nl/lexemmens/podman/config/skopeo/copy/TestSkopeoCopyConfigurationBuilder.java @@ -2,8 +2,6 @@ import nl.lexemmens.podman.config.skopeo.TestSkopeoConfigurationBuilder; -import java.io.File; - public class TestSkopeoCopyConfigurationBuilder { private final TestSkopeoConfigurationBuilder parent; private final SkopeoCopyConfiguration copy; diff --git a/src/test/java/nl/lexemmens/podman/service/PodmanExecutorServiceTest.java b/src/test/java/nl/lexemmens/podman/service/PodmanExecutorServiceTest.java index 3f300ef0..cb99bafa 100644 --- a/src/test/java/nl/lexemmens/podman/service/PodmanExecutorServiceTest.java +++ b/src/test/java/nl/lexemmens/podman/service/PodmanExecutorServiceTest.java @@ -24,7 +24,6 @@ import org.zeroturnaround.exec.ProcessExecutor; import java.io.File; -import java.security.PublicKey; import java.util.*; import static nl.lexemmens.podman.enumeration.ContainerFormat.DOCKER; diff --git a/src/test/java/nl/lexemmens/podman/service/SecurityContextServiceTest.java b/src/test/java/nl/lexemmens/podman/service/SecurityContextServiceTest.java index f6000717..b91bdcb1 100644 --- a/src/test/java/nl/lexemmens/podman/service/SecurityContextServiceTest.java +++ b/src/test/java/nl/lexemmens/podman/service/SecurityContextServiceTest.java @@ -2,8 +2,6 @@ import nl.lexemmens.podman.config.podman.PodmanConfiguration; import nl.lexemmens.podman.config.podman.TestPodmanConfigurationBuilder; -import nl.lexemmens.podman.config.skopeo.SkopeoConfiguration; -import nl.lexemmens.podman.config.skopeo.TestSkopeoConfigurationBuilder; import nl.lexemmens.podman.executor.CommandExecutorDelegate; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; diff --git a/src/test/java/nl/lexemmens/podman/service/SkopeoExecutorServiceTest.java b/src/test/java/nl/lexemmens/podman/service/SkopeoExecutorServiceTest.java index 84bce5a8..15e7131d 100644 --- a/src/test/java/nl/lexemmens/podman/service/SkopeoExecutorServiceTest.java +++ b/src/test/java/nl/lexemmens/podman/service/SkopeoExecutorServiceTest.java @@ -15,7 +15,6 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.zeroturnaround.exec.ProcessExecutor; -import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; From ec329ce40faf9290f1aa10de9b838c0514221e7a Mon Sep 17 00:00:00 2001 From: Granie Laurent Date: Tue, 2 Apr 2024 18:31:12 +0200 Subject: [PATCH 5/5] Fix Sonar java:S1700 --- .../java/nl/lexemmens/podman/enumeration/PullPolicy.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/nl/lexemmens/podman/enumeration/PullPolicy.java b/src/main/java/nl/lexemmens/podman/enumeration/PullPolicy.java index def0e585..161ab5ff 100644 --- a/src/main/java/nl/lexemmens/podman/enumeration/PullPolicy.java +++ b/src/main/java/nl/lexemmens/podman/enumeration/PullPolicy.java @@ -28,14 +28,14 @@ public enum PullPolicy { */ NEWER("newer"); - private final String pullPolicy; + private final String value; /** * Constructor * @param pullPolicy The pullpolicy to set */ - PullPolicy(String pullPolicy) { - this.pullPolicy = pullPolicy; + PullPolicy(String value) { + this.value = value; } /** @@ -43,6 +43,6 @@ public enum PullPolicy { * @return the selected pullpolicy */ public String getValue() { - return pullPolicy; + return value; } }