Skip to content

Expose SigningEntity via package metadata #6442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2023
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
15 changes: 14 additions & 1 deletion Sources/PackageMetadata/PackageMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public struct Package {
public let type: String
public let checksum: String?
public let signing: Signing?
public let signingEntity: RegistryReleaseMetadata.SigningEntity?
}

public struct Signing: Sendable {
Expand Down Expand Up @@ -421,13 +422,25 @@ extension Package.Signing {
}
}

extension RegistryReleaseMetadata.SigningEntity {
fileprivate init(_ entity: SigningEntity) {
switch entity {
case .recognized(let type, let name, let organizationalUnit, let organization):
self = .recognized(type: type.rawValue, commonName: name, organization: organization, identity: organizationalUnit)
case .unrecognized(let name, _, let organization):
self = .unrecognized(commonName: name, organization: organization)
}
}
}

extension Package.Resource {
fileprivate init(_ resource: RegistryClient.PackageVersionMetadata.Resource) {
self.init(
name: resource.name,
type: resource.type,
checksum: resource.checksum,
signing: resource.signing.map { .init($0) }
signing: resource.signing.map { .init($0) },
signingEntity: resource.signingEntity.map { .init($0) }
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/PackageModel/RegistryReleaseMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public struct RegistryReleaseMetadata {
}
}

public enum SigningEntity: Codable, Equatable {
public enum SigningEntity: Codable, Equatable, Sendable {
case recognized(type: String, commonName: String?, organization: String?, identity: String?)
case unrecognized(commonName: String?, organization: String?)
}
Expand Down