mirror of https://github.com/docker/docs.git
vbox: change to get latest released iso instead of pre-release
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com> vbox: fix windows share dir for homedir Signed-off-by: Evan Hazlett <ejhazlett@gmail.com> vbox: update tests for b2d Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
parent
ab31d52165
commit
e09f2fdd9c
|
|
@ -290,24 +290,7 @@ func (d *Driver) Create() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var shareDir string
|
shareDir := homedir.Get()
|
||||||
|
|
||||||
homePath := homedir.Get()
|
|
||||||
|
|
||||||
switch runtime.GOOS {
|
|
||||||
case "windows":
|
|
||||||
shareDir = homePath
|
|
||||||
mountDir, err := translateWindowsMount(homePath)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
shareDir = mountDir
|
|
||||||
case "darwin":
|
|
||||||
shareDir = homePath
|
|
||||||
case "linux":
|
|
||||||
shareDir = homePath
|
|
||||||
}
|
|
||||||
|
|
||||||
shareName := shareDir
|
shareName := shareDir
|
||||||
|
|
||||||
log.Debugf("creating share: path=%s", shareDir)
|
log.Debugf("creating share: path=%s", shareDir)
|
||||||
|
|
@ -321,12 +304,21 @@ func (d *Driver) Create() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if shareDir != "" {
|
if shareDir != "" {
|
||||||
|
log.Debugf("setting up shareDir")
|
||||||
if _, err := os.Stat(shareDir); err != nil && !os.IsNotExist(err) {
|
if _, err := os.Stat(shareDir); err != nil && !os.IsNotExist(err) {
|
||||||
|
log.Debugf("setting up share failed: %s", err)
|
||||||
return err
|
return err
|
||||||
} else if !os.IsNotExist(err) {
|
} else if !os.IsNotExist(err) {
|
||||||
if shareName != "" {
|
// parts of the VBox internal code are buggy with share names that start with "/"
|
||||||
// parts of the VBox internal code are buggy with share names that start with "/"
|
shareName = strings.TrimLeft(shareDir, "/")
|
||||||
shareName = strings.TrimLeft(shareDir, "/")
|
|
||||||
|
// translate to msys git path
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
mountName, err := translateWindowsMount(shareDir)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
shareName = mountName
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("adding shared folder: name=%q dir=%q", shareName, shareDir)
|
log.Debugf("adding shared folder: name=%q dir=%q", shareName, shareDir)
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ func (provisioner *DebianProvisioner) Service(name string, action pkgaction.Serv
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
command := fmt.Sprintf("sudo systemctl %s %s || true", action.String(), name)
|
command := fmt.Sprintf("sudo systemctl %s %s", action.String(), name)
|
||||||
|
|
||||||
if _, err := provisioner.SSHCommand(command); err != nil {
|
if _, err := provisioner.SSHCommand(command); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,24 @@ import (
|
||||||
|
|
||||||
"github.com/docker/machine/drivers/fakedriver"
|
"github.com/docker/machine/drivers/fakedriver"
|
||||||
"github.com/docker/machine/libmachine/auth"
|
"github.com/docker/machine/libmachine/auth"
|
||||||
|
"github.com/docker/machine/libmachine/engine"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func engineOptions() engine.EngineOptions {
|
||||||
|
return engine.EngineOptions{
|
||||||
|
StorageDriver: "aufs",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestGenerateDockerOptionsBoot2Docker(t *testing.T) {
|
func TestGenerateDockerOptionsBoot2Docker(t *testing.T) {
|
||||||
|
g := GenericProvisioner{
|
||||||
|
Driver: &fakedriver.FakeDriver{},
|
||||||
|
EngineOptions: engineOptions(),
|
||||||
|
}
|
||||||
p := &Boot2DockerProvisioner{
|
p := &Boot2DockerProvisioner{
|
||||||
Driver: &fakedriver.FakeDriver{},
|
DebianProvisioner{
|
||||||
|
g,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
dockerPort := 1234
|
dockerPort := 1234
|
||||||
p.AuthOptions = auth.AuthOptions{
|
p.AuthOptions = auth.AuthOptions{
|
||||||
|
|
@ -20,37 +33,38 @@ func TestGenerateDockerOptionsBoot2Docker(t *testing.T) {
|
||||||
ServerKeyRemotePath: "/test/server-key",
|
ServerKeyRemotePath: "/test/server-key",
|
||||||
ServerCertRemotePath: "/test/server-cert",
|
ServerCertRemotePath: "/test/server-cert",
|
||||||
}
|
}
|
||||||
engineConfigPath := "/var/lib/boot2docker/profile"
|
|
||||||
|
|
||||||
dockerCfg, err := p.GenerateDockerOptions(dockerPort)
|
dockerCfg, err := p.GenerateDockerOptions(dockerPort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if dockerCfg.EngineOptionsPath != engineConfigPath {
|
|
||||||
t.Fatalf("expected engine path %s; received %s", engineConfigPath, dockerCfg.EngineOptionsPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.Index(dockerCfg.EngineOptions, fmt.Sprintf("-H tcp://0.0.0.0:%d", dockerPort)) == -1 {
|
if strings.Index(dockerCfg.EngineOptions, fmt.Sprintf("-H tcp://0.0.0.0:%d", dockerPort)) == -1 {
|
||||||
t.Fatalf("-H docker port invalid; expected %d", dockerPort)
|
t.Fatalf("-H docker port invalid; expected %d", dockerPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Index(dockerCfg.EngineOptions, fmt.Sprintf("CACERT=%s", p.AuthOptions.CaCertRemotePath)) == -1 {
|
if strings.Index(dockerCfg.EngineOptions, fmt.Sprintf("--tlscacert %s", p.AuthOptions.CaCertRemotePath)) == -1 {
|
||||||
t.Fatalf("CACERT option invalid; expected %s", p.AuthOptions.CaCertRemotePath)
|
t.Fatalf("--tlscacert option invalid; expected %s", p.AuthOptions.CaCertRemotePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Index(dockerCfg.EngineOptions, fmt.Sprintf("SERVERKEY=%s", p.AuthOptions.ServerKeyRemotePath)) == -1 {
|
if strings.Index(dockerCfg.EngineOptions, fmt.Sprintf("--tlscert %s", p.AuthOptions.ServerCertRemotePath)) == -1 {
|
||||||
t.Fatalf("SERVERKEY option invalid; expected %s", p.AuthOptions.ServerKeyRemotePath)
|
t.Fatalf("--tlscert option invalid; expected %s", p.AuthOptions.ServerCertRemotePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Index(dockerCfg.EngineOptions, fmt.Sprintf("SERVERCERT=%s", p.AuthOptions.ServerCertRemotePath)) == -1 {
|
if strings.Index(dockerCfg.EngineOptions, fmt.Sprintf("--tlskey %s", p.AuthOptions.ServerKeyRemotePath)) == -1 {
|
||||||
t.Fatalf("SERVERCERT option invalid; expected %s", p.AuthOptions.ServerCertRemotePath)
|
t.Fatalf("--tlskey option invalid; expected %s", p.AuthOptions.ServerKeyRemotePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMachinePortBoot2Docker(t *testing.T) {
|
func TestMachinePortBoot2Docker(t *testing.T) {
|
||||||
|
g := GenericProvisioner{
|
||||||
|
Driver: &fakedriver.FakeDriver{},
|
||||||
|
EngineOptions: engineOptions(),
|
||||||
|
}
|
||||||
p := &Boot2DockerProvisioner{
|
p := &Boot2DockerProvisioner{
|
||||||
Driver: &fakedriver.FakeDriver{},
|
DebianProvisioner{
|
||||||
|
g,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
dockerPort := 2376
|
dockerPort := 2376
|
||||||
bindUrl := fmt.Sprintf("tcp://0.0.0.0:%d", dockerPort)
|
bindUrl := fmt.Sprintf("tcp://0.0.0.0:%d", dockerPort)
|
||||||
|
|
@ -81,8 +95,14 @@ func TestMachinePortBoot2Docker(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMachineCustomPortBoot2Docker(t *testing.T) {
|
func TestMachineCustomPortBoot2Docker(t *testing.T) {
|
||||||
|
g := GenericProvisioner{
|
||||||
|
Driver: &fakedriver.FakeDriver{},
|
||||||
|
EngineOptions: engineOptions(),
|
||||||
|
}
|
||||||
p := &Boot2DockerProvisioner{
|
p := &Boot2DockerProvisioner{
|
||||||
Driver: &fakedriver.FakeDriver{},
|
DebianProvisioner{
|
||||||
|
g,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
dockerPort := 3376
|
dockerPort := 3376
|
||||||
bindUrl := fmt.Sprintf("tcp://0.0.0.0:%d", dockerPort)
|
bindUrl := fmt.Sprintf("tcp://0.0.0.0:%d", dockerPort)
|
||||||
|
|
|
||||||
14
utils/b2d.go
14
utils/b2d.go
|
|
@ -80,7 +80,8 @@ func (b *B2dUtils) GetLatestBoot2DockerReleaseURL() (string, error) {
|
||||||
defer rsp.Body.Close()
|
defer rsp.Body.Close()
|
||||||
|
|
||||||
var t []struct {
|
var t []struct {
|
||||||
TagName string `json:"tag_name"`
|
TagName string `json:"tag_name"`
|
||||||
|
PreRelease bool `json:"prerelease"`
|
||||||
}
|
}
|
||||||
if err := json.NewDecoder(rsp.Body).Decode(&t); err != nil {
|
if err := json.NewDecoder(rsp.Body).Decode(&t); err != nil {
|
||||||
return "", fmt.Errorf("Error demarshaling the Github API response: %s\nYou may be getting rate limited by Github.", err)
|
return "", fmt.Errorf("Error demarshaling the Github API response: %s\nYou may be getting rate limited by Github.", err)
|
||||||
|
|
@ -89,8 +90,15 @@ func (b *B2dUtils) GetLatestBoot2DockerReleaseURL() (string, error) {
|
||||||
return "", fmt.Errorf("no releases found")
|
return "", fmt.Errorf("no releases found")
|
||||||
}
|
}
|
||||||
|
|
||||||
tag := t[0].TagName
|
// find the latest "released" release (i.e. not pre-release)
|
||||||
isoUrl := fmt.Sprintf("%s/boot2docker/boot2docker/releases/download/%s/boot2docker.iso", b.githubBaseUrl, tag)
|
isoUrl := ""
|
||||||
|
for _, r := range t {
|
||||||
|
if !r.PreRelease {
|
||||||
|
tag := r.TagName
|
||||||
|
isoUrl = fmt.Sprintf("%s/boot2docker/boot2docker/releases/download/%s/boot2docker.iso", b.githubBaseUrl, tag)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
return isoUrl, nil
|
return isoUrl, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
func TestGetLatestBoot2DockerReleaseUrl(t *testing.T) {
|
func TestGetLatestBoot2DockerReleaseUrl(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
respText := `[{"tag_name": "0.1"}]`
|
respText := `[{"tag_name": "0.2", "prerelease": true, "tag_name": "0.1", "prerelease": false}]`
|
||||||
w.Write([]byte(respText))
|
w.Write([]byte(respText))
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue