Skip to content

Commit

Permalink
Working WIP using Linode Go SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
kzap committed Sep 27, 2018
0 parents commit 206b766
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
ligo

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
7 changes: 7 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module github.com/kzap/ligo

require (
github.com/linode/linodego v0.5.2-0.20180916222121-15d4ab6c221b
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be
gopkg.in/resty.v1 v1.9.1 // indirect
)
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
github.com/linode/linodego v0.5.2-0.20180916222121-15d4ab6c221b h1:1oeOtCnxd4Fi9qWnUr0v/k1XURvWdEPGDyJLbHg4b6o=
github.com/linode/linodego v0.5.2-0.20180916222121-15d4ab6c221b/go.mod h1:ga11n3ivecUrPCHN0rANxKmfWBJVkOXfLMZinAbj2sY=
golang.org/x/net v0.0.0-20180611182652-db08ff08e862 h1:JZi6BqOZ+iSgmLWe6llhGrNnEnK+YB/MRkStwnEfbqM=
golang.org/x/net v0.0.0-20180611182652-db08ff08e862/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
gopkg.in/resty.v1 v1.9.1 h1:Lq4EIBZ5e2J4ZWp22W2hVOYc0X1qwDDki/nNVchRbdw=
gopkg.in/resty.v1 v1.9.1/go.mod h1:vo52Hzryw9PnPHcJfPsBiFW62XhNx5OczbV9y+IMpgc=
36 changes: 36 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package main

import (
"context"
"fmt"

"github.com/linode/linodego"
"golang.org/x/oauth2"

"log"
"net/http"
"os"
)

func main() {
apiKey, ok := os.LookupEnv("LINODE_TOKEN")
if !ok {
log.Fatal("Could not find LINODE_TOKEN, please assert it is set.")
}
tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: apiKey})

oauth2Client := &http.Client{
Transport: &oauth2.Transport{
Source: tokenSource,
},
}

linodeClient := linodego.NewClient(oauth2Client)
linodeClient.SetDebug(true)

res, err := linodeClient.GetInstance(context.Background(), 4090913)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%v", res)
}

0 comments on commit 206b766

Please sign in to comment.