@@ -15,33 +15,16 @@ import (
1515 "github.com/uselagoon/lagoon-cli/pkg/output"
1616)
1717
18- func parseSSHKeyFile (sshPubKey string , keyName string , keyValue string , userEmail string ) (schema.AddSSHKeyInput , error ) {
18+ func parseSSHKeyFile (sshPubKey string , keyName string , keyValue string , userEmail string ) (* schema.AddUserSSHPublicKeyInput , error ) {
1919 // if we haven't got a keyvalue
2020 if keyValue == "" {
2121 b , err := os .ReadFile (sshPubKey ) // just pass the file name
22- handleError (err )
22+ if err != nil {
23+ return nil , err
24+ }
2325 keyValue = string (b )
2426 }
2527 splitKey := strings .Split (keyValue , " " )
26- var keyType schema.SSHKeyType
27- var err error
28-
29- // will fail if value is not right
30- switch splitKey [0 ] {
31- case "ssh-rsa" :
32- keyType = schema .SSHRsa
33- case "ssh-ed25519" :
34- keyType = schema .SSHEd25519
35- case "ecdsa-sha2-nistp256" :
36- keyType = schema .SSHECDSA256
37- case "ecdsa-sha2-nistp384" :
38- keyType = schema .SSHECDSA384
39- case "ecdsa-sha2-nistp521" :
40- keyType = schema .SSHECDSA521
41- default :
42- keyType = schema .SSHRsa
43- err = fmt .Errorf ("SSH key type %s not supported" , splitKey [0 ])
44- }
4528
4629 // if the sshkey has a comment/name in it, we can use that
4730 if keyName == "" && len (splitKey ) == 3 {
@@ -51,16 +34,13 @@ func parseSSHKeyFile(sshPubKey string, keyName string, keyValue string, userEmai
5134 keyName = userEmail
5235 output .RenderInfo ("no name provided, using email address as key name\n " , outputOptions )
5336 }
54- SSHKeyInput := schema.AddSSHKeyInput {
55- SSHKey : schema.SSHKey {
56- KeyType : keyType ,
57- KeyValue : stripNewLines (splitKey [1 ]),
58- Name : keyName ,
59- },
37+ SSHKeyInput := schema.AddUserSSHPublicKeyInput {
38+ PublicKey : keyValue ,
39+ Name : keyName ,
6040 UserEmail : userEmail ,
6141 }
6242
63- return SSHKeyInput , err
43+ return & SSHKeyInput , nil
6444}
6545
6646var addUserCmd = & cobra.Command {
@@ -189,7 +169,7 @@ Add key by defining key value, but not specifying a key name (will default to tr
189169 if err != nil {
190170 return err
191171 }
192- result , err := lagoon .AddSSHKey (context .TODO (), & userSSHKey , lc )
172+ result , err := lagoon .AddUserSSHPublicKey (context .TODO (), userSSHKey , lc )
193173 if err != nil {
194174 return err
195175 }
@@ -236,7 +216,7 @@ var deleteSSHKeyCmd = &cobra.Command{
236216 debug )
237217
238218 if yesNo (fmt .Sprintf ("You are attempting to delete SSH key ID:'%d', are you sure?" , sshKeyID )) {
239- _ , err := lagoon .RemoveSSHKey (context .TODO (), sshKeyID , lc )
219+ _ , err := lagoon .DeleteUserSSHPublicKey (context .TODO (), sshKeyID , lc )
240220 if err != nil {
241221 return err
242222 }
0 commit comments