jib icon indicating copy to clipboard operation
jib copied to clipboard

Support pulling OCI Image Index manifests

Open rquinio opened this issue 1 year ago • 1 comments

Resolves #2749

Implementation follows https://github.com/GoogleContainerTools/jib/issues/3700#issuecomment-1171283502

  • Add Accept header application/vnd.oci.image.index.v1+json during base image pull
  • Re-use the logic from V22ManifestListTemplate to select the target platform diget via a new interface ManifestListTemplate

Before filing a pull request, make sure to do the following:

  • [x] Create a new issue at https://github.com/GoogleContainerTools/jib/issues/new/choose.
  • [x] Ensure that your implementation plan is approved by the team.
  • [x] Verify that integration tests and unit tests are passing after the change.
  • [x] Address all checkstyle issues. Refer to the style guide.

This helps to reduce the chance of having a pull request rejected.

rquinio avatar Jul 28 '22 20:07 rquinio

@rquinio Thank you; we'll review next week.

elefeint avatar Jul 29 '22 21:07 elefeint

No worries. Hopefully I've fixed the formatting issue.

rquinio avatar Aug 13 '22 11:08 rquinio

Done ! I also took the opportunity to fix missing coverage in PullBaseImageStep for manifest lists pulling and case where the target architecture is not in the list.

rquinio avatar Aug 20 '22 12:08 rquinio

Test failure:

> Task :jib-core:test

com.google.cloud.tools.jib.builder.steps.PullBaseImageStepTest > testCall_allMirrorsFail FAILED
    java.lang.NullPointerException
        at com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.pullBaseImages(PullBaseImageStep.java:296)
        at com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.call(PullBaseImageStep.java:159)
        at com.google.cloud.tools.jib.builder.steps.PullBaseImageStepTest.testCall_allMirrorsFail(PullBaseImageStepTest.java:571)

com.google.cloud.tools.jib.builder.steps.PullBaseImageStepTest STANDARD_OUT
    [MockitoHint] PullBaseImageStepTest.testCall_allMirrorsFail (see javadoc for MockitoHint):
    [MockitoHint] 1. Unused... -> at com.google.cloud.tools.jib.builder.steps.PullBaseImageStepTest.setUpWorkingRegistryClientFactoryWithV22ManifestList(PullBaseImageStepTest.java:672)
    [MockitoHint]  ...args ok? -> at com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.pullBaseImages(PullBaseImageStep.java:294)

elefeint avatar Aug 23 '22 14:08 elefeint

Should be fixed, testCall_allMirrorsFail was wrongly using the client factory with new V22ManifestList mocks, instead of the old V22ManifestTeplate mock.

rquinio avatar Aug 23 '22 20:08 rquinio

@rquinio Thank you! I'm afraid we need a bit more testing to pass the 80% coverage gate. OciIndexTemplate.ManifestDescriptorTemplate is likely an easy candidate. Can you see the Sonar report that's linked in "Details" under the Github Action checks?

elefeint avatar Aug 23 '22 22:08 elefeint

@elefeint I've added a test for POJO -> JSON serialization. I had a look at the code duplication, but I wouldn't risk factorizing the JSON objects between docker and OCI manifests as they have different fields, and I'm not sure of the details of each spec.

rquinio avatar Aug 24 '22 20:08 rquinio