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 manifest lists when referenced by sha256 #1811

Merged
merged 5 commits into from
Jun 28, 2019
Merged

Conversation

loosebazooka
Copy link
Member

@loosebazooka loosebazooka commented Jun 26, 2019

This PR adds support for manifest lists when referenced by sha256 as described in #1360

This PR:

  • does not allow the user to specify any platform information in their configuration.
  • will still delegate to the registry default when using a non-sha256 tag
  • also makes no changes to offline mode - that should be handled automatically

V22ManifestListTemplate manifestListTemplate =
registryClient.pullManifest("11-jre-slim", V22ManifestListTemplate.class);
Assert.assertEquals(2, manifestListTemplate.getSchemaVersion());
Assert.assertTrue(manifestListTemplate.getDigestsForPlatform("amd64", "linux").size() > 0);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe check for another platform too?

@@ -118,10 +125,6 @@ private T getManifestTemplateFromJson(String jsonString)
throw new UnknownManifestFormatException("Cannot find field 'schemaVersion' in manifest");
}

if (!manifestTemplateClass.equals(ManifestTemplate.class)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This code would unsafely create template objects that didn't first validate schema and mediatype. So now we always validate the value and then create the objects. Any mismatch will trigger a ClassCastException (indicating programming error or registry error).

Copy link
Member

Choose a reason for hiding this comment

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

I remember something. This is about whether the registry client API should support the usage of pullManifest(imageTag, templateClass): https://github.com/GoogleContainerTools/jib/blob/v1.3.0-maven/jib-core/src/main/java/com/google/cloud/tools/jib/registry/RegistryClient.java#L196-L197

Our plugins don't make use of it, but as an API, it may make sense to keep it.

If we remove this, we can actually clean up a lot more. From what I recall, ManfiestPuller won't need to accept the manifestTemplateClass argument.

Copy link
Member

Choose a reason for hiding this comment

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

And it makes sense to update this Javadoc too.

Copy link
Member Author

Choose a reason for hiding this comment

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

You can still verify that you're actually pulling something you wanted... in which case ManifestPuller should probably still accept a template class. Either way, I think we should do it in a new PR.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, we can do it later. (It is basically the question of whether we maintain the RegistryClient API surface in a sane manner. A library throwing a ClassCastException won't look nice. But we aren't even sure if we will ever release this as a library.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yeah, but a ClassCastException should only happen if something went horribly wrong.

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.

This looks good. Just some leftovers in testing. Also merge with master to resolve conflicts.

@loosebazooka loosebazooka merged commit 7b0406a into master Jun 28, 2019
@loosebazooka loosebazooka deleted the manifestList2 branch June 28, 2019 18:09
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