Skip to content

Commit 43e7d4f

Browse files
committed
plugin: If a resource bundle is present, pass the path to containertool
Alternatively: check the target input file list for resource files.
1 parent 95077c6 commit 43e7d4f

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

Plugins/ContainerImageBuilder/main.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,18 @@ extension PluginError: CustomStringConvertible {
8989

9090
for built in builtExecutables { Diagnostics.remark("Built product: \(built.url.path)") }
9191

92+
let resources = builtExecutables[0].url
93+
.deletingLastPathComponent()
94+
.appendingPathComponent(
95+
"\(context.package.displayName)_\(productName).resources"
96+
)
97+
9298
// Run a command line helper to upload the image
93-
let helper = try context.tool(named: "containertool")
94-
let helperURL = helper.url
95-
let helperArgs = extractor.remainingArguments + builtExecutables.map { $0.url.path }
99+
let helperURL = try context.tool(named: "containertool").url
100+
let helperArgs =
101+
(FileManager.default.fileExists(atPath: resources.path) ? ["--resources", resources.path] : [])
102+
+ extractor.remainingArguments
103+
+ builtExecutables.map { $0.url.path }
96104
let helperEnv = ProcessInfo.processInfo.environment.filter { $0.key.starts(with: "CONTAINERTOOL_") }
97105

98106
let err = Pipe()

Sources/containertool/containertool.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,20 @@ enum AllowHTTP: String, ExpressibleByArgument, CaseIterable { case source, desti
152152

153153
// MARK: Upload resource layers
154154

155-
var resourceLayers: [RegistryClient.ImageLayer] = []
155+
typealias DiffID = String
156+
var resourceLayers: [(descriptor: ContentDescriptor, diffID: String)] = []
156157
for resourceDir in resources {
157-
let layer = try await destination.uploadLayer(
158+
let resourceTardiff = try Archive().appendingRecursively(atPath: resourceDir).bytes
159+
let resourceLayer = try await destination.uploadImageLayer(
158160
repository: destination_image.repository,
159-
contents: try Archive().appendingRecursively(atPath: resourceDir).bytes
161+
layer: resourceTardiff
160162
)
161163

162164
if verbose {
163-
log("resource layer: \(layer.descriptor.digest) (\(layer.descriptor.size) bytes)")
165+
log("resource layer: \(resourceLayer.digest) (\(resourceLayer.size) bytes)")
164166
}
165167

166-
resourceLayers.append(layer)
168+
resourceLayers.append((resourceLayer, digest(of: resourceTardiff)))
167169
}
168170

169171
// MARK: Upload the application layer
@@ -176,7 +178,6 @@ enum AllowHTTP: String, ExpressibleByArgument, CaseIterable { case source, desti
176178
}
177179

178180
// MARK: Create the application configuration
179-
180181
let timestamp = Date(timeIntervalSince1970: 0).ISO8601Format()
181182

182183
// Inherit the configuration of the base image - UID, GID, environment etc -

0 commit comments

Comments
 (0)