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

#305 cleanup #416

Merged
merged 12 commits into from
Mar 15, 2018
Merged

#305 cleanup #416

merged 12 commits into from
Mar 15, 2018

Conversation

mtrmac
Copy link
Collaborator

@mtrmac mtrmac commented Feb 13, 2018

This is a set of quite independent cleanups and minor bug fixes on top of #305 . Notably resolves #413, and adds tests for the schema1 code to decrease risk of similar breakage in the future.

See individual commit messages for more details. I’ll be happy to break this up into several PRs if any part needs more discussion than others.

Cc: @nalind

  • Simplify types.Image.Inspect call chain
  • Make ImageInspectInfo.Created optional
  • Move LayerInfosForCopy from UnparsedImage to Image/sourcedImage
  • Populate labels in manifest.Schema1.Inspect
  • Clean up manifest types
  • Return "" in computeID for unknown manifest types
  • Instead of a type switch + cast + error, let the type switch do the conversion
  • Rename manifest.Schema1.ToSchema2 to ToSchema2Config
  • Load a *storage.Image only once in storageImageSource
  • Drop unused storageImageDestination.{image,systemContext}
  • Create a new slice in Schema1.UpdateLayerInfos
  • Add tests for image.manifestSchema1

@mtrmac
Copy link
Collaborator Author

mtrmac commented Feb 13, 2018

This breaks API, so tests are going to fail; corresponding skopeo PR is containers/skopeo#477 .

@mtrmac mtrmac force-pushed the 305-cleanup branch 2 times, most recently from d883d69 to c4cdaa4 Compare February 27, 2018 12:44
mtrmac added 12 commits March 9, 2018 05:35
Now that inspectManifest only forwards the call to
genericManifest.imageInspectInfo, simplify the call chain from
{memoryImage,sourcedImage}.Inspect→inspectManifest→genericManifest.imageInspectInfo
to genericManifest.Inspect directly (via embedding genericManifest into
{memoryImage,sourcedImage}).

Signed-off-by: Miloslav Trmač <[email protected]>
... instead of inventing a nonsensical value if the field is missing in OCI
images.

Signed-off-by: Miloslav Trmač <[email protected]>
The whole purpose of UnparsedImage is to not parse the manifest,
so having this interface which more or less requires the manifest to be
parsed and recomputed is not desirable.

sourcedImage now uses ImageSource.LayerInfosForCopy via the private
UnparsedImage.src, which is a bit ugly, but that dependency has already
existed, and we get a more consistent public API for this price.

Signed-off-by: Miloslav Trmač <[email protected]>
Drop unused private fields in types used only for JSON marshaling.

Use Schema2V1Image for the pre-1.8.3 reencoding, to mirror what
docker/docker does.  It is especially pointless to explicitly declare
extra fields to preserve when the immediately following code
removes all of them.

Signed-off-by: Miloslav Trmač <[email protected]>
... which is what the API contract says it should do, at least.

Signed-off-by: Miloslav Trmač <[email protected]>
... to avoid confusion with image.manifestSchema1.convertToManifestSchema2

Signed-off-by: Miloslav Trmač <[email protected]>
... instead of reloading it in LayerInfosForCopy and getSize.

Alternatively, it seems we could just save the TopLayer field; this
is more generic.

AFAICT this should be equally safe in principle: any locking done in
the storage.Store loaders is unlocked by the time we get the
*storage.Image, so if anything can modify the unlocked *storage.Image
concurrently after this change, or make its fields invalid, the same
breakage can in principle happen before this change just as well,
"only" with a shorter window.

Signed-off-by: Miloslav Trmač <[email protected]>
Image.UpdatedImage is supposed to create a new instance which does not modify
the original, so Manifest.UpdateLayerInfos should not modify the original either.

Signed-off-by: Miloslav Trmač <[email protected]>
Not _quite_ comprehensive (notably not covering most failure cases),
but at least comparable with the schema2 and OCI tests.

Signed-off-by: Miloslav Trmač <[email protected]>
@mtrmac
Copy link
Collaborator Author

mtrmac commented Mar 9, 2018

@runcom ping

@runcom
Copy link
Member

runcom commented Mar 12, 2018

LGTM, @nalind please ack and I'll merge

Approved with PullApprove

}
if s1.Config != nil {
i.Labels = s1.Config.Labels
}
Copy link
Member

Choose a reason for hiding this comment

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

Does this leave i.Labels set to nil if the compat blob doesn't specify any labels?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

“A nil map is equivalent to an empty map except that no elements may be added.”, which seems acceptable here (and consistent with schema2).

@nalind
Copy link
Member

nalind commented Mar 13, 2018

One nit, otherwise LGTM.

@mtrmac
Copy link
Collaborator Author

mtrmac commented Mar 15, 2018

👍

Approved with PullApprove

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.

Regression in the returning of inspected labels
3 participants