dospin/dospin.go

40 lines
743 B
Go
Raw Normal View History

2016-02-14 23:38:28 -06:00
package main
import (
"github.com/digitalocean/godo"
"golang.org/x/oauth2"
"log"
)
type TokenSource struct {
AccessToken string
}
func (t *TokenSource) Token() (*oauth2.Token, error) {
token := &oauth2.Token{
AccessToken: t.AccessToken,
}
return token, nil
}
func main() {
settings, err := loadSettings("dospin.json")
if err != nil {
log.Fatal(err)
}
tokenSource := &TokenSource{settings.Token}
oauthClient := oauth2.NewClient(oauth2.NoContext, tokenSource)
client := godo.NewClient(oauthClient)
dm := NewDropletManager(client, settings)
2016-02-15 00:18:56 -06:00
_, err = dm.SpinupMachine("minecraft")
2016-02-14 23:38:28 -06:00
if err != nil {
log.Println(err)
return
}
2016-02-15 00:18:56 -06:00
//_, err = client.Droplets.Delete(droplet.ID)
//if err != nil {
// log.Println(err)
//}
2016-02-14 23:38:28 -06:00
}