Skip to content

Commit b786eda

Browse files
authored
chore(baremetal): change from account to iam api for ssh-keys (#3203)
1 parent 0bce871 commit b786eda

7 files changed

+129
-156
lines changed

internal/namespaces/baremetal/v1/custom_server_install.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"reflect"
66

77
"github.com/scaleway/scaleway-cli/v2/internal/core"
8-
account "github.com/scaleway/scaleway-sdk-go/api/account/v2alpha1"
98
baremetal "github.com/scaleway/scaleway-sdk-go/api/baremetal/v1"
9+
iam "github.com/scaleway/scaleway-sdk-go/api/iam/v1alpha1"
1010
"github.com/scaleway/scaleway-sdk-go/scw"
1111
)
1212

@@ -33,9 +33,9 @@ func serverInstallBuilder(c *core.Command) *core.Command {
3333
// SSH keys management
3434
if tmpRequest.AllSSHKeys != nil && *tmpRequest.AllSSHKeys {
3535
client := core.ExtractClient(ctx)
36-
accountapi := account.NewAPI(client)
36+
iamAPI := iam.NewAPI(client)
3737
orgID, _ := client.GetDefaultOrganizationID()
38-
listKeys, err := accountapi.ListSSHKeys(&account.ListSSHKeysRequest{
38+
listKeys, err := iamAPI.ListSSHKeys(&iam.ListSSHKeysRequest{
3939
OrganizationID: &orgID,
4040
}, scw.WithAllPages())
4141
if err != nil {

internal/namespaces/baremetal/v1/custom_server_install_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"testing"
55

66
"github.com/scaleway/scaleway-cli/v2/internal/core"
7-
account "github.com/scaleway/scaleway-cli/v2/internal/namespaces/account/v2alpha1"
7+
iam "github.com/scaleway/scaleway-cli/v2/internal/namespaces/iam/v1alpha1"
88
)
99

1010
func Test_InstallServer(t *testing.T) {
@@ -14,7 +14,7 @@ func Test_InstallServer(t *testing.T) {
1414
sshKey := `ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCbJuYSOQc01zjHsMyn4OUsW61cqRvttKt3StJgbvt2WBuGpwi1/5RtSoMQpudYlZpdeivFb21S8QRas8zcOc+6WqgWa2nj/8yA+cauRlV6CMWY+hOTkkg39xaekstuQ+WR2/AP7O/9hjVx5735+9ZNIxxHsFjVYdBEuk9gEX+1Rw== foobar@foobar`
1515
osID := `03b7f4ba-a6a1-4305-984e-b54fafbf1681` // Ubuntu 20.04 LTS (Focal)
1616
cmds := GetCommands()
17-
cmds.Merge(account.GetCommands())
17+
cmds.Merge(iam.GetCommands())
1818

1919
t.Run("With ID", core.Test(&core.TestConfig{
2020
BeforeFunc: core.BeforeFuncCombine(

internal/namespaces/baremetal/v1/helpers_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ func deleteServer(metaKey string) core.AfterFunc {
2626
func addSSH(metaKey string, key string) core.BeforeFunc {
2727
return func(ctx *core.BeforeFuncCtx) error {
2828
ctx.Meta[metaKey] = ctx.ExecuteCmd([]string{
29-
"scw", "account", "ssh-key", "add", "public-key=" + key,
29+
"scw", "iam", "ssh-key", "create", "public-key=" + key,
3030
})
3131
return nil
3232
}
3333
}
3434

3535
// delete an ssh key with a given meta key
3636
func deleteSSH(metaKey string) core.AfterFunc {
37-
return core.ExecAfterCmd("scw account ssh-key remove {{ ." + metaKey + ".ID }}")
37+
return core.ExecAfterCmd("scw iam ssh-key delete {{ ." + metaKey + ".ID }}")
3838
}

internal/namespaces/baremetal/v1/testdata/test-install-server-simple-all-ssh-keys.cassette.yaml

Lines changed: 51 additions & 67 deletions
Large diffs are not rendered by default.

internal/namespaces/baremetal/v1/testdata/test-install-server-simple-all-ssh-keys.golden

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ BootType normal
2727
Zone nl-ams-1
2828
Install.OsID 03b7f4ba-a6a1-4305-984e-b54fafbf1681
2929
Install.Hostname test-install-server
30-
Install.SSHKeyIDs.0 9bf6c340-687c-4f31-8aad-6a525761d8cd
31-
Install.SSHKeyIDs.1 d957cb31-2a7f-4b68-9363-b128184b3c85
32-
Install.SSHKeyIDs.2 b97c757c-d530-4ff6-92c3-febddb801096
33-
Install.SSHKeyIDs.3 48734124-36fc-409c-a515-40c87ed0e1b8
34-
Install.SSHKeyIDs.4 66f16bba-3002-45d5-8348-58f13d31afaf
30+
Install.SSHKeyIDs.0 02aeb573-5220-4e1d-8983-fbd12fc38b5f
3531
Install.Status completed
3632
Install.User -
3733
Install.ServiceUser -
@@ -75,11 +71,7 @@ PingStatus down
7571
"os_id": "03b7f4ba-a6a1-4305-984e-b54fafbf1681",
7672
"hostname": "test-install-server",
7773
"ssh_key_ids": [
78-
"9bf6c340-687c-4f31-8aad-6a525761d8cd",
79-
"d957cb31-2a7f-4b68-9363-b128184b3c85",
80-
"b97c757c-d530-4ff6-92c3-febddb801096",
81-
"48734124-36fc-409c-a515-40c87ed0e1b8",
82-
"66f16bba-3002-45d5-8348-58f13d31afaf"
74+
"02aeb573-5220-4e1d-8983-fbd12fc38b5f"
8375
],
8476
"status": "completed",
8577
"user": "",

internal/namespaces/baremetal/v1/testdata/test-install-server-simple-with-id.cassette.yaml

Lines changed: 67 additions & 70 deletions
Large diffs are not rendered by default.

internal/namespaces/baremetal/v1/testdata/test-install-server-simple-with-id.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ BootType normal
2727
Zone nl-ams-1
2828
Install.OsID 03b7f4ba-a6a1-4305-984e-b54fafbf1681
2929
Install.Hostname test-install-server
30-
Install.SSHKeyIDs.0 48734124-36fc-409c-a515-40c87ed0e1b8
30+
Install.SSHKeyIDs.0 02aeb573-5220-4e1d-8983-fbd12fc38b5f
3131
Install.Status completed
3232
Install.User -
3333
Install.ServiceUser -
@@ -71,7 +71,7 @@ PingStatus down
7171
"os_id": "03b7f4ba-a6a1-4305-984e-b54fafbf1681",
7272
"hostname": "test-install-server",
7373
"ssh_key_ids": [
74-
"48734124-36fc-409c-a515-40c87ed0e1b8"
74+
"02aeb573-5220-4e1d-8983-fbd12fc38b5f"
7575
],
7676
"status": "completed",
7777
"user": "",

0 commit comments

Comments
 (0)