func TestVersionCmd(t *testing.T) {
	t.Parallel()
	stdout, stderr := testRunCmd(t, "hostctl version", 0, nil, func() {
		Version = "0"
		versionChecker = usage.NewChecker("hostctl", Version)
	})
	ensure.DeepEqual(t, stdout.String(), "0\n")
	ensure.DeepEqual(t, stderr.String(), "")
}
Exemple #2
0
import (
	"errors"
	"flag"
	"log"
	"os"
	"time"

	dockerapi "github.com/fsouza/go-dockerclient"
	"github.com/gliderlabs/pkg/usage"
	"github.com/gliderlabs/registrator/bridge"
)

var Version string

var versionChecker = usage.NewChecker("registrator", Version)

var hostIp = flag.String("ip", "", "IP for ports mapped to the host")
var internal = flag.Bool("internal", false, "Use internal ports instead of published ones")
var refreshInterval = flag.Int("ttl-refresh", 0, "Frequency with which service TTLs are refreshed")
var refreshTtl = flag.Int("ttl", 0, "TTL for services (default is no expiry)")
var forceTags = flag.String("tags", "", "Append tags for all registered services")
var resyncInterval = flag.Int("resync", 0, "Frequency with which services are resynchronized")
var deregister = flag.String("deregister", "always", "Deregister exited services \"always\" or \"on-success\"")
var retryAttempts = flag.Int("retry-attempts", 0, "Max retry attempts to establish a connection with the backend. Use -1 for infinite retries")
var retryInterval = flag.Int("retry-interval", 2000, "Interval (in millisecond) between retry-attempts.")
var cleanup = flag.Bool("cleanup", false, "Remove dangling services")

func getopt(name, def string) string {
	if env := os.Getenv(name); env != "" {
		return env