Fix container machine setup script being dropped from artifact.#1891
Open
anxkhn wants to merge 1 commit into
Open
Fix container machine setup script being dropped from artifact.#1891anxkhn wants to merge 1 commit into
anxkhn wants to merge 1 commit into
Conversation
When fetching container machine resources from an OCI artifact, the setup script layer was decoded separately and then merged into the config with `if var resources, let setupScript`. Because MachineResources is a value type, that binding mutated a throwaway copy, so the fetched setup script was silently discarded and the returned resources kept a nil setupScript. As a result MachineBundle fell back to the default create-user.sh instead of the per-image script. Merge through the optional so the script survives on the returned value, and add unit tests for the merge behavior.
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.
Files changed (3 files, +56 -3)
Sources/Services/MachineAPIService/Client/MachineClient.swiftReplace the inline
if var resources, let setupScript { ... }merge with a callto a new
static func merge(resources:setupScript:) -> MachineResources?thatassigns through the optional. Doc comment notes the value-type pitfall.
Package.swiftAdd a
MachineAPIClientTeststest target depending onMachineAPIClient(this target had no unit tests before, only VM-dependent integration tests).
Tests/MachineAPIClientTests/MachineClientMergeTests.swift(new)Three Swift Testing (
import Testing) regression tests. Carries the repo'scanonical Apache-2.0 license header (byte-identical to existing tracked files).