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

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

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

	return nil
}
Example #2
0
	"regexp"
	"strconv"
	"strings"
	"syscall"

	env "github.com/MattAitchison/envconfig"
	"github.com/fsouza/go-dockerclient"
	"github.com/gliderlabs/connectable/pkg/lookup"

	_ "github.com/gliderlabs/connectable/pkg/lookup/dns"
)

var Version string

var (
	endpoint = env.String("docker_host", "unix:///var/run/docker.sock", "docker endpoint")
	port     = env.String("port", "10000", "primary listen port")

	self *docker.Container
)

func assert(err error) {
	if err != nil {
		log.Fatal(err)
	}
}

func runNetCmd(container, image string, cmd string) error {
	client, err := docker.NewClient(endpoint)
	if err != nil {
		return err
Example #3
0
package etcd

import (
	"strings"
	"time"

	env "github.com/MattAitchison/envconfig"
	"github.com/coreos/etcd/Godeps/_workspace/src/golang.org/x/net/context"
	"github.com/coreos/etcd/client"
	"github.com/gliderlabs/connectable/pkg/lookup"
)

var (
	// envconfig seems to not handle stringlist right
	//etcdPeers  = env.StringList("etcd_peers", []string{"http://127.0.0.1:4001"}, "Etcd Peers")
	etcdPeers  = env.String("etcd_peers", "http://127.0.0.1:4001", "Comman separated list of etcd peers")
	etcdPrefix = env.String("etcd_prefix", "", "Prefix to look for services in.")
	peersList  []string
)

func init() {
	lookup.Register("etcd", new(etcdResolver))
	peersList = strings.Split(etcdPeers, ",")
}

type etcdResolver struct{}

func (r *etcdResolver) Lookup(addr string) ([]string, error) {
	cfg := client.Config{
		Endpoints: peersList,
		Transport: client.DefaultTransport,
Example #4
0
package lookup

import (
	"fmt"
	"log"
	"time"

	env "github.com/MattAitchison/envconfig"
)

var (
	resolverName = env.String("lookup_resolver", "dns", "resolver to use for lookups")
	debugMode    = env.Bool("lookup_debug", false, "enable debug output")
	resolvers    = make(map[string]Resolver)
)

func debug(v ...interface{}) {
	if debugMode {
		log.Println(v...)
	}
}

type Resolver interface {
	Lookup(addr string) ([]string, error)
}

func Register(name string, resolver Resolver) {
	resolvers[name] = resolver
}

func Resolve(addr string) ([]string, error) {
Example #5
0
	"github.com/MattAitchison/envconfig"
	ext "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       = envconfig.Int("remotectl_port", 22, "port used to connect to each host")
	_             = envconfig.String("SSH_AUTH_SOCK", "", "ssh agent socket")
	ident         = envconfig.String("remotectl_identity", "", "file from which the identity (private key) for public key authentication is read.")
	usr           = envconfig.String("remotectl_user", curUser.Username, "user to connect as")
	provider      = envconfig.String("remotectl_provider", "do", "comma-sep list of provider modules to use for selecting hosts")
	namespace     = envconfig.String("remotectl_namespace", "", "namespace is a prefix which is matched and removed from hosts")
	prefixTmplStr = envconfig.String("remotectl_prefix", "{{.Name}}: ", "prefix template for host log output")
	prefixTmpl    = template.Must(template.New("prefix").Parse(prefixTmplStr))
	profile       = flag.String("profile", "", "bash profile to source for env config") // Maybe a name will default to a file in ~/.remotectl

	showVersion = flag.Bool("version", false, "show version")
	showHelp    = flag.Bool("help", false, "show this help message")
	showList    = flag.Bool("list", false, "lists selected ips and names. /etc/hosts friendly output")
)

func fatal(err error) {
	if err != nil {
Example #6
0
	"regexp"
	"strconv"
	"strings"
	"syscall"

	env "github.com/MattAitchison/envconfig"
	"github.com/fsouza/go-dockerclient"
	"github.com/gliderlabs/connectable/pkg/lookup"

	_ "github.com/gliderlabs/connectable/pkg/lookup/dns"
)

var Version string

var (
	endpoint = env.String("docker_host", "unix:///var/run/docker.sock", "docker endpoint")
	port     = env.String("port", "10000", "primary listen port")
	network  = env.String("network", "default", "network to match on")

	self *docker.Container
)

func assert(err error) {
	if err != nil {
		log.Fatal(err)
	}
}

func runNetCmd(container, image string, cmd string) error {
	client, err := docker.NewClient(endpoint)
	if err != nil {