diff options
| author | Jeff Carr <[email protected]> | 2023-12-30 23:30:14 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2023-12-30 23:30:14 -0600 |
| commit | 44730e1b91d0aa9d412032aebe2fc0c8367ddf13 (patch) | |
| tree | f0b92816ef7a672097183b776a9a78557a485f82 /digitalocean/listKeys.go | |
| parent | be03e85c2def1501b6b22572d8a1d140663194ab (diff) | |
digitalocean droplet power on & off work
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'digitalocean/listKeys.go')
| -rw-r--r-- | digitalocean/listKeys.go | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/digitalocean/listKeys.go b/digitalocean/listKeys.go index 000a66d..97c82bb 100644 --- a/digitalocean/listKeys.go +++ b/digitalocean/listKeys.go @@ -2,30 +2,37 @@ package digitalocean import ( "context" - "fmt" "golang.org/x/oauth2" "github.com/digitalocean/godo" + + "go.wit.com/log" ) -func GetSSHKeyID(token, name string) (string, error) { - tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token}) +// func (d *DigitalOcean) ListDroplets() bool { +func (d *DigitalOcean) ListSSHKeyID() error { + tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: d.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 + return err } // Find the key by name. - for _, key := range keys { - if key.Name == name { - return key.Fingerprint, nil - } + for i, key := range keys { + log.Info("found ssh i =", i) + log.Info("found ssh key.Name =", key.Name) + log.Info("found ssh key.Fingerprint =", key.Fingerprint) + log.Info("found ssh key:", key) + // if key.Name == name { + // return key.Fingerprint, nil + // } } - return "", fmt.Errorf("SSH Key not found") + // return fmt.Errorf("SSH Key not found") + return nil } |
