Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Sources/CLI/Image/ImagePull.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ extension Application {
}

func run() async throws {
var p: Platform?
var p: Platform
if let platform {
p = try Platform(from: platform)
} else {
p = Platform.current
}

let scheme = try RequestScheme(registry.scheme)
Expand Down
26 changes: 26 additions & 0 deletions Tests/CLITests/Subcommands/Images/TestCLIImages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,32 @@ extension TestCLIImagesCommand {
}
}

@Test func testPullDefaultPlatform() throws {
do {
// Use busybox for this test to avoid cache conflicts with other tests
let testImage = busybox

// Pull without specifying platform - should default to current platform
try doPull(imageName: testImage)

let output = try doInspectImages(image: testImage)
#expect(output.count == 1, "expected a single image inspect output, got \(output)")

// Verify only current platform was pulled
let variants = output[0].variants
#expect(variants.count == 1, "expected single platform variant, got \(variants.count)")

// On macOS, we expect either arm64 or amd64 depending on the hardware
let currentArch = variants[0].platform.architecture
let currentOS = variants[0].platform.os
#expect(currentOS == "linux", "expected linux OS, got \(currentOS)")
#expect(["arm64", "amd64"].contains(currentArch), "expected current platform architecture (arm64 or amd64), got \(currentArch)")
} catch {
Issue.record("failed to test default platform pulling \(error)")
return
}
}

@Test func testPullRemoveSingle() throws {
do {
try doPull(imageName: alpine)
Expand Down