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
24 changes: 21 additions & 3 deletions Sources/ContainerBuild/BuildImageResolver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ import ContainerizationOCI
import Foundation
import GRPC
import Logging
import TerminalProgress

struct BuildImageResolver: BuildPipelineHandler {
let contentStore: ContentStore
let quiet: Bool
let output: FileHandle

public init(_ contentStore: ContentStore) throws {
public init(_ contentStore: ContentStore, quiet: Bool = false, output: FileHandle = FileHandle.standardError) throws {
self.contentStore = contentStore
self.quiet = quiet
self.output = output
}

func accept(_ packet: ServerStream) throws -> Bool {
Expand Down Expand Up @@ -54,8 +59,21 @@ struct BuildImageResolver: BuildPipelineHandler {
}

let img = try await {
guard let img = try? await ClientImage.pull(reference: ref, platform: platform) else {
return try await ClientImage.fetch(reference: ref, platform: platform)
let progressConfig = try ProgressConfig(
terminal: self.output,
description: "Pulling \(ref)",
showPercent: true,
showProgressBar: true,
showSize: true,
showSpeed: true,
disableProgressUpdates: self.quiet
)
let progress = ProgressBar(config: progressConfig)
defer { progress.finish() }
progress.start()

guard let img = try? await ClientImage.pull(reference: ref, platform: platform, progressUpdate: progress.handler) else {
return try await ClientImage.fetch(reference: ref, platform: platform, progressUpdate: progress.handler)
}
return img
}()
Expand Down
2 changes: 1 addition & 1 deletion Sources/ContainerBuild/BuildPipelineHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public actor BuildPipeline {
[
try BuildFSSync(URL(filePath: config.contextDir)),
try BuildRemoteContentProxy(config.contentStore),
try BuildImageResolver(config.contentStore),
try BuildImageResolver(config.contentStore, quiet: config.quiet, output: config.terminal?.handle ?? FileHandle.standardError),
try BuildStdio(quiet: config.quiet, output: config.terminal?.handle ?? FileHandle.standardError),
]
}
Expand Down