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

Keep duplicate layers to match history #1017

Merged
merged 2 commits into from
Sep 20, 2018
Merged

Keep duplicate layers to match history #1017

merged 2 commits into from
Sep 20, 2018

Conversation

briandealwis
Copy link
Member

Fixes #991

Copy link
Member

@chanseokoh chanseokoh left a comment

Choose a reason for hiding this comment

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

I feel like this will work, but punting to @coollog for final check.

@@ -34,7 +34,7 @@
static class Builder {

private final ImageLayers.Builder<CachedLayerWithMetadata> layersBuilder =
ImageLayers.builder();
ImageLayers.<CachedLayerWithMetadata>builder().removeDuplicates();
Copy link
Member

Choose a reason for hiding this comment

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

Is <CachedLayerWithMetadata> necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, get compiler errors otherwise as it resolves to ImageLayers<Layer>.

public ImageLayers<T> build() {
return new ImageLayers<>(ImmutableList.copyOf(layers), layerDigestsBuilder.build());
ImmutableList<T> layers;
Copy link
Member

Choose a reason for hiding this comment

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

What if we remove this variable assignment and push return into each branch of if? Disregard my comment if it won't look any better though.

@chanseokoh
Copy link
Member

Also add a bug fix entry in CHANGELOG.

Copy link
Contributor

@coollog coollog left a comment

Choose a reason for hiding this comment

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

I'm thinking maybe ImageLayers.Builder should be instantiated with removeDuplicates as true or false via ImageLayers.builder(boolean removeDuplcates) so that it does add differently based on the value of removeDuplicates rather than having ImageLayers reconstruct a LinkedHashSet for the removeDuplicates=true case.

@briandealwis
Copy link
Member Author

briandealwis commented Sep 20, 2018

I think it makes more sense to have the logic in build(), and it conceivably allows including other layer-combining strategies. Since the deduping is there (now) purely as a convenience for the cache's use, and may not be used in the new-cache, we should code it so that the expected case is easy.

Copy link
Contributor

@coollog coollog left a comment

Choose a reason for hiding this comment

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

Okay, that sounds good.

@briandealwis briandealwis merged commit 3e89e15 into master Sep 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants