[plugin] Refactor lambda-build packaging into a pluggable ArchiveBackend (ZIP today, OCI-ready)#681
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces a pluggable archive backend abstraction for
lambda-build, mirroringthe existing build-backend design (#679). Packaging the built binaries into a
deployable artifact was hard-coded to ZIP inside
Builder.swift; it is now behindan
ArchiveBackendprotocol with one implementation today (ZIP, the existing codemoved verbatim) and a stubbed seam for OCI images in the future.
Internal refactor: the default behaviour is unchanged (ZIP), no public Swift API
changes, and the output ZIP layout / path is identical.
What changed
ArchiveBackendprotocol (ArchiveBackends/ArchiveBackend.swift) — owns whatkind of artifact is produced from the built binaries. It's the packaging
counterpart to
BuildBackend(which owns how the binaries are built);Builderselects and sequences the two.
ZipArchiveBackend(ArchiveBackends/ZipArchiveBackend.swift) — the existingBuilder.package(...)body, moved unchanged, withzipToolPathinjected via init.ArchiveFormatenum (ArchiveFormat.swift) — the parsed--archive-formatvalue (
zip|oci), mirroringCrossCompileMethod:parse(...)(defaults tozip, case-insensitive),isSupported(oci→ false), and a newBuilderErrors.unsupportedArchiveFormatcase.--archive-format zip|ociflag — parsed intoBuilderConfiguration, with amakeArchiveBackend()factory (following the same on-configuration factoryconvention as
makeCrossCompileBackend()).ociis recognised but throws a"not yet supported" error. Help text and the verbose config dump updated.
Builder.build(...)now ends withconfiguration.makeArchiveBackend().archive(...)instead of the inline
package(...)method (which is removed).Backends/→BuildBackends/, so the two families read asparallel siblings:
BuildBackends/andArchiveBackends/.Adding OCI later
Add
OCIArchiveBackend: ArchiveBackendunderArchiveBackends/, then flip theocicase in
ArchiveFormat.isSupportedandmakeArchiveBackend(). No other changes.Testing
ArchiveBackendTests.swift:ArchiveFormat.parse(default/case-insensitive/oci-unsupported/unknown),
makeArchiveBackend()selection (zip →ZipArchiveBackend),and
ZipArchiveBackend.archiverun against a temp build dir asserting the.zipandrelocated
bootstrapare produced.AWSLambdaPluginHelperTestspass (90 tests);swift buildandswift format lint --strictclean.--archive-format ocifails fast with the stub error; zip/defaultproduce a byte-for-byte identical artifact to before.