10000 Descriptor: do not implement Describable interface by thaJeztah · Pull Request #3886 · distribution/distribution · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Descriptor: do not implement Describable interface #3886

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

Merged
merged 2 commits into from
Jul 16, 2024

Conversation

thaJeztah
Copy link
Member

Commit cb6f002 (#1268) implemented a generic Manifest interface to represent manifests in the registry and remove references to schema specific manifests.

As part of this refactor, the Describable interface was introduced, which allowed for a single ManifestBuilder interface to handle both schema1 and schema2 manifests. Implementations of Describable are generally objects which can be described, not simply descriptors, but for convenience, this interface was also implemented on Descriptor in 2ff77c0 (#1281).

This interface served its purpose, but no longer needed for most cases; schema2 (and OCI) descriptors do not need this method, making it only needed for schema1.Reference, which is now deprecated.

Requiring this interface to be implemented limits interoperability between distribution's Descriptor and the OCI Descriptor types, which are identical in every other way, except for the presence of the Describable interface.

This patch:

  • Removes the Descriptor.Descriptor() method (no longer implementing the Describable interface).
  • Updates ManifestBuilder interface and implementations to accept either a Descriptor, a Describable, or (for schema1), a schema1.Reference.

@codecov-commenter
Copy link
codecov-commenter commented Apr 30, 2023

Codecov Report

Patch coverage: 51.61% and project coverage change: -0.06 ⚠️

Comparison is base (29b5e79) 56.63% compared to head (4b146db) 56.58%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3886      +/-   ##
==========================================
- Coverage   56.63%   56.58%   -0.06%     
==========================================
  Files         106      106              
  Lines       10674    10696      +22     
==========================================
+ Hits         6045     6052       +7     
- Misses       3955     3967      +12     
- Partials      674      677       +3     
Impacted Files Coverage Δ
manifest/schema1/config_builder.go 69.94% <44.44%> (-1.71%) ⬇️
manifest/ocischema/builder.go 62.29% <50.00%> (-3.75%) ⬇️
manifest/schema2/builder.go 66.00% <50.00%> (-5.43%) ⬇️
manifest/schema1/reference_builder.go 94.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member
@milosgajdos milosgajdos left a comment

Choose a reason for hiding this comment

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

LGTM, but we need to deprecate Schema 1 images soon.

@milosgajdos milosgajdos requested a review from corhere May 1, 2023 08:25
@corhere
Copy link
Collaborator
corhere commented May 1, 2023

Requiring this interface to be implemented limits interoperability between distribution's Descriptor and the OCI Descriptor types, which are identical in every other way, except for the presence of the Describable interface.

Could you please elaborate? I don't see how deleting a method improves interoperability. distribution.Descriptor is a concrete type and the changed code type-asserts to that very concrete type so OCI Descriptor types would not be useable anyway.

@thaJeztah
Copy link
Member Author

@corhere perhaps poor choice of words; see #3888

Copy link
Collaborator
@corhere corhere left a comment

Choose a reason for hiding this comment

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

Do the AppendReference methods need to accept both a Describable and a Descriptor? Callers holding a Describable value (only schema1.Reference?) could always convert it to a Descriptor themselves.

builder.AppendReference(describable.Descriptor())

And as far as I can tell, the ManifestBuilder interface is not needed. If we were to throw away that interface, the builders could accept the concrete types directly.

@davidspek
Copy link
Collaborator

Since schema1 is in the process of being removed is this PR still relevant?

@milosgajdos
Copy link
Member

Can you rebase @thaJeztah

@thaJeztah thaJeztah force-pushed the remove_describable branch from 6b7a5a5 to e22d113 Compare July 16, 2024 08:17
@milosgajdos milosgajdos requested a review from corhere July 16, 2024 08:22
corhere and others added 2 commits July 16, 2024 11:16
Defining an interface on the implementer side is generally not best
practice in Go code. There is no code in the distribution module which
consumes a ManifestBuilder value so there is no need to define the
interface in the distribution module. Export the concrete
ManifestBuilder types and modify the constructors to return concrete
values.

Co-authored-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Cory Snider <csnider@mirantis.com>
Commit cb6f002 implemented a generic
Manifest interface to represent manifests in the registry and remove
references to schema specific manifests.

As part of this refactor, the Describable interface was introduced,
which allowed for a single ManifestBuilder interface to handle both
schema1 and schema2 manifests. Implementations of Describable are
generally objects which can be described, not simply descriptors, but
for convenience, this interface was also implemented on Descriptor in
2ff77c0.

This interface served its purpose, but no longer needed for most cases;
schema2 (and OCI) descriptors do not need this method, making it only
needed for `schema1.Reference`, which is now deprecated.

Requiring this interface to be implemented limits interoperability
between distribution's Descriptor and the OCI Descriptor types, which
are identical in every other way, except for the presence of the
Describable interface.

This patch:

- Removes the `Descriptor.Descriptor()` method (no longer implementing
  the `Describable` interface).
- Updates ManifestBuilder interface and implementations to accept either
- Updates ManifestBuilder interface and implementations to accept a
  `Descriptor`.

After this patch, the caller is responsible for changing a describable
type into a descriptor;

    builder.AppendReference(describable.Descriptor())

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
Copy link
Member Author

@corhere Squashed that last commit, and I included your commit to remove the ManifestBuilder interface altogether; I had to slightly modify if now that Schema1 was removed

And as far as I can tell, the ManifestBuilder interface is not needed. If we were to throw away that interface, the builders could accept the concrete types directly.

@milosgajdos milosgajdos merged commit 54cf416 into distribution:main Jul 16, 2024
16 checks passed
@thaJeztah thaJeztah deleted the remove_describable branch July 16, 2024 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0