Skip to content

Commit

Permalink
Use map for Client.GetSSHKeys(...) response
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarber-akamai committed Jan 10, 2024
1 parent b8ab235 commit 7bbfc38
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
8 changes: 1 addition & 7 deletions sshkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@ package metadata

import "context"

// SSHKeysUserData contains per-user SSH public keys
// specified during Linode instance/disk creation.
type SSHKeysUserData struct {
Root []string `json:"root"`
}

// SSHKeysData contains information about SSH keys
// relevant to the current Linode instance.
type SSHKeysData struct {
Users SSHKeysUserData `json:"users"`
Users map[string][]string `json:"users"`
}

// GetSSHKeys gets all SSH keys for the current instance.
Expand Down
24 changes: 24 additions & 0 deletions test/integration/sshkeys_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package integration

import (
"context"
"github.com/stretchr/testify/assert"
"testing"
)

// NOTE: This test assumes the host instance has
// a user configured with SSH keys. This should
// always be the case when using the `make e2e`
// target but may not always be the case when running
// the `make e2e-local` target.
func TestGetSSHKeys(t *testing.T) {
t.Parallel()

sshKeys, err := metadataClient.GetSSHKeys(context.Background())
assert.NoError(t, err)

assert.Greater(t, len(sshKeys.Users), 0)
for _, v := range sshKeys.Users {
assert.Greater(t, len(v), 0)
}
}

0 comments on commit 7bbfc38

Please sign in to comment.