Explorar el Código

Renamed Moby backend to “local” backend. This will leave “moby” available for default type contexts

Guillaume Tardif hace 5 años
padre
commit
0de2522079

+ 1 - 1
Makefile

@@ -45,7 +45,7 @@ cli: ## Compile the cli
 	--output ./bin
 	--output ./bin
 
 
 e2e-local: ## Run End to end local tests
 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
 e2e-win-ci: ## Run End to end local tests on windows CI, no docker for linux containers available ATM
 	go test -v ./tests/e2e
 	go test -v ./tests/e2e

+ 5 - 5
cli/cmd/context/create.go

@@ -83,7 +83,7 @@ $ docker context create my-context --description "some description" --docker "ho
 
 
 	cmd.AddCommand(
 	cmd.AddCommand(
 		createAciCommand(),
 		createAciCommand(),
-		createMobyCommand(),
+		createLocalCommand(),
 		createExampleCommand(),
 		createExampleCommand(),
 	)
 	)
 
 
@@ -99,15 +99,15 @@ $ docker context create my-context --description "some description" --docker "ho
 	return cmd
 	return cmd
 }
 }
 
 
-func createMobyCommand() *cobra.Command {
+func createLocalCommand() *cobra.Command {
 	var opts descriptionCreateOpts
 	var opts descriptionCreateOpts
 	cmd := &cobra.Command{
 	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),
 		Args:   cobra.ExactArgs(1),
 		Hidden: true,
 		Hidden: true,
 		RunE: func(cmd *cobra.Command, args []string) error {
 		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)
 	addDescriptionFlag(cmd, &opts.description)

+ 1 - 1
cli/main.go

@@ -45,7 +45,7 @@ import (
 	// Backend registrations
 	// Backend registrations
 	_ "github.com/docker/api/azure"
 	_ "github.com/docker/api/azure"
 	_ "github.com/docker/api/example"
 	_ "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"
 	"github.com/docker/api/cli/cmd/compose"
 	"github.com/docker/api/cli/cmd/compose"

+ 3 - 3
config/config_test.go

@@ -39,7 +39,7 @@ import (
 
 
 var sampleConfig = []byte(`{
 var sampleConfig = []byte(`{
 	"otherField": "value",
 	"otherField": "value",
-	"currentContext": "moby"
+	"currentContext": "local"
 }`)
 }`)
 
 
 type ConfigTestSuite struct {
 type ConfigTestSuite struct {
@@ -66,14 +66,14 @@ func (s *ConfigTestSuite) TestLoadFile() {
 	writeSampleConfig(s.T(), s.configDir)
 	writeSampleConfig(s.T(), s.configDir)
 	f, err := LoadFile(s.configDir)
 	f, err := LoadFile(s.configDir)
 	require.NoError(s.T(), err)
 	require.NoError(s.T(), err)
-	require.Equal(s.T(), "moby", f.CurrentContext)
+	require.Equal(s.T(), "local", f.CurrentContext)
 }
 }
 
 
 func (s *ConfigTestSuite) TestOverWriteCurrentContext() {
 func (s *ConfigTestSuite) TestOverWriteCurrentContext() {
 	writeSampleConfig(s.T(), s.configDir)
 	writeSampleConfig(s.T(), s.configDir)
 	f, err := LoadFile(s.configDir)
 	f, err := LoadFile(s.configDir)
 	require.NoError(s.T(), err)
 	require.NoError(s.T(), err)
-	require.Equal(s.T(), "moby", f.CurrentContext)
+	require.Equal(s.T(), "local", f.CurrentContext)
 
 
 	err = WriteCurrentContext(s.configDir, "overwrite")
 	err = WriteCurrentContext(s.configDir, "overwrite")
 	require.NoError(s.T(), err)
 	require.NoError(s.T(), err)

+ 2 - 2
context/store/contextmetadata.go

@@ -33,8 +33,8 @@ type AciContext struct {
 	ResourceGroup  string `json:",omitempty"`
 	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
 // ExampleContext is the context for the example backend
 type ExampleContext struct{}
 type ExampleContext struct{}

+ 4 - 5
context/store/store.go

@@ -96,9 +96,8 @@ const (
 	// AciContextType is the endpoint key in the context endpoints for an ACI
 	// AciContextType is the endpoint key in the context endpoints for an ACI
 	// backend
 	// backend
 	AciContextType = "aci"
 	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
 	// ExampleContextType is the endpoint key in the context endpoints for an
 	// example backend
 	// example backend
 	ExampleContextType = "example"
 	ExampleContextType = "example"
@@ -335,8 +334,8 @@ func getters() map[string]func() interface{} {
 		"aci": func() interface{} {
 		"aci": func() interface{} {
 			return &AciContext{}
 			return &AciContext{}
 		},
 		},
-		"moby": func() interface{} {
-			return &MobyContext{}
+		"local": func() interface{} {
+			return &LocalContext{}
 		},
 		},
 		"example": func() interface{} {
 		"example": func() interface{} {
 			return &ExampleContext{}
 			return &ExampleContext{}

+ 1 - 1
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
 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
 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
 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"
 > docker context create my-context --description "some description" --docker "host=tcp://myserver:2376"

+ 12 - 12
moby/backend.go → local/backend.go

@@ -1,4 +1,4 @@
-package moby
+package local
 
 
 import (
 import (
 	"bufio"
 	"bufio"
@@ -24,12 +24,12 @@ import (
 	"github.com/docker/api/errdefs"
 	"github.com/docker/api/errdefs"
 )
 )
 
 
-type mobyService struct {
+type local struct {
 	apiClient *client.Client
 	apiClient *client.Client
 }
 }
 
 
 func init() {
 func init() {
-	backend.Register("moby", "moby", service, cloud.NotImplementedCloudService)
+	backend.Register("local", "local", service, cloud.NotImplementedCloudService)
 }
 }
 
 
 func service(ctx context.Context) (backend.Service, error) {
 func service(ctx context.Context) (backend.Service, error) {
@@ -38,20 +38,20 @@ func service(ctx context.Context) (backend.Service, error) {
 		return nil, err
 		return nil, err
 	}
 	}
 
 
-	return &mobyService{
+	return &local{
 		apiClient,
 		apiClient,
 	}, nil
 	}, nil
 }
 }
 
 
-func (ms *mobyService) ContainerService() containers.Service {
+func (ms *local) ContainerService() containers.Service {
 	return ms
 	return ms
 }
 }
 
 
-func (ms *mobyService) ComposeService() compose.Service {
+func (ms *local) ComposeService() compose.Service {
 	return nil
 	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{
 	css, err := ms.apiClient.ContainerList(ctx, types.ContainerListOptions{
 		All: all,
 		All: all,
 	})
 	})
@@ -78,7 +78,7 @@ func (ms *mobyService) List(ctx context.Context, all bool) ([]containers.Contain
 	return result, nil
 	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)
 	exposedPorts, hostBindings, err := fromPorts(r.Ports)
 	if err != nil {
 	if err != nil {
 		return err
 		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{})
 	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
 	var t *time.Duration
 	if timeout != nil {
 	if timeout != nil {
 		timeoutValue := time.Duration(*timeout) * time.Second
 		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)
 	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{
 	cec, err := ms.apiClient.ContainerExecCreate(ctx, name, types.ExecConfig{
 		Cmd:          []string{command},
 		Cmd:          []string{command},
 		Tty:          true,
 		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)
 	c, err := ms.apiClient.ContainerInspect(ctx, containerName)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
@@ -204,7 +204,7 @@ func (ms *mobyService) Logs(ctx context.Context, containerName string, request c
 	return err
 	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{
 	err := ms.apiClient.ContainerRemove(ctx, containerID, types.ContainerRemoveOptions{
 		Force: force,
 		Force: force,
 	})
 	})

+ 9 - 9
moby/e2e/backend_test.go → local/e2e/backend_test.go

@@ -11,26 +11,26 @@ import (
 	"github.com/docker/api/tests/framework"
 	"github.com/docker/api/tests/framework"
 )
 )
 
 
-type MobyBackendTestSuite struct {
+type LocalBackendTestSuite struct {
 	framework.Suite
 	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()
 	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", "rm", "test-context").ExecOrDie()
 	m.NewDockerCommand("context", "use", "default").ExecOrDie()
 	m.NewDockerCommand("context", "use", "default").ExecOrDie()
 }
 }
 
 
-func (m *MobyBackendTestSuite) TestPs() {
+func (m *LocalBackendTestSuite) TestPs() {
 	out := m.NewDockerCommand("ps").ExecOrDie()
 	out := m.NewDockerCommand("ps").ExecOrDie()
 	require.Equal(m.T(), "CONTAINER ID        IMAGE               COMMAND             STATUS              PORTS\n", out)
 	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()
 	_, err := m.NewDockerCommand("run", "--name", "nginx", "nginx").Exec()
 	require.Nil(m.T(), err)
 	require.Nil(m.T(), err)
 	out := m.NewDockerCommand("ps").ExecOrDie()
 	out := m.NewDockerCommand("ps").ExecOrDie()
@@ -41,7 +41,7 @@ func (m *MobyBackendTestSuite) TestRun() {
 	assert.Equal(m.T(), 3, len(lines))
 	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()
 	_, err := m.NewDockerCommand("run", "--name", "nginx", "-p", "8080:80", "nginx").Exec()
 	require.Nil(m.T(), err)
 	require.Nil(m.T(), err)
 	out := m.NewDockerCommand("ps").ExecOrDie()
 	out := m.NewDockerCommand("ps").ExecOrDie()
@@ -51,6 +51,6 @@ func (m *MobyBackendTestSuite) TestRunWithPorts() {
 	assert.Contains(m.T(), out, "8080")
 	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))
 }
 }