-
Notifications
You must be signed in to change notification settings - Fork 379
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
manifest: introduce internal/manifest
with private types and freeze public manifest.List
#1791
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you prototype this a bit further, please?
In a new commit, add a do-nothing method to internal/manifest.List
, and call it from copy.Image
. Build the necessary infrastructure to do that; ensure that the new method can not be called via c/image/manifest.ListFromBlob
; and then remove that do-nothing method.
In particular, I expect that will require at least creating internal/manifest.OCI1Index
and internal/manifest.Schema2List
; and that, in turn, might require moving quite a bit more types/constants/variables from manifest
to internal/manifest
.
The goal of this is to do all of the refactoring in this PR, so that the Zstd PR can just add a method without any more refactoring.
I guess the NonImageArtifactError
type might need to be moved into a separate subpackage. Or, alternatively, move almost all of the implementation of c/image/manifest
to internal/manifest
, so that internal/manifest
has never a reason to call the public one.
On second thought — callers that explicitly cast are not interesting; those deserve any breakage they get. But the new method should not be directly visible in the API (i.e. it should not be a public method on a publicly visible |
@mtrmac Do you have any priority on these two suggested solution ? Like which one do you think could be better so I can do that part. IMO maybe moving all of the OTOH |
I was thinking that the public My hunch is to try moving the |
Edit: Please ignore this comment , i think i got some idea. |
22fe467
to
7cd6888
Compare
@mtrmac PTAL I think this is what you meant, I have also added a |
(This is not a review nor a request for any change, just a note about Go language features at this point.)
type OCI1 = internalPackage.OCI1Public. Compare e.g. |
Thinking back to the goals of this infrastructure:
This PR works fine for the first point; but looking at the second two
That’s a bit awkward to do with the current internal → public dependency direction. It would require moving the actual implementation logic into a third The net effect of that would be … so I think it would actually be much simpler to reverse the dependency:
Does that make sense? I think this would work and do everything necessary, but I didn’t actually do the work so I’m not 100% sure there isn‘t a snag. |
Actually that can just be a package-private |
7cd6888
to
29e066c
Compare
@mtrmac PTAL I agree moving everything to internal is much better. Also I have kept naming scheme as Also added a dummy commit to show how private API can be extended. |
internal/manifest.List
and freeze public manifest.List
internal/manifest
with private types and freeze public manifest.List
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point let’s just discuss it, please don’t immediately make changes:
Is there a dependency that forces us to move the non-multi arch implementations as well?
Also I have kept naming scheme as
OCI1Index
andOCI1IndexInternal
for consistency with other packages
We don’t really have that precedent AFAICS.
and it automatically explains that the one with suffix
Internal
is the private type while other is public.
The way I think about this is, most of the c/image code is going to use the internal API so saying “internal” all over the place is not particularly useful. Pointing out public parts of an otherwise-nonpublic API might be a thing to pay attention to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Toying with https://github.com/mtrmac/image/tree/list-experiment (which is by no means complete), it does seem that we don’t actually need to move the non-multi-arch types. The only real dependency is a FromBlob
in list_test.go
, which can be avoided by keeping the original test in manifest
, and dropping that one test part from a copy in internal/manifest
.
So, yes, I’d prefer minimizing the churn and dealing with only the two multi-arch objects.
29e066c
to
6d35306
Compare
@mtrmac I was playing with your branch it correctly moves the two needed types and leaving everything else intact, what do else is left which you think is missing from that and needs to be done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that the structure works overall … so just a final cleanup:
- Explicitly note, everywhere, which symbols in
internal/manifest
are publicly visible - Add individual documentation to the new symbols, and update documentation of the old symbols
- Keep the existing tests in
c/image/manifest
f23e045
to
fab48e8
Compare
@mtrmac PTAL again, I'll drop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please add the “This is publicly available” comments to all such top-level items. Both data types like
Schema2PlatformSpec
and functions likeMatchesDigest
- I’m afraid there was recently some churn on the main branch to benefit from Go 1.18, the recent rebase of this branch is reverting some of those. Please update. (FWIW that can be compared using e.g things like
git diff {upstream/main:,other-branch:internal/}manifest/oci_index_test.go
). - The second commit can be dropped now; we have proven the architecture out already, so let’s avoid another review iteration.
Similarly #1824 has a small intersection with this PR. I’m sorry about that hassle, it was necessary to allow building with Go 1.20 and enabling other work. |
8547b96
to
317d79b
Compare
317d79b
to
fe7cdae
Compare
fe7cdae
to
7ccdecb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more comment updates, please.
LGTM aftewards, feel free to merge after tests pass.
7ccdecb
to
e44f803
Compare
…t.List Flips dependency of internal and public manifest.List API and introduces private manifest.List API which will be extended in future for new features. [NO NEW TESTS NEEDED] [NO TESTS NEEDED] Signed-off-by: Aditya R <[email protected]>
e44f803
to
8a1955b
Compare
@vrothberg @giuseppe @mtrmac PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@flouthoc Thanks! |
Flips dependency of internal and public manifest.List API and introduces private manifest.List API which will be extended in future for new features.