示例#1
0
package main

import (
	"fmt"

	"github.com/flyinprogrammer/ec2metaproxy/Godeps/_workspace/src/github.com/alecthomas/kingpin"
)

var (
	debug   = kingpin.Flag("debug", "Enable debug mode.").Bool()
	timeout = kingpin.Flag("timeout", "Timeout waiting for ping.").OverrideDefaultFromEnvar("PING_TIMEOUT").Required().Short('t').Duration()
	ip      = kingpin.Arg("ip", "IP address to ping.").Required().IP()
	count   = kingpin.Arg("count", "Number of packets to send").Int()
)

func main() {
	kingpin.Version("0.0.1")
	kingpin.Parse()
	fmt.Printf("Would ping: %s with timeout %s and count %d", *ip, *timeout, *count)
}
示例#2
0
// A curl-like HTTP command-line client.
package main

import (
	"errors"
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"

	"github.com/flyinprogrammer/ec2metaproxy/Godeps/_workspace/src/github.com/alecthomas/kingpin"
)

var (
	timeout = kingpin.Flag("timeout", "Set connection timeout.").Short('t').Default("5s").Duration()
	headers = HTTPHeader(kingpin.Flag("headers", "Add HTTP headers to the request.").Short('H').PlaceHolder("HEADER=VALUE"))

	get         = kingpin.Command("get", "GET a resource.")
	getFlag     = get.Flag("test", "Test flag").Bool()
	getURL      = get.Command("url", "Retrieve a URL.")
	getURLURL   = getURL.Arg("url", "URL to GET.").Required().URL()
	getFile     = get.Command("file", "Retrieve a file.")
	getFileFile = getFile.Arg("file", "File to retrieve.").Required().ExistingFile()

	post           = kingpin.Command("post", "POST a resource.")
	postData       = post.Flag("data", "Key-value data to POST").Short('d').PlaceHolder("KEY:VALUE").StringMap()
	postBinaryFile = post.Flag("data-binary", "File with binary data to POST.").File()
	postURL        = post.Arg("url", "URL to POST to.").Required().URL()
)
示例#3
0
	"github.com/flyinprogrammer/ec2metaproxy/Godeps/_workspace/src/github.com/fsouza/go-dockerclient"
	"github.com/flyinprogrammer/ec2metaproxy/Godeps/_workspace/src/github.com/goamz/goamz/aws"
)

const (
	baseURL = "http://169.254.169.254" // no trailing slash '/'
)

var (
	credsRegex = regexp.MustCompile("^/(.+?)/meta-data/iam/security-credentials/(.*)$")

	instanceServiceClient = &http.Transport{}
)

var (
	defaultRole = RoleArnOpt(kingpin.
			Flag("default-iam-role", "ARN of the role to use if the container does not specify a role.").
			Short('r'))

	serverAddr = kingpin.
			Flag("server", "Interface and port to bind the server to.").
			Default(":18000").
			Short('s').
			String()

	verboseOpt = kingpin.
			Flag("verbose", "Enable verbose output.").
			Bool()
)

type MetadataCredentials struct {
	Code            string