add support for local build output (#369)

Fixes https://github.com/apple/container/issues/354
This commit is contained in:
Sidhartha Mani
2025-07-23 15:59:28 -07:00
committed by GitHub
parent f0eda65a20
commit cc4a85bb09
5 changed files with 282 additions and 3 deletions
+11
View File
@@ -292,6 +292,17 @@ extension Application {
let tarURL = tempURL.appendingPathComponent("out.tar")
try FileManager.default.moveItem(at: tarURL, to: dest)
finalMessage = "Successfully exported to \(dest.absolutePath())"
case "local":
guard let dest = exp.destination else {
throw ContainerizationError(.invalidArgument, message: "dest is required \(exp.rawValue)")
}
let localDir = tempURL.appendingPathComponent("local")
guard FileManager.default.fileExists(atPath: localDir.path) else {
throw ContainerizationError(.invalidArgument, message: "expected local output not found")
}
try FileManager.default.copyItem(at: localDir, to: dest)
finalMessage = "Successfully exported to \(dest.absolutePath())"
default:
throw ContainerizationError(.invalidArgument, message: "invalid exporter \(exp.rawValue)")
}
+5 -1
View File
@@ -175,6 +175,10 @@ public struct Builder: Sendable {
if destinationValue == nil {
throw Builder.Error.invalidExport(input, "dest field is required")
}
case "local":
if destinationValue == nil {
throw Builder.Error.invalidExport(input, "dest field is required")
}
default:
throw Builder.Error.invalidExport(input, "unsupported output type")
}
@@ -187,7 +191,7 @@ public struct Builder: Sendable {
var components = ["type=\(type)"]
switch type {
case "oci", "tar":
case "oci", "tar", "local":
break // ignore destination
default:
throw Builder.Error.invalidExport(rawValue, "unsupported output type")