summaryrefslogtreecommitdiff
path: root/listKeys.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-01 15:33:08 -0600
committerJeff Carr <[email protected]>2024-01-01 15:33:08 -0600
commitf03f76bc082a245f852dcd0cc52fef9ff48cdc93 (patch)
tree5e63087bc7cd1fe22743a4b60d120121ce0f7886 /listKeys.go
initial commit
Diffstat (limited to 'listKeys.go')
-rw-r--r--listKeys.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/listKeys.go b/listKeys.go
new file mode 100644
index 0000000..4b7da29
--- /dev/null
+++ b/listKeys.go
@@ -0,0 +1,39 @@
+package digitalocean
+
+import (
+ "context"
+ "golang.org/x/oauth2"
+ "github.com/digitalocean/godo"
+
+ "go.wit.com/log"
+)
+
+// 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
+ }
+
+ d.sshKeys = keys
+
+ // Find the key by name.
+ for _, key := range keys {
+ log.Log(POLL, "found ssh wierd", key.Name)
+ log.Log(POLL, "found ssh key:", key)
+ }
+ /*
+ sshKeys := []godo.DropletCreateSSHKey{
+ {ID: 22994569},
+ {ID: 333},
+ }
+ */
+
+ // return fmt.Errorf("SSH Key not found")
+ return nil
+}