Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support listing multiple images to remove #1206

Conversation

marcospereira
Copy link
Contributor

@marcospereira marcospereira commented Nov 30, 2023

What?

Fixes #1190.

It allows users to list multiple images to remove.

How?

A new ListProperty allows users to set a list of the images they want to remove. The old property is maintained, but it will generate a warning if used and throw an error if used together with the list property.

Status

This is a WIP/draft for now. But I think it is close to be ready to merge.

@@ -38,6 +38,12 @@ jobs:
run: ./gradlew functionalTest
- name: Documentation tests
run: ./gradlew docTest
- name: Upload test reports
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's really no need to upload test results, as you can view them with the help of a build scan. The build scan link is available at the end of each workflow run, on success and on failure. I'd say remove this change.

@@ -23,5 +23,11 @@ jobs:
run: ./gradlew test
- name: Integration tests
run: ./gradlew integrationTest
- name: Upload test reports
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's really no need to upload test results, as you can view them with the help of a build scan. The build scan link is available at the end of each workflow run, on success and on failure. I'd say remove this change.

private final Property<Boolean> force = getProject().getObjects().property(Boolean.class);
private final Property<Boolean> noPrune = getProject().getObjects().property(Boolean.class);

private final ListProperty<String> images = getProject().getObjects().listProperty(String.class);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a look at DockerPushImage. It does something similar.

* @param images the names or IDs of the images.
* @see #images(ListProperty)
*/
public void images(List<String> images) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will just need a method that returns a reference to the images field.

@Input
public final SetProperty<String> getImages() {
    return images;
}

this.images.set(images);
}

// Overriding methods to provide a warning message.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove all of those methods and extend from AbstractDockerRemoteApiTask instead. The parent class DockerExistingImage is really only meant for a single image reference.

@@ -42,6 +42,75 @@ class DockerRemoveImageFunctionalTest extends AbstractGroovyDslFunctionalTest {
!result.output.contains("repository")
}

def "can remove multiple images"() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll also want to change all documentation and test cases to use the new method instead.

}

task removeImages(type: DockerRemoveImage) {
dependsOn buildFirstImage
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We won't really need the dependsOn as you set an implicit dependency by assigning the image references (the output of DockerBuildImage tasks) to the input field images.

@marcospereira
Copy link
Contributor Author

Thanks for the review, @bmuschko. I got busy and haven't had the time to finish this, but your comments will definitely help to get this done later. :-)

@bmuschko
Copy link
Owner

bmuschko commented Jan 9, 2024

I am going to close this issue. We can reopen if you or someone else is planning to continue working on this change.

@bmuschko bmuschko closed this Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove multiple images at once
2 participants