Skip to content
Merged
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
8 changes: 3 additions & 5 deletions Sources/ContainerClient/Archiver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ public final class Archiver: Sendable {
try fileManager.createDirectory(at: directory, withIntermediateDirectories: true)

guard
let enumerator = FileManager.default.enumerator(
at: source,
includingPropertiesForKeys: [.isDirectoryKey, .isRegularFileKey, .isSymbolicLinkKey]
)
let enumerator = FileManager.default.enumerator(atPath: source.path)
else {
throw Error.fileDoesNotExist(source)
}
Expand All @@ -74,7 +71,8 @@ public final class Archiver: Sendable {
entryInfo.append(info)
}
} else {
while let url = enumerator.nextObject() as? URL {
while let relPath = enumerator.nextObject() as? String {
let url = source.appending(path: relPath).standardizedFileURL
guard let info = closure(url) else {
continue
}
Expand Down
21 changes: 21 additions & 0 deletions Tests/CLITests/Subcommands/Build/CLIBuilderTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,27 @@ extension TestCLIBuildBase {
#expect(try self.inspectImage(newImageName) == newImageName, "expected to have successfully built \(newImageName)")
}

@Test func testBuildAddFromSpecialDirs() throws {
let tempDir = URL(filePath: "/tmp/container/.clitests" + testUUID)
try! FileManager.default.createDirectory(at: tempDir, withIntermediateDirectories: true)

defer {
try! FileManager.default.removeItem(at: tempDir)
}

let dockerfile: String =
"""
FROM scratch

ADD emptyFile /
"""
let context: [FileSystemEntry] = [.file("emptyFile", content: .zeroFilled(size: 1))]
try createContext(tempDir: tempDir, dockerfile: dockerfile, context: context)
let imageName = "registry.local/scratch-add-special-dir:\(UUID().uuidString)"
try self.build(tag: imageName, tempDir: tempDir)
#expect(try self.inspectImage(imageName) == imageName, "expected to have successfully built \(imageName)")
}

@Test func testBuildScratchAdd() throws {
let tempDir: URL = try createTempDir()
let dockerfile: String =
Expand Down