This commit is contained in:
Max Goedjen 2022-01-02 16:20:12 -08:00
parent d902130c01
commit 7ba5e85aaf
No known key found for this signature in database
GPG Key ID: E58C21DD77B9B8E8
2 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,5 @@
import Foundation
import OSLog
import SecretKit
/// Controller responsible for writing public keys to disk, so that they're easily accessible by scripts.
public class PublicKeyFileStoreController {
@ -38,7 +37,7 @@ public class PublicKeyFileStoreController {
/// - Parameter secret: The Secret to return the path for.
/// - Returns: The path to the Secret's public key.
/// - Warning: This method returning a path does not imply that a key has been written to disk already. This method only describes where it will be written to.
func path(for secret: AnySecret) -> String {
public func path<SecretType: Secret>(for secret: SecretType) -> String {
directory.appending("/").appending("\(secret.name.replacingOccurrences(of: " ", with: "-")).pub")
}

View File

@ -6,6 +6,7 @@ struct SecretDetailView<SecretType: Secret>: View {
@State var secret: SecretType
private let keyWriter = OpenSSHKeyWriter()
private let publicKeyFileStoreController = PublicKeyFileStoreController()
var body: some View {
ScrollView {
@ -20,7 +21,7 @@ struct SecretDetailView<SecretType: Secret>: View {
CopyableView(title: "Public Key Contents", image: Image(systemName: "key"), text: keyString)
Spacer()
.frame(height: 20)
CopyableView(title: "Public Key Path", image: Image(systemName: "lock.doc"), text: "/Users/max/whatever")
CopyableView(title: "Public Key Path", image: Image(systemName: "lock.doc"), text: publicKeyFileStoreController.path(for: secret))
Spacer()
}
}
@ -43,7 +44,7 @@ struct SecretDetailView<SecretType: Secret>: View {
var keyString: String {
keyWriter.openSSHString(secret: secret, comment: "\(dashedKeyName)@\(dashedHostName)")
}
}
#if DEBUG