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

Refactor data passing in c/image/copy #2048

Merged
merged 23 commits into from
Jul 19, 2023
Merged

Conversation

mtrmac
Copy link
Collaborator

@mtrmac mtrmac commented Jul 19, 2023

This is motivated by the concurrent Zstd work, to make it more maintainable to pass data from and to copySingleImage.

  • Add copier.options, copier.policyContext and copier.unparsedToplevel instead of passing them around in parameters
  • Eliminate fields of copier and imageCopier that are now reachable through .options
  • Return a copySingleImageResult from copySingleImage

@flouthoc I realize this is disruptive, and I want to do whatever necessary not to disrupt or slow down your work. Let me know what works for you — feel free to completely ignore this (and I’ll rebase this later as necessary), to reimplement parts yourself in some other way, or to tell me to split this up (maybe only the copySingleImageResult part?).

Others: Please don’t merge this without an ACK from @flouthoc .

mtrmac added 23 commits July 19, 2023 01:20
- Generally I discourage unsing named return values, it's easy
  to miss that it wasn't set
- I have no idea what the "in the middle of a multi-streamed copy"
  paragraph refers to.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... so that we don't have to carry it around in extra
parameters. Migrating individual functions will follow.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... so that we can eliminate three parameters.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... so that the code looks the same here and in possible callees.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Use options.Progress and ProgressInterval directly.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Use c.options.OciDecryptConfig directly.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Use c.options.OciEncryptConfig directly.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Use c.options.DownloadForeignLayers directly.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Use ic.c.options.OciEncryptLayers directly.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
So that we don't need to pass it around in a parameter.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Use copier.unparsedToplevel now that it exists.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... so that we don't need to carry it around in parameters.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
It is no longer used.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... so that we don't have so many unnamed return values, and
we can manage the return values as a batch.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
…sult on a match

... so that the caller doesn't have to assemble it. Using a pointer-or-nil eliminates
a separate boolean.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... instead of three separate ones.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
@flouthoc
Copy link
Contributor

flouthoc commented Jul 19, 2023

This LGTM I'll rebase my PR on top of this. I don't have merge access.

@flouthoc
Copy link
Contributor

@vrothberg Could you PTAL

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Very nice refactor and with surgical precision :)

LGTM

@vrothberg vrothberg merged commit b739592 into containers:main Jul 19, 2023
9 checks passed
@mtrmac mtrmac deleted the copy-single-api branch July 19, 2023 18:25
flouthoc added a commit to flouthoc/image that referenced this pull request Jul 21, 2023
After containers#2048 there is no room for copy/multiple to pass custom compressionFormat to copySingleImage
while processing each instance, following PR introduces that functionality again and wraps options
to simpler struct.

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/image that referenced this pull request Jul 21, 2023
After containers#2048 there is no room for copy/multiple to pass custom compressionFormat to copySingleImage
while processing each instance, following PR introduces that functionality again and wraps options
to simpler struct.

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/image that referenced this pull request Jul 21, 2023
After containers#2048 there is no room for copy/multiple to pass custom compressionFormat to copySingleImage
while processing each instance, following PR introduces that functionality again and wraps options
to simpler struct.

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/image that referenced this pull request Jul 21, 2023
After containers#2048 there is no room for copy/multiple to pass custom compressionFormat to copySingleImage
while processing each instance, following PR introduces that functionality again and wraps options
to simpler struct.

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/image that referenced this pull request Aug 4, 2023
After containers#2048 there is no room for copy/multiple to pass custom compressionFormat to copySingleImage
while processing each instance, following PR introduces that functionality again and wraps options
to simpler struct.

Signed-off-by: Aditya R <arajan@redhat.com>
mtrmac pushed a commit to mtrmac/image that referenced this pull request Aug 4, 2023
After containers#2048 there is no room for copy/multiple to pass custom compressionFormat to copySingleImage
while processing each instance, following PR introduces that functionality again and wraps options
to simpler struct.

Signed-off-by: Aditya R <arajan@redhat.com>
mtrmac pushed a commit to mtrmac/image that referenced this pull request Aug 5, 2023
After containers#2048 there is no room for copy/multiple to pass custom compressionFormat to copySingleImage
while processing each instance, following PR introduces that functionality again and wraps options
to simpler struct.

Signed-off-by: Aditya R <arajan@redhat.com>
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.

3 participants