1
0
mirror of https://github.com/rancher/os.git synced 2025-09-01 23:04:41 +00:00

Bump libcompose and its dependencies

This commit is contained in:
Josh Curl
2016-05-23 17:22:40 -07:00
parent c18cd26e78
commit 50de80d09a
1109 changed files with 35052 additions and 125685 deletions

View File

@@ -1,19 +0,0 @@
package log
import "testing"
func TestTerminalLoggerWithFields(t *testing.T) {
logger := TerminalLogger{}
withFieldsLogger := logger.WithFields(Fields{
"foo": "bar",
"spam": "eggs",
})
withFieldsTerminalLogger, ok := withFieldsLogger.(TerminalLogger)
if !ok {
t.Fatal("Type assertion to TerminalLogger failed")
}
expectedOutFields := "\t\t foo=bar spam=eggs"
if withFieldsTerminalLogger.fieldOut != expectedOutFields {
t.Fatalf("Expected %q, got %q", expectedOutFields, withFieldsTerminalLogger.fieldOut)
}
}

View File

@@ -1,125 +0,0 @@
package main
import (
"os"
"path"
"github.com/codegangsta/cli"
"github.com/docker/machine/commands"
"github.com/docker/machine/log"
"github.com/docker/machine/ssh"
"github.com/docker/machine/utils"
"github.com/docker/machine/version"
)
var AppHelpTemplate = `Usage: {{.Name}} {{if .Flags}}[OPTIONS] {{end}}COMMAND [arg...]
{{.Usage}}
Version: {{.Version}}{{if or .Author .Email}}
Author:{{if .Author}}
{{.Author}}{{if .Email}} - <{{.Email}}>{{end}}{{else}}
{{.Email}}{{end}}{{end}}
{{if .Flags}}
Options:
{{range .Flags}}{{.}}
{{end}}{{end}}
Commands:
{{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
{{end}}
Run '{{.Name}} COMMAND --help' for more information on a command.
`
var CommandHelpTemplate = `Usage: docker-machine {{.Name}}{{if .Flags}} [OPTIONS]{{end}} [arg...]
{{.Usage}}{{if .Description}}
Description:
{{.Description}}{{end}}{{if .Flags}}
Options:
{{range .Flags}}
{{.}}{{end}}{{ end }}
`
func main() {
for _, f := range os.Args {
if f == "-D" || f == "--debug" || f == "-debug" {
os.Setenv("DEBUG", "1")
}
}
cli.AppHelpTemplate = AppHelpTemplate
cli.CommandHelpTemplate = CommandHelpTemplate
app := cli.NewApp()
app.Name = path.Base(os.Args[0])
app.Author = "Docker Machine Contributors"
app.Email = "https://github.com/docker/machine"
app.Before = func(c *cli.Context) error {
os.Setenv("MACHINE_STORAGE_PATH", c.GlobalString("storage-path"))
if c.GlobalBool("native-ssh") {
ssh.SetDefaultClient(ssh.Native)
}
return nil
}
app.Commands = commands.Commands
app.CommandNotFound = cmdNotFound
app.Usage = "Create and manage machines running Docker."
app.Version = version.VERSION + " (" + version.GITCOMMIT + ")"
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "debug, D",
Usage: "Enable debug mode",
},
cli.StringFlag{
EnvVar: "MACHINE_STORAGE_PATH",
Name: "s, storage-path",
Value: utils.GetBaseDir(),
Usage: "Configures storage path",
},
cli.StringFlag{
EnvVar: "MACHINE_TLS_CA_CERT",
Name: "tls-ca-cert",
Usage: "CA to verify remotes against",
Value: "",
},
cli.StringFlag{
EnvVar: "MACHINE_TLS_CA_KEY",
Name: "tls-ca-key",
Usage: "Private key to generate certificates",
Value: "",
},
cli.StringFlag{
EnvVar: "MACHINE_TLS_CLIENT_CERT",
Name: "tls-client-cert",
Usage: "Client cert to use for TLS",
Value: "",
},
cli.StringFlag{
EnvVar: "MACHINE_TLS_CLIENT_KEY",
Name: "tls-client-key",
Usage: "Private key used in client TLS auth",
Value: "",
},
cli.BoolFlag{
EnvVar: "MACHINE_NATIVE_SSH",
Name: "native-ssh",
Usage: "Use the native (Go-based) SSH implementation.",
},
}
app.Run(os.Args)
}
func cmdNotFound(c *cli.Context, command string) {
log.Fatalf(
"%s: '%s' is not a %s command. See '%s --help'.",
c.App.Name,
command,
c.App.Name,
c.App.Name,
)
}

