This commit is contained in:
parent
d902130c01
commit
7ba5e85aaf
|
@ -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")
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue