Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

add 3rd party docker extensions #1881

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 30 additions & 22 deletions commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/auth"
"github.com/docker/machine/libmachine/extension"
"github.com/docker/machine/libmachine/swarm"
"github.com/docker/machine/log"
"github.com/docker/machine/utils"
Expand All @@ -43,17 +44,18 @@ var (
)

type machineConfig struct {
machineName string
machineDir string
machineUrl string
clientKeyPath string
serverCertPath string
clientCertPath string
caCertPath string
caKeyPath string
serverKeyPath string
AuthOptions auth.AuthOptions
SwarmOptions swarm.SwarmOptions
machineName string
machineDir string
machineUrl string
clientKeyPath string
serverCertPath string
clientCertPath string
caCertPath string
caKeyPath string
serverKeyPath string
AuthOptions auth.AuthOptions
SwarmOptions swarm.SwarmOptions
ExtensionOptions extension.ExtensionOptions
}

func sortHostListItemsByName(items []libmachine.HostListItem) {
Expand Down Expand Up @@ -236,6 +238,11 @@ var sharedCreateFlags = []cli.Flag{
Usage: "addr to advertise for Swarm (default: detect and use the machine IP)",
Value: "",
},
cli.StringFlag{
Name: "extension",
Usage: "specify local path or network resource for the YAML or JSON extension file",
Value: "",
},
}

var Commands = []cli.Command{
Expand Down Expand Up @@ -609,17 +616,18 @@ func getMachineConfig(c *cli.Context) (*machineConfig, error) {
}
}
return &machineConfig{
machineName: name,
machineDir: machineDir,
machineUrl: machineUrl,
clientKeyPath: clientKey,
clientCertPath: clientCert,
serverCertPath: serverCert,
caKeyPath: caKey,
caCertPath: caCert,
serverKeyPath: serverKey,
AuthOptions: *m.HostOptions.AuthOptions,
SwarmOptions: *m.HostOptions.SwarmOptions,
machineName: name,
machineDir: machineDir,
machineUrl: machineUrl,
clientKeyPath: clientKey,
clientCertPath: clientCert,
serverCertPath: serverCert,
caKeyPath: caKey,
caCertPath: caCert,
serverKeyPath: serverKey,
AuthOptions: *m.HostOptions.AuthOptions,
SwarmOptions: *m.HostOptions.SwarmOptions,
ExtensionOptions: *m.HostOptions.ExtensionOptions,
}, nil
}

Expand Down
4 changes: 3 additions & 1 deletion commands/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/auth"
"github.com/docker/machine/libmachine/engine"
"github.com/docker/machine/libmachine/extension"
"github.com/docker/machine/libmachine/swarm"
)

Expand Down Expand Up @@ -48,7 +49,8 @@ func TestCmdConfig(t *testing.T) {
Address: "",
Host: "",
},
AuthOptions: &auth.AuthOptions{},
AuthOptions: &auth.AuthOptions{},
ExtensionOptions: &extension.ExtensionOptions{},
}

host, err := provider.Create("test-a", "none", hostOptions, flags)
Expand Down
4 changes: 4 additions & 0 deletions commands/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/auth"
"github.com/docker/machine/libmachine/engine"
"github.com/docker/machine/libmachine/extension"
"github.com/docker/machine/libmachine/swarm"
"github.com/docker/machine/utils"
)
Expand Down Expand Up @@ -93,6 +94,9 @@ func cmdCreate(c *cli.Context) {
Strategy: c.String("swarm-strategy"),
ArbitraryFlags: c.StringSlice("swarm-opt"),
},
ExtensionOptions: &extension.ExtensionOptions{
File: c.String("extension"),
},
}

_, err = provider.Create(name, driver, hostOptions, c)
Expand Down
10 changes: 7 additions & 3 deletions commands/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/auth"
"github.com/docker/machine/libmachine/engine"
"github.com/docker/machine/libmachine/extension"
"github.com/docker/machine/libmachine/swarm"
)

Expand Down Expand Up @@ -56,7 +57,8 @@ func TestCmdEnvBash(t *testing.T) {
Address: "",
Host: "",
},
AuthOptions: &auth.AuthOptions{},
AuthOptions: &auth.AuthOptions{},
ExtensionOptions: &extension.ExtensionOptions{},
}

host, err := provider.Create("test-a", "none", hostOptions, flags)
Expand Down Expand Up @@ -155,7 +157,8 @@ func TestCmdEnvFish(t *testing.T) {
Address: "",
Host: "",
},
AuthOptions: &auth.AuthOptions{},
AuthOptions: &auth.AuthOptions{},
ExtensionOptions: &extension.ExtensionOptions{},
}

host, err := provider.Create("test-a", "none", hostOptions, flags)
Expand Down Expand Up @@ -254,7 +257,8 @@ func TestCmdEnvPowerShell(t *testing.T) {
Address: "",
Host: "",
},
AuthOptions: &auth.AuthOptions{},
AuthOptions: &auth.AuthOptions{},
ExtensionOptions: &extension.ExtensionOptions{},
}

host, err := provider.Create("test-a", "none", hostOptions, flags)
Expand Down
4 changes: 3 additions & 1 deletion commands/inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/auth"
"github.com/docker/machine/libmachine/engine"
"github.com/docker/machine/libmachine/extension"
"github.com/docker/machine/libmachine/swarm"
"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -86,7 +87,8 @@ func runInspectCommand(t *testing.T, args []string) (string, *libmachine.Host) {
Address: "",
Host: "",
},
AuthOptions: &auth.AuthOptions{},
AuthOptions: &auth.AuthOptions{},
ExtensionOptions: &extension.ExtensionOptions{},
}

flags := getTestDriverFlags()
Expand Down
Loading