Skip to content

Commit

Permalink
refactor(ssh-keys): Check for errors in decorateAsyncOperations
Browse files Browse the repository at this point in the history
  • Loading branch information
mlec1 committed Oct 14, 2024
1 parent c95e972 commit 016d7f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cmd/ssh_key_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func (c *computeSSHKeyDeleteCmd) cmdPreRun(cmd *cobra.Command, args []string) er
}

func (c *computeSSHKeyDeleteCmd) cmdRun(_ *cobra.Command, _ []string) error {

ctx := gContext

if !c.Force {
Expand All @@ -41,7 +40,7 @@ func (c *computeSSHKeyDeleteCmd) cmdRun(_ *cobra.Command, _ []string) error {
}
}

decorateAsyncOperations(fmt.Sprintf("Deleting SSH key %s...", c.Name), func() error {
err := decorateAsyncOperations(fmt.Sprintf("Deleting SSH key %s...", c.Name), func() error {
op, err := globalstate.EgoscaleV3Client.DeleteSSHKey(ctx, c.Name)

if err != nil {
Expand All @@ -55,6 +54,9 @@ func (c *computeSSHKeyDeleteCmd) cmdRun(_ *cobra.Command, _ []string) error {

return nil
})
if err != nil {
return err
}

return nil
}
Expand Down
5 changes: 4 additions & 1 deletion cmd/ssh_key_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (c *computeSSHKeyRegisterCmd) cmdRun(cmd *cobra.Command, _ []string) error
PublicKey: string(publicKey),
}

decorateAsyncOperations(fmt.Sprintf("Registering SSH key %q...", c.Name), func() error {
err = decorateAsyncOperations(fmt.Sprintf("Registering SSH key %q...", c.Name), func() error {
op, err := client.RegisterSSHKey(ctx, registerKeyRequest)

if err != nil {
Expand All @@ -76,6 +76,9 @@ func (c *computeSSHKeyRegisterCmd) cmdRun(cmd *cobra.Command, _ []string) error

return nil
})
if err != nil {
return err
}

if !globalstate.Quiet {

Expand Down

0 comments on commit 016d7f7

Please sign in to comment.