| 245 | } |
| 246 | |
| 247 | func keyToString(key *Key) string { |
| 248 | switch k := key.KeyType.(type) { |
| 249 | case *Key_PgpKey: |
| 250 | return fmt.Sprintf("PGP key with fingerprint %s", k.PgpKey.Fingerprint) |
| 251 | case *Key_KmsKey: |
| 252 | return fmt.Sprintf("AWS KMS key with ARN %s", k.KmsKey.Arn) |
| 253 | case *Key_GcpKmsKey: |
| 254 | return fmt.Sprintf("GCP KMS key with resource ID %s", k.GcpKmsKey.ResourceId) |
| 255 | case *Key_AzureKeyvaultKey: |
| 256 | return fmt.Sprintf("Azure Key Vault key with URL %s/keys/%s/%s", k.AzureKeyvaultKey.VaultUrl, k.AzureKeyvaultKey.Name, k.AzureKeyvaultKey.Version) |
| 257 | case *Key_VaultKey: |
| 258 | return fmt.Sprintf("Hashicorp Vault key with URI %s/v1/%s/keys/%s", k.VaultKey.VaultAddress, k.VaultKey.EnginePath, k.VaultKey.KeyName) |
| 259 | case *Key_HckmsKey: |
| 260 | return fmt.Sprintf("HuaweiCloud KMS key with ID %s", k.HckmsKey.KeyId) |
| 261 | default: |
| 262 | return "Unknown key type" |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | func (ks Server) prompt(key *Key, requestType string) error { |
| 267 | keyString := keyToString(key) |