diff --git a/Makefile b/Makefile index 2d8623750..569c96f47 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ cli: ## Compile the cli --output ./bin e2e-local: ## Run End to end local tests - go test -v ./tests/e2e ./tests/skip-win-ci-e2e ./moby/e2e + go test -v ./tests/e2e ./tests/skip-win-ci-e2e ./local/e2e e2e-win-ci: ## Run End to end local tests on windows CI, no docker for linux containers available ATM go test -v ./tests/e2e diff --git a/cli/cmd/context/create.go b/cli/cmd/context/create.go index b5533cbc8..bfbfea1a3 100644 --- a/cli/cmd/context/create.go +++ b/cli/cmd/context/create.go @@ -83,7 +83,7 @@ $ docker context create my-context --description "some description" --docker "ho cmd.AddCommand( createAciCommand(), - createMobyCommand(), + createLocalCommand(), createExampleCommand(), ) @@ -99,15 +99,15 @@ $ docker context create my-context --description "some description" --docker "ho return cmd } -func createMobyCommand() *cobra.Command { +func createLocalCommand() *cobra.Command { var opts descriptionCreateOpts cmd := &cobra.Command{ - Use: "moby CONTEXT", - Short: "Create a context for accessing docker engine with new CLI commands", + Use: "local CONTEXT", + Short: "Create a context for accessing local engine", Args: cobra.ExactArgs(1), Hidden: true, RunE: func(cmd *cobra.Command, args []string) error { - return createDockerContext(cmd.Context(), args[0], store.MobyContextType, opts.description, store.MobyContext{}) + return createDockerContext(cmd.Context(), args[0], store.LocalContextType, opts.description, store.LocalContext{}) }, } addDescriptionFlag(cmd, &opts.description) diff --git a/cli/main.go b/cli/main.go index c097aaba0..540c56fed 100644 --- a/cli/main.go +++ b/cli/main.go @@ -45,7 +45,7 @@ import ( // Backend registrations _ "github.com/docker/api/azure" _ "github.com/docker/api/example" - _ "github.com/docker/api/moby" + _ "github.com/docker/api/local" "github.com/docker/api/cli/cmd" "github.com/docker/api/cli/cmd/compose" diff --git a/config/config_test.go b/config/config_test.go index a0d8ac217..5f94639ee 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -39,7 +39,7 @@ import ( var sampleConfig = []byte(`{ "otherField": "value", - "currentContext": "moby" + "currentContext": "local" }`) type ConfigTestSuite struct { @@ -66,14 +66,14 @@ func (s *ConfigTestSuite) TestLoadFile() { writeSampleConfig(s.T(), s.configDir) f, err := LoadFile(s.configDir) require.NoError(s.T(), err) - require.Equal(s.T(), "moby", f.CurrentContext) + require.Equal(s.T(), "local", f.CurrentContext) } func (s *ConfigTestSuite) TestOverWriteCurrentContext() { writeSampleConfig(s.T(), s.configDir) f, err := LoadFile(s.configDir) require.NoError(s.T(), err) - require.Equal(s.T(), "moby", f.CurrentContext) + require.Equal(s.T(), "local", f.CurrentContext) err = WriteCurrentContext(s.configDir, "overwrite") require.NoError(s.T(), err) diff --git a/context/store/contextmetadata.go b/context/store/contextmetadata.go index a6ab560d6..a9987dfd8 100644 --- a/context/store/contextmetadata.go +++ b/context/store/contextmetadata.go @@ -33,8 +33,8 @@ type AciContext struct { ResourceGroup string `json:",omitempty"` } -// MobyContext is the context for the moby backend -type MobyContext struct{} +// LocalContext is the context for the local backend +type LocalContext struct{} // ExampleContext is the context for the example backend type ExampleContext struct{} diff --git a/context/store/store.go b/context/store/store.go index ccb4f65c9..53355c0df 100644 --- a/context/store/store.go +++ b/context/store/store.go @@ -96,9 +96,8 @@ const ( // AciContextType is the endpoint key in the context endpoints for an ACI // backend AciContextType = "aci" - // MobyContextType is the endpoint key in the context endpoints for a moby - // backend - MobyContextType = "moby" + // LocalContextType is the endpoint key in the context endpoints for a new local backend + LocalContextType = "local" // ExampleContextType is the endpoint key in the context endpoints for an // example backend ExampleContextType = "example" @@ -335,8 +334,8 @@ func getters() map[string]func() interface{} { "aci": func() interface{} { return &AciContext{} }, - "moby": func() interface{} { - return &MobyContext{} + "local": func() interface{} { + return &LocalContext{} }, "example": func() interface{} { return &ExampleContext{} diff --git a/docs/cli/overview-of-the-cli.md b/docs/cli/overview-of-the-cli.md index b7bb66ca0..b2c043dba 100644 --- a/docs/cli/overview-of-the-cli.md +++ b/docs/cli/overview-of-the-cli.md @@ -26,7 +26,7 @@ Insert a really small tutorial or links here. We have made some changes to the syntax of a few commands to make them easier to understand. Where we still support the old forms, the command line will tell you the new form, but will still work correctly. In cases where we remove the old form you will get help text. If we remove a verb, for example "docker stack" we will display a message saying that the command -is only available with the Moby backend. For example +is only available with the Local backend. For example ``` > docker context create my-context --description "some description" --docker "host=tcp://myserver:2376" diff --git a/moby/backend.go b/local/backend.go similarity index 85% rename from moby/backend.go rename to local/backend.go index 92796a589..abefd57ab 100644 --- a/moby/backend.go +++ b/local/backend.go @@ -1,4 +1,4 @@ -package moby +package local import ( "bufio" @@ -24,12 +24,12 @@ import ( "github.com/docker/api/errdefs" ) -type mobyService struct { +type local struct { apiClient *client.Client } func init() { - backend.Register("moby", "moby", service, cloud.NotImplementedCloudService) + backend.Register("local", "local", service, cloud.NotImplementedCloudService) } func service(ctx context.Context) (backend.Service, error) { @@ -38,20 +38,20 @@ func service(ctx context.Context) (backend.Service, error) { return nil, err } - return &mobyService{ + return &local{ apiClient, }, nil } -func (ms *mobyService) ContainerService() containers.Service { +func (ms *local) ContainerService() containers.Service { return ms } -func (ms *mobyService) ComposeService() compose.Service { +func (ms *local) ComposeService() compose.Service { return nil } -func (ms *mobyService) List(ctx context.Context, all bool) ([]containers.Container, error) { +func (ms *local) List(ctx context.Context, all bool) ([]containers.Container, error) { css, err := ms.apiClient.ContainerList(ctx, types.ContainerListOptions{ All: all, }) @@ -78,7 +78,7 @@ func (ms *mobyService) List(ctx context.Context, all bool) ([]containers.Contain return result, nil } -func (ms *mobyService) Run(ctx context.Context, r containers.ContainerConfig) error { +func (ms *local) Run(ctx context.Context, r containers.ContainerConfig) error { exposedPorts, hostBindings, err := fromPorts(r.Ports) if err != nil { return err @@ -125,7 +125,7 @@ func (ms *mobyService) Run(ctx context.Context, r containers.ContainerConfig) er return ms.apiClient.ContainerStart(ctx, created.ID, types.ContainerStartOptions{}) } -func (ms *mobyService) Stop(ctx context.Context, containerID string, timeout *uint32) error { +func (ms *local) Stop(ctx context.Context, containerID string, timeout *uint32) error { var t *time.Duration if timeout != nil { timeoutValue := time.Duration(*timeout) * time.Second @@ -134,7 +134,7 @@ func (ms *mobyService) Stop(ctx context.Context, containerID string, timeout *ui return ms.apiClient.ContainerStop(ctx, containerID, t) } -func (ms *mobyService) Exec(ctx context.Context, name string, command string, reader io.Reader, writer io.Writer) error { +func (ms *local) Exec(ctx context.Context, name string, command string, reader io.Reader, writer io.Writer) error { cec, err := ms.apiClient.ContainerExecCreate(ctx, name, types.ExecConfig{ Cmd: []string{command}, Tty: true, @@ -176,7 +176,7 @@ func (ms *mobyService) Exec(ctx context.Context, name string, command string, re } } -func (ms *mobyService) Logs(ctx context.Context, containerName string, request containers.LogsRequest) error { +func (ms *local) Logs(ctx context.Context, containerName string, request containers.LogsRequest) error { c, err := ms.apiClient.ContainerInspect(ctx, containerName) if err != nil { return err @@ -204,7 +204,7 @@ func (ms *mobyService) Logs(ctx context.Context, containerName string, request c return err } -func (ms *mobyService) Delete(ctx context.Context, containerID string, force bool) error { +func (ms *local) Delete(ctx context.Context, containerID string, force bool) error { err := ms.apiClient.ContainerRemove(ctx, containerID, types.ContainerRemoveOptions{ Force: force, }) diff --git a/moby/e2e/backend_test.go b/local/e2e/backend_test.go similarity index 70% rename from moby/e2e/backend_test.go rename to local/e2e/backend_test.go index df92ae582..c719060a3 100644 --- a/moby/e2e/backend_test.go +++ b/local/e2e/backend_test.go @@ -11,26 +11,26 @@ import ( "github.com/docker/api/tests/framework" ) -type MobyBackendTestSuite struct { +type LocalBackendTestSuite struct { framework.Suite } -func (m *MobyBackendTestSuite) BeforeTest(suiteName string, testName string) { - m.NewDockerCommand("context", "create", "moby", "test-context").ExecOrDie() +func (m *LocalBackendTestSuite) BeforeTest(suiteName string, testName string) { + m.NewDockerCommand("context", "create", "local", "test-context").ExecOrDie() m.NewDockerCommand("context", "use", "test-context").ExecOrDie() } -func (m *MobyBackendTestSuite) AfterTest(suiteName string, testName string) { +func (m *LocalBackendTestSuite) AfterTest(suiteName string, testName string) { m.NewDockerCommand("context", "rm", "test-context").ExecOrDie() m.NewDockerCommand("context", "use", "default").ExecOrDie() } -func (m *MobyBackendTestSuite) TestPs() { +func (m *LocalBackendTestSuite) TestPs() { out := m.NewDockerCommand("ps").ExecOrDie() require.Equal(m.T(), "CONTAINER ID IMAGE COMMAND STATUS PORTS\n", out) } -func (m *MobyBackendTestSuite) TestRun() { +func (m *LocalBackendTestSuite) TestRun() { _, err := m.NewDockerCommand("run", "--name", "nginx", "nginx").Exec() require.Nil(m.T(), err) out := m.NewDockerCommand("ps").ExecOrDie() @@ -41,7 +41,7 @@ func (m *MobyBackendTestSuite) TestRun() { assert.Equal(m.T(), 3, len(lines)) } -func (m *MobyBackendTestSuite) TestRunWithPorts() { +func (m *LocalBackendTestSuite) TestRunWithPorts() { _, err := m.NewDockerCommand("run", "--name", "nginx", "-p", "8080:80", "nginx").Exec() require.Nil(m.T(), err) out := m.NewDockerCommand("ps").ExecOrDie() @@ -51,6 +51,6 @@ func (m *MobyBackendTestSuite) TestRunWithPorts() { assert.Contains(m.T(), out, "8080") } -func TestMobyBackendTestSuite(t *testing.T) { - suite.Run(t, new(MobyBackendTestSuite)) +func TestLocalBackendTestSuite(t *testing.T) { + suite.Run(t, new(LocalBackendTestSuite)) }