@@ -25,10 +25,35 @@ public struct DestinationsBundle {
25
25
26
26
/// Mapping of artifact IDs to variants available for a corresponding artifact.
27
27
public fileprivate( set) var artifacts = [ String: [ Variant] ] ( )
28
+
29
+ /// Parses metadata of an `.artifactbundle` and validates it as a bundle containing
30
+ /// cross-compilation destinations.
31
+ /// - Parameters:
32
+ /// - bundlePath: path to the bundle root directory.
33
+ /// - fileSystem: filesystem containing the bundle.
34
+ /// - observabilityScope: observability scope to log validation warnings.
35
+ /// - Returns: Validated `DestinationsBundle` containing validated `Destination` values for
36
+ /// each artifact and its variants.
37
+ public static func parseAndValidate(
38
+ bundlePath: AbsolutePath ,
39
+ fileSystem: FileSystem ,
40
+ observabilityScope: ObservabilityScope
41
+ ) throws -> Self {
42
+ let parsedManifest = try ArtifactsArchiveMetadata . parse (
43
+ fileSystem: fileSystem,
44
+ rootPath: bundlePath
45
+ )
46
+
47
+ return try parsedManifest. validateDestinationsBundle (
48
+ bundlePath: bundlePath,
49
+ fileSystem: fileSystem,
50
+ observabilityScope: observabilityScope
51
+ )
52
+ }
28
53
}
29
54
30
- extension ArtifactsArchiveMetadata {
31
- public func validateDestinationsBundle(
55
+ private extension ArtifactsArchiveMetadata {
56
+ func validateDestinationsBundle(
32
57
bundlePath: AbsolutePath ,
33
58
fileSystem: FileSystem ,
34
59
observabilityScope: ObservabilityScope
0 commit comments