NewEncryptionKey for client secret
(cmd *cobra.Command, client *http.Client)
| 20 | |
| 21 | // NewEncryptionKey for client secret |
| 22 | func NewEncryptionKey(cmd *cobra.Command, client *http.Client) (ek encrypta.EncryptionKey, encryptSecret bool, err error) { |
| 23 | if client == nil { |
| 24 | client = http.DefaultClient |
| 25 | } |
| 26 | |
| 27 | pgpKey := flagx.MustGetString(cmd, FlagEncryptionPGPKey) |
| 28 | pgpKeyURL := flagx.MustGetString(cmd, FlagEncryptionPGPKeyURL) |
| 29 | keybaseUsername := flagx.MustGetString(cmd, FlagEncryptionKeybase) |
| 30 | |
| 31 | if pgpKey != "" { |
| 32 | ek, err = encrypta.NewPublicKeyFromBase64Encoded(pgpKey) |
| 33 | encryptSecret = true |
| 34 | return |
| 35 | } |
| 36 | |
| 37 | if pgpKeyURL != "" { |
| 38 | ek, err = encrypta.NewPublicKeyFromURL(pgpKeyURL, encrypta.HTTPClientOption(client)) |
| 39 | encryptSecret = true |
| 40 | return |
| 41 | } |
| 42 | |
| 43 | if keybaseUsername != "" { |
| 44 | ek, err = encrypta.NewPublicKeyFromKeybase(keybaseUsername, encrypta.HTTPClientOption(client)) |
| 45 | encryptSecret = true |
| 46 | return |
| 47 | } |
| 48 | |
| 49 | return nil, false, nil |
| 50 | } |
no outgoing calls
no test coverage detected