Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

Respect the tag specfied in the image name in removeImage #225

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/main/java/com/spotify/docker/RemoveImageMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.apache.maven.plugins.annotations.Parameter;

import java.io.IOException;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;

import static com.google.common.base.Strings.isNullOrEmpty;
Expand All @@ -51,20 +51,21 @@ public class RemoveImageMojo extends AbstractDockerMojo {
private String imageName;

/**
* Additional tags to tag the image with.
* Additional tags to remove.
*/
@Parameter(property = "dockerImageTags")
private List<String> imageTags;

protected void execute(final DockerClient docker)
throws MojoExecutionException, DockerException, IOException, InterruptedException {
final String imageNameWithoutTag = parseImageName(imageName)[0];
final String[] imageNameParts = parseImageName(imageName);
if (imageTags == null) {
imageTags = Collections.singletonList("");
imageTags = new ArrayList<>(1);
}
imageTags.add(imageNameParts[1]);

for (final String imageTag : imageTags) {
final String currImageName = imageNameWithoutTag +
final String currImageName = imageNameParts[0] +
((isNullOrEmpty(imageTag)) ? "" : (":" + imageTag));
getLog().info("Removing -f " + currImageName);

Expand Down