Esempio n. 1
0
// Setup a new client with an access_token.
func (p *DOProvider) Setup() error {
	token := env.String("do_access_token", "", "digitalocean PAT token")
	if token == "" {
		return errors.New("access key required")
	}

	t := &oauth.Transport{
		Token: &oauth.Token{AccessToken: token},
	}

	p.client = godo.NewClient(t.Client())

	return nil
}
Esempio n. 2
0
import (
	"encoding/base64"

	"github.com/Sirupsen/logrus"
	h "github.com/gogrademe/api/handler"
	"github.com/gogrademe/api/store"
	"github.com/mattes/migrate/migrate"

	"github.com/labstack/echo"
	"github.com/labstack/echo/engine/standard"
	mw "github.com/labstack/echo/middleware"
	"github.com/mattaitchison/env"
)

var (
	port       = env.String("port", "5000", "listen port")
	dbAddr     = env.String("database_url", "postgres://localhost/gogrademe-api-dev?sslmode=disable&timezone=Etc/UTC", "sql db address")
	signingkey = env.String("jwt_key", "examplesigningkey", "key to used to sign jwt")
	// signingmethod = env.String("jwt_method", "HS256", "method used to sign jwt")
)

func main() {
	logrus.Println("running migrations")
	allErrors, ok := migrate.UpSync(dbAddr, "./migrations")
	if !ok {
		logrus.Println("Oh no ...")
		logrus.Fatal(allErrors)
		// do sth with allErrors slice
	}

	// Echo instance
Esempio n. 3
0
	"github.com/MattAitchison/remotectl/providers"
	sshutil "github.com/MattAitchison/remotectl/ssh"

	// Enabled Providers
	_ "github.com/MattAitchison/remotectl/digitalocean"
)

var (
	// Version number that gets set at compile time.
	Version string

	curUser, _ = user.Current()

	sshPort       = env.Int("remotectl_port", 22, "port used to connect to each host")
	_             = env.String("SSH_AUTH_SOCK", "", "ssh agent socket")
	ident         = env.String("remotectl_identity", "", "file from which the identity (private key) for public key authentication is read.")
	usr           = env.String("remotectl_user", curUser.Username, "user to connect as")
	provider      = env.StringList("remotectl_provider", []string{"digitalocean"}, "comma-sep list of provider modules to use for selecting hosts")
	namespace     = env.String("remotectl_namespace", "", "namespace is a prefix which is matched and removed from hosts")
	prefixTmplStr = env.String("remotectl_prefix", "{{.Name}}: ", "prefix template for host log output")
	prefixTmpl    = template.Must(template.New("prefix").Parse(prefixTmplStr))

	profile     = flag.StringP("profile", "p", "", "bash profile to source for env config") // Maybe a name will default to a file in ~/.remotectl
	showVersion = flag.BoolP("version", "V", false, "show version")
	showHelp    = flag.BoolP("help", "h", false, "show this help message")
	showList    = flag.BoolP("list", "l", false, "lists selected ips and names. /etc/hosts friendly output")
)

func fatal(err error) {
	if err != nil {