diff options
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 } |
