@@ -63,7 +63,16 @@ extension Application {
6363 return
6464 }
6565
66- let resources = try await Self . buildResources ( images: images, containerSystemConfig: containerSystemConfig)
66+ let resources = await Self . buildResources (
67+ images: images,
68+ containerSystemConfig: containerSystemConfig,
69+ onError: { image, error in
70+ log. warning (
71+ " skipping unreadable image " ,
72+ metadata: [ " image " : " \( image. reference) " , " error " : " \( error) " ]
73+ )
74+ }
75+ )
6776
6877 try Output . render ( payload: resources, format: format) {
6978 if verbose {
@@ -81,14 +90,34 @@ extension Application {
8190
8291 /// Builds the resource for each image, denormalizing the reference so the
8392 /// display name omits the default registry.
84- private static func buildResources( images: [ ClientImage ] , containerSystemConfig: ContainerSystemConfig ) async throws -> [ ImageResource ] {
85- var resources : [ ImageResource ] = [ ]
86- for image in images {
87- resources. append (
93+ private static func buildResources(
94+ images: [ ClientImage ] ,
95+ containerSystemConfig: ContainerSystemConfig ,
96+ onError: ( ClientImage , any Error ) -> Void
97+ ) async -> [ ImageResource ] {
98+ await collectReadableValues (
99+ from: images,
100+ resolve: { image in
88101 try await image. toImageResource ( containerSystemConfig: containerSystemConfig)
89- )
102+ } ,
103+ onError: onError
104+ )
105+ }
106+
107+ static func collectReadableValues< Input, Value> (
108+ from inputs: [ Input ] ,
109+ resolve: ( Input ) async throws -> Value ,
110+ onError: ( Input , any Error ) -> Void
111+ ) async -> [ Value ] {
112+ var values : [ Value ] = [ ]
113+ for input in inputs {
114+ do {
115+ values. append ( try await resolve ( input) )
116+ } catch {
117+ onError ( input, error)
118+ }
90119 }
91- return resources
120+ return values
92121 }
93122 }
94123}
0 commit comments