diff options
| author | Jeff Carr <[email protected]> | 2023-12-29 01:36:10 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2023-12-29 01:36:10 -0600 |
| commit | 1258be9beff2e45c94ba5f7c29db65be02a1e2d4 (patch) | |
| tree | c1b6bc4e9a648835ec243140fd29689db1cf0bf1 /digitalocean/listKeys.go | |
| parent | 8afc73da048204f4245e0c850436c1e3e70055a5 (diff) | |
add digital ocean & DNS state windows
lists digital ocean droplets
create a new digital ocean droplet
knows what needs to be done to get IPv4 and IPv6 to work
update windows on Show()
make a window for the state of DNS specific to the hostname
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'digitalocean/listKeys.go')
| -rw-r--r-- | digitalocean/listKeys.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/digitalocean/listKeys.go b/digitalocean/listKeys.go new file mode 100644 index 0000000..000a66d --- /dev/null +++ b/digitalocean/listKeys.go @@ -0,0 +1,31 @@ +package digitalocean + +import ( + "context" + "fmt" + + "golang.org/x/oauth2" + + "github.com/digitalocean/godo" +) + +func GetSSHKeyID(token, name string) (string, error) { + tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token}) + oauthClient := oauth2.NewClient(context.Background(), tokenSource) + client := godo.NewClient(oauthClient) + + // List all keys. + keys, _, err := client.Keys.List(context.Background(), &godo.ListOptions{}) + if err != nil { + return "", err + } + + // Find the key by name. + for _, key := range keys { + if key.Name == name { + return key.Fingerprint, nil + } + } + + return "", fmt.Errorf("SSH Key not found") +} |