View File

@@ -1 +0,0 @@
package main

View File

@@ -1,63 +0,0 @@
package utils
import (
"io/ioutil"
"net/http"
"net/http/httptest"
"path/filepath"
"testing"
)
func TestGetLatestBoot2DockerReleaseUrl(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
respText := `[{"tag_name": "0.2", "prerelease": true, "tag_name": "0.1", "prerelease": false}]`
w.Write([]byte(respText))
}))
defer ts.Close()
b := NewB2dUtils(ts.URL, ts.URL, "virtualbox")
isoUrl, err := b.GetLatestBoot2DockerReleaseURL()
if err != nil {
t.Fatal(err)
}
// TODO: update to release URL once we get the releases worked
// out for b2d-ng
//expectedUrl := fmt.Sprintf("%s/boot2docker/boot2docker/releases/download/0.1/boot2docker.iso", ts.URL)
//if isoUrl != expectedUrl {
// t.Fatalf("expected url %s; received %s", isoUrl)
//}
if isoUrl == "" {
t.Fatalf("expected a url for the iso")
}
}
func TestDownloadIso(t *testing.T) {
testData := "test-download"
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(testData))
}))
defer ts.Close()
filename := "test"
tmpDir, err := ioutil.TempDir("", "machine-test-")
if err != nil {
t.Fatal(err)
}
b := NewB2dUtils(ts.URL, ts.URL, "")
if err := b.DownloadISO(tmpDir, filename, ts.URL); err != nil {
t.Fatal(err)
}
data, err := ioutil.ReadFile(filepath.Join(tmpDir, filename))
if err != nil {
t.Fatal(err)
}
if string(data) != testData {
t.Fatalf("expected data \"%s\"; received \"%s\"", testData, string(data))
}
}

View File

@@ -1,74 +0,0 @@
package utils
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
)
func TestGenerateCACertificate(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "machine-test-")
if err != nil {
t.Fatal(err)
}
// cleanup
defer os.RemoveAll(tmpDir)
os.Setenv("MACHINE_DIR", tmpDir)
caCertPath := filepath.Join(tmpDir, "ca.pem")
caKeyPath := filepath.Join(tmpDir, "key.pem")
testOrg := "test-org"
bits := 2048
if err := GenerateCACertificate(caCertPath, caKeyPath, testOrg, bits); err != nil {
t.Fatal(err)
}
if _, err := os.Stat(caCertPath); err != nil {
t.Fatal(err)
}
if _, err := os.Stat(caKeyPath); err != nil {
t.Fatal(err)
}
os.Setenv("MACHINE_DIR", "")
}
func TestGenerateCert(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "machine-test-")
if err != nil {
t.Fatal(err)
}
// cleanup
defer os.RemoveAll(tmpDir)
os.Setenv("MACHINE_DIR", tmpDir)
caCertPath := filepath.Join(tmpDir, "ca.pem")
caKeyPath := filepath.Join(tmpDir, "key.pem")
certPath := filepath.Join(tmpDir, "cert.pem")
keyPath := filepath.Join(tmpDir, "cert-key.pem")
testOrg := "test-org"
bits := 2048
if err := GenerateCACertificate(caCertPath, caKeyPath, testOrg, bits); err != nil {
t.Fatal(err)
}
if _, err := os.Stat(caCertPath); err != nil {
t.Fatal(err)
}
if _, err := os.Stat(caKeyPath); err != nil {
t.Fatal(err)
}
os.Setenv("MACHINE_DIR", "")
if err := GenerateCert([]string{}, certPath, keyPath, caCertPath, caKeyPath, testOrg, bits); err != nil {
t.Fatal(err)
}
if _, err := os.Stat(certPath); err != nil {
t.Fatalf("certificate not created at %s", certPath)
}
if _, err := os.Stat(keyPath); err != nil {
t.Fatalf("key not created at %s", keyPath)
}
}

View File

@@ -1,139 +0,0 @@
package utils
import (
"io/ioutil"
"os"
"path"
"path/filepath"
"runtime"
"strings"
"testing"
)
func TestGetBaseDir(t *testing.T) {
// reset any override env var
homeDir := GetHomeDir()
baseDir := GetBaseDir()
if strings.Index(baseDir, homeDir) != 0 {
t.Fatalf("expected base dir with prefix %s; received %s", homeDir, baseDir)
}
}
func TestGetCustomBaseDir(t *testing.T) {
root := "/tmp"
os.Setenv("MACHINE_STORAGE_PATH", root)
baseDir := GetBaseDir()
if strings.Index(baseDir, root) != 0 {
t.Fatalf("expected base dir with prefix %s; received %s", root, baseDir)
}
os.Setenv("MACHINE_STORAGE_PATH", "")
}
func TestGetDockerDir(t *testing.T) {
homeDir := GetHomeDir()
baseDir := GetBaseDir()
if strings.Index(baseDir, homeDir) != 0 {
t.Fatalf("expected base dir with prefix %s; received %s", homeDir, baseDir)
}
}
func TestGetMachineDir(t *testing.T) {
root := "/tmp"
os.Setenv("MACHINE_STORAGE_PATH", root)
machineDir := GetMachineDir()
if strings.Index(machineDir, root) != 0 {
t.Fatalf("expected machine dir with prefix %s; received %s", root, machineDir)
}
path, filename := path.Split(machineDir)
if strings.Index(path, root) != 0 {
t.Fatalf("expected base path of %s; received %s", root, path)
}
if filename != "machines" {
t.Fatalf("expected machine dir \"machines\"; received %s", filename)
}
os.Setenv("MACHINE_STORAGE_PATH", "")
}
func TestGetMachineCertDir(t *testing.T) {
root := "/tmp"
os.Setenv("MACHINE_STORAGE_PATH", root)
clientDir := GetMachineCertDir()
if strings.Index(clientDir, root) != 0 {
t.Fatalf("expected machine client cert dir with prefix %s; received %s", root, clientDir)
}
path, filename := path.Split(clientDir)
if strings.Index(path, root) != 0 {
t.Fatalf("expected base path of %s; received %s", root, path)
}
if filename != "certs" {
t.Fatalf("expected machine client dir \"certs\"; received %s", filename)
}
os.Setenv("MACHINE_STORAGE_PATH", "")
}
func TestCopyFile(t *testing.T) {
testStr := "test-machine"
srcFile, err := ioutil.TempFile("", "machine-test-")
if err != nil {
t.Fatal(err)
}
srcFi, err := srcFile.Stat()
if err != nil {
t.Fatal(err)
}
srcFile.Write([]byte(testStr))
srcFile.Close()
srcFilePath := filepath.Join(os.TempDir(), srcFi.Name())
destFile, err := ioutil.TempFile("", "machine-copy-test-")
if err != nil {
t.Fatal(err)
}
destFi, err := destFile.Stat()
if err != nil {
t.Fatal(err)
}
destFile.Close()
destFilePath := filepath.Join(os.TempDir(), destFi.Name())
if err := CopyFile(srcFilePath, destFilePath); err != nil {
t.Fatal(err)
}
data, err := ioutil.ReadFile(destFilePath)
if err != nil {
t.Fatal(err)
}
if string(data) != testStr {
t.Fatalf("expected data \"%s\"; received \"%\"", testStr, string(data))
}
}
func TestGetUsername(t *testing.T) {
currentUser := "unknown"
switch runtime.GOOS {
case "darwin", "linux":
currentUser = os.Getenv("USER")
case "windows":
currentUser = os.Getenv("USERNAME")
}
username := GetUsername()
if username != currentUser {
t.Fatalf("expected username %s; received %s", currentUser, username)
}
}