Skip to content

Commit

Permalink
refactor(ssh-keys-list): Update ssh-keys list to egoscale v3
Browse files Browse the repository at this point in the history
  • Loading branch information
mlec1 committed Sep 21, 2024
1 parent 3868b32 commit 0d3de18
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions cmd/ssh_key_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import (

"github.com/spf13/cobra"

"github.com/exoscale/cli/pkg/account"
"github.com/exoscale/cli/pkg/globalstate"
"github.com/exoscale/cli/pkg/output"
exoapi "github.com/exoscale/egoscale/v2/api"
)

type computeSSHKeyListItemOutput struct {
Expand Down Expand Up @@ -45,22 +43,21 @@ func (c *computeSSHKeyListCmd) cmdPreRun(cmd *cobra.Command, args []string) erro
}

func (c *computeSSHKeyListCmd) cmdRun(_ *cobra.Command, _ []string) error {
ctx := exoapi.WithEndpoint(
gContext,
exoapi.NewReqEndpoint(account.CurrentAccount.Environment, account.CurrentAccount.DefaultZone),
)

sshKeys, err := globalstate.EgoscaleClient.ListSSHKeys(ctx, account.CurrentAccount.DefaultZone)
ctx := gContext
client := globalstate.EgoscaleV3Client

sshKeysResponse, err := client.ListSSHKeys(ctx)
if err != nil {
return err
}

out := make(computeSSHKeyListOutput, 0)

for _, k := range sshKeys {
for _, k := range sshKeysResponse.SSHKeys {
out = append(out, computeSSHKeyListItemOutput{
Name: *k.Name,
Fingerprint: *k.Fingerprint,
Name: k.Name,
Fingerprint: k.Fingerprint,
})
}

Expand Down

0 comments on commit 0d3de18

Please sign in to comment.