-
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
Use a SourcedImage struct in c/image/copy #1578
Commits on Jun 14, 2022
-
Have image.FromUnparsedImage return a SourcedImage instead of types.I…
…mage This will allow us to add more methods to SourcedImage without breaking external implementations of types.Image, if any. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Configuration menu - View commit details
-
Copy full SHA for 0cf416b - Browse repository at this point
Copy the full SHA 0cf416bView commit details -
Make SourcedImage.{ManifestBlob,ManifestMIMEType} public
We know these values are available without having to worry about errors, which allows simplifying users in c/image/copy. We don't really need accessor functions, all users are internal (and a public field is actually better protected than a public method, because a public method can be used by third parties through a caller-defined interface). It's also usefo to make them available as individual values; various users only need one or the other. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Configuration menu - View commit details
-
Copy full SHA for 2874e99 - Browse repository at this point
Copy the full SHA 2874e99View commit details -
Introduce manifestConversionPlan
To make determineManifestConversion easier to test, we'll want to separate it from imageCopier and make it a pure function. To do that, start with introducing a struct for its return value; that way we won't need three unnamed return values, and three variables with long names at the call site. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Configuration menu - View commit details
-
Copy full SHA for cba0127 - Browse repository at this point
Copy the full SHA cba0127View commit details -
Move the manifest conversion setup out of determineManifestConversion
Have determineManifestConversion just set a flag in the returned plan; then copier.copyOneImage will actually act on that flag. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Configuration menu - View commit details
-
Copy full SHA for 225269f - Browse repository at this point
Copy the full SHA 225269fView commit details -
Use manifestConversionPlan for expected results in TestDetermineManif…
…estConversion This is not smaller, but a bit more readable and consistent with the real call site. Also, on test failures we can see the full returned plan as a single unit, making it possibly easier to see what went wrong. Should not change (test) behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Configuration menu - View commit details
-
Copy full SHA for e117048 - Browse repository at this point
Copy the full SHA e117048View commit details -
Introduce determineManifestConversionInputs
... and split the actual logic (determineManifestConversion) from imageCopier (imageCopier.determineManifestConversion). determineManifestConversion is now a pure function (well, apart from logging). Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Configuration menu - View commit details
-
Copy full SHA for f395eeb - Browse repository at this point
Copy the full SHA f395eebView commit details -
Mostly test the pure function in TestDetermineManifestConversion
Keep the "reading manifest failed" case, for now. Should not change (test) behavior, except that the test coverage is now a tiny bit smaller - but then the test not depending on imageCopier is the primary reason for this refactoring. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Configuration menu - View commit details
-
Copy full SHA for 7602cbd - Browse repository at this point
Copy the full SHA 7602cbdView commit details -
Record an *image.SourcedImage in imageCopier.src
This is surprisingly somewhat convoluted. We've had to do a bunch of work to make determineManifestConversion not depend on a complete (and mostly valid!) image, to be able to make this change. Then, so that we don't lose test coverage (and to actually benefit from the new private type), use SourcedImage.ManifestMIMEType in imageCopier.determineManifestConversion. That allows us to get rid of the last imageCopier.determineManifestConversion call in tests. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Configuration menu - View commit details
-
Copy full SHA for cce475b - Browse repository at this point
Copy the full SHA cce475bView commit details -
Use StoredImage.StoredManifest() where appropriate
This eliminates some unreachable error paths. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Configuration menu - View commit details
-
Copy full SHA for f074600 - Browse repository at this point
Copy the full SHA f074600View commit details -
Inline imageCopier.determineManifestConversion into the caller
It's now basically a trivial call forwarder we don't need for anything, so just have the caller set determineManifestConversionInputs directly (and let it benefit from labeling the inputs). Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Configuration menu - View commit details
-
Copy full SHA for acbde71 - Browse repository at this point
Copy the full SHA acbde71View commit details