mirror of
https://github.com/docker/compose.git
synced 2025-07-27 07:34:10 +02:00
rename packages ( amazon to ecs and azure to aci )
Signed-off-by: aiordache <anca.iordache@docker.com>
This commit is contained in:
parent
2471e51b39
commit
87245ef727
19
.vscode/launch.json
vendored
Normal file
19
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Launch",
|
||||||
|
"type": "go",
|
||||||
|
"request": "launch",
|
||||||
|
"mode": "auto",
|
||||||
|
"program": "${workspaceRoot}/cli/main.go",
|
||||||
|
"env": {},
|
||||||
|
"cwd": "${workspaceRoot}/test/",
|
||||||
|
//"args": ["context", "create", "aws", "ecs", --profile", "sandbox.devtools.developer", "--region", "eu-west-3", "--description", "My ECS account"]
|
||||||
|
"args":["compose", "up"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -14,7 +14,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package azure
|
package aci
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -33,8 +33,8 @@ import (
|
|||||||
"github.com/morikuni/aec"
|
"github.com/morikuni/aec"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/docker/api/azure/convert"
|
"github.com/docker/api/aci/convert"
|
||||||
"github.com/docker/api/azure/login"
|
"github.com/docker/api/aci/login"
|
||||||
"github.com/docker/api/containers"
|
"github.com/docker/api/containers"
|
||||||
"github.com/docker/api/context/store"
|
"github.com/docker/api/context/store"
|
||||||
"github.com/docker/api/progress"
|
"github.com/docker/api/progress"
|
@ -1,4 +1,4 @@
|
|||||||
package azure
|
package aci
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
@ -14,7 +14,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package azure
|
package aci
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -30,8 +30,8 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/docker/api/azure/convert"
|
"github.com/docker/api/aci/convert"
|
||||||
"github.com/docker/api/azure/login"
|
"github.com/docker/api/aci/login"
|
||||||
"github.com/docker/api/backend"
|
"github.com/docker/api/backend"
|
||||||
"github.com/docker/api/compose"
|
"github.com/docker/api/compose"
|
||||||
"github.com/docker/api/containers"
|
"github.com/docker/api/containers"
|
||||||
@ -41,6 +41,8 @@ import (
|
|||||||
"github.com/docker/api/errdefs"
|
"github.com/docker/api/errdefs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const backendType = store.AciContextType
|
||||||
|
|
||||||
const (
|
const (
|
||||||
singleContainerTag = "docker-single-container"
|
singleContainerTag = "docker-single-container"
|
||||||
composeContainerTag = "docker-compose-application"
|
composeContainerTag = "docker-compose-application"
|
||||||
@ -65,7 +67,7 @@ type LoginParams struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
backend.Register("aci", "aci", service, getCloudService)
|
backend.Register(backendType, backendType, service, getCloudService)
|
||||||
}
|
}
|
||||||
|
|
||||||
func service(ctx context.Context) (backend.Service, error) {
|
func service(ctx context.Context) (backend.Service, error) {
|
@ -14,7 +14,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package azure
|
package aci
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -14,7 +14,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package azure
|
package aci
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -14,7 +14,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package azure
|
package aci
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -14,7 +14,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package azure
|
package aci
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1 +0,0 @@
|
|||||||
package amazon
|
|
@ -76,7 +76,6 @@ $ docker context create my-context --description "some description" --docker "ho
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
createAciCommand(),
|
|
||||||
createLocalCommand(),
|
createLocalCommand(),
|
||||||
createExampleCommand(),
|
createExampleCommand(),
|
||||||
)
|
)
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/docker/api/azure"
|
"github.com/docker/api/aci"
|
||||||
"github.com/docker/api/client"
|
"github.com/docker/api/client"
|
||||||
"github.com/docker/api/context/store"
|
"github.com/docker/api/context/store"
|
||||||
"github.com/docker/api/errdefs"
|
"github.com/docker/api/errdefs"
|
||||||
@ -38,7 +38,7 @@ $ docker context create aci CONTEXT [flags]
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createAciCommand() *cobra.Command {
|
func createAciCommand() *cobra.Command {
|
||||||
var opts azure.ContextParams
|
var opts aci.ContextParams
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "aci CONTEXT [flags]",
|
Use: "aci CONTEXT [flags]",
|
||||||
Short: "Create a context for Azure Container Instances",
|
Short: "Create a context for Azure Container Instances",
|
||||||
@ -56,7 +56,7 @@ func createAciCommand() *cobra.Command {
|
|||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func runCreateAci(ctx context.Context, contextName string, opts azure.ContextParams) error {
|
func runCreateAci(ctx context.Context, contextName string, opts aci.ContextParams) error {
|
||||||
if contextExists(ctx, contextName) {
|
if contextExists(ctx, contextName) {
|
||||||
return errors.Wrapf(errdefs.ErrAlreadyExists, "context %s", contextName)
|
return errors.Wrapf(errdefs.ErrAlreadyExists, "context %s", contextName)
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ func runCreateAci(ctx context.Context, contextName string, opts azure.ContextPar
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAciContextData(ctx context.Context, opts azure.ContextParams) (interface{}, string, error) {
|
func getAciContextData(ctx context.Context, opts aci.ContextParams) (interface{}, string, error) {
|
||||||
cs, err := client.GetCloudService(ctx, store.AciContextType)
|
cs, err := client.GetCloudService(ctx, store.AciContextType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", errors.Wrap(err, "cannot connect to ACI backend")
|
return nil, "", errors.Wrap(err, "cannot connect to ACI backend")
|
@ -24,9 +24,9 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/docker/api/amazon"
|
|
||||||
"github.com/docker/api/client"
|
"github.com/docker/api/client"
|
||||||
"github.com/docker/api/context/store"
|
"github.com/docker/api/context/store"
|
||||||
|
"github.com/docker/api/ecs"
|
||||||
"github.com/docker/api/errdefs"
|
"github.com/docker/api/errdefs"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ $ docker context create ecs CONTEXT [flags]
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createEcsCommand() *cobra.Command {
|
func createEcsCommand() *cobra.Command {
|
||||||
var opts amazon.ContextParams
|
var opts ecs.ContextParams
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "ecs CONTEXT [flags]",
|
Use: "ecs CONTEXT [flags]",
|
||||||
Short: "Create a context for Amazon ECS",
|
Short: "Create a context for Amazon ECS",
|
||||||
@ -58,9 +58,9 @@ func createEcsCommand() *cobra.Command {
|
|||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func runCreateEcs(ctx context.Context, contextName string, opts amazon.ContextParams) error {
|
func runCreateEcs(ctx context.Context, contextName string, opts ecs.ContextParams) error {
|
||||||
if contextExists(ctx, contextName) {
|
if contextExists(ctx, contextName) {
|
||||||
return errors.Wrapf(errdefs.ErrAlreadyExists, "context %s", contextName)
|
return errors.Wrapf(errdefs.ErrAlreadyExists, "context %q", contextName)
|
||||||
}
|
}
|
||||||
contextData, description, err := getEcsContextData(ctx, opts)
|
contextData, description, err := getEcsContextData(ctx, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -70,7 +70,7 @@ func runCreateEcs(ctx context.Context, contextName string, opts amazon.ContextPa
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getEcsContextData(ctx context.Context, opts amazon.ContextParams) (interface{}, string, error) {
|
func getEcsContextData(ctx context.Context, opts ecs.ContextParams) (interface{}, string, error) {
|
||||||
cs, err := client.GetCloudService(ctx, store.EcsContextType)
|
cs, err := client.GetCloudService(ctx, store.EcsContextType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", errors.Wrap(err, "cannot connect to AWS backend")
|
return nil, "", errors.Wrap(err, "cannot connect to AWS backend")
|
@ -3,12 +3,12 @@ package login
|
|||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/docker/api/azure"
|
"github.com/docker/api/aci"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AzureLoginCommand returns the azure login command
|
// AzureLoginCommand returns the azure login command
|
||||||
func AzureLoginCommand() *cobra.Command {
|
func AzureLoginCommand() *cobra.Command {
|
||||||
opts := azure.LoginParams{}
|
opts := aci.LoginParams{}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "azure",
|
Use: "azure",
|
||||||
Short: "Log in to azure",
|
Short: "Log in to azure",
|
||||||
|
@ -36,8 +36,8 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
// Backend registrations
|
// Backend registrations
|
||||||
_ "github.com/docker/api/amazon"
|
_ "github.com/docker/api/aci"
|
||||||
_ "github.com/docker/api/azure"
|
_ "github.com/docker/api/ecs"
|
||||||
_ "github.com/docker/api/example"
|
_ "github.com/docker/api/example"
|
||||||
_ "github.com/docker/api/local"
|
_ "github.com/docker/api/local"
|
||||||
"github.com/docker/api/metrics"
|
"github.com/docker/api/metrics"
|
||||||
|
9
cli/mobycli/delegate_ecs.go
Normal file
9
cli/mobycli/delegate_ecs.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// +build !ecs
|
||||||
|
|
||||||
|
package mobycli
|
||||||
|
|
||||||
|
import "github.com/docker/api/context/store"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
delegatedContextTypes = append(delegatedContextTypes, store.AwsContextType, store.EcsContextType)
|
||||||
|
}
|
@ -29,6 +29,8 @@ import (
|
|||||||
"github.com/docker/api/context/store"
|
"github.com/docker/api/context/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var delegatedContextTypes = []string{store.DefaultContextType}
|
||||||
|
|
||||||
// ComDockerCli name of the classic cli binary
|
// ComDockerCli name of the classic cli binary
|
||||||
const ComDockerCli = "com.docker.cli"
|
const ComDockerCli = "com.docker.cli"
|
||||||
|
|
||||||
@ -46,7 +48,12 @@ func ExecIfDefaultCtxType(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func mustDelegateToMoby(ctxType string) bool {
|
func mustDelegateToMoby(ctxType string) bool {
|
||||||
return ctxType == store.DefaultContextType
|
for _, ctype := range delegatedContextTypes {
|
||||||
|
if ctxType == ctype {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exec delegates to com.docker.cli if on moby context
|
// Exec delegates to com.docker.cli if on moby context
|
||||||
|
@ -55,6 +55,9 @@ type EcsContext struct {
|
|||||||
Region string `json:",omitempty"`
|
Region string `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AwsContext is the context for the ecs plugin
|
||||||
|
type AwsContext EcsContext
|
||||||
|
|
||||||
// LocalContext is the context for the local backend
|
// LocalContext is the context for the local backend
|
||||||
type LocalContext struct{}
|
type LocalContext struct{}
|
||||||
|
|
||||||
|
@ -36,7 +36,13 @@ const (
|
|||||||
DefaultContextName = "default"
|
DefaultContextName = "default"
|
||||||
// DefaultContextType is the type for all moby contexts (not associated with cli backend)
|
// DefaultContextType is the type for all moby contexts (not associated with cli backend)
|
||||||
DefaultContextType = "moby"
|
DefaultContextType = "moby"
|
||||||
// EcsContextType is the type for ecs contexts (currently a CLI plugin, not associated with cli backend)
|
|
||||||
|
// AwsContextType is the type for aws contexts (currently a CLI plugin, not associated with cli backend)
|
||||||
|
// to be removed with the cli plugin
|
||||||
|
AwsContextType = "aws"
|
||||||
|
|
||||||
|
// EcsContextType is the endpoint key in the context endpoints for an ECS
|
||||||
|
// backend
|
||||||
EcsContextType = "ecs"
|
EcsContextType = "ecs"
|
||||||
// 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
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package amazon
|
package ecs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -25,7 +25,7 @@ import (
|
|||||||
"github.com/docker/api/context/cloud"
|
"github.com/docker/api/context/cloud"
|
||||||
"github.com/docker/api/context/store"
|
"github.com/docker/api/context/store"
|
||||||
"github.com/docker/api/errdefs"
|
"github.com/docker/api/errdefs"
|
||||||
ecs "github.com/docker/ecs-plugin/pkg/amazon/backend"
|
ecsplugin "github.com/docker/ecs-plugin/pkg/amazon/backend"
|
||||||
)
|
)
|
||||||
|
|
||||||
const backendType = store.EcsContextType
|
const backendType = store.EcsContextType
|
||||||
@ -57,7 +57,7 @@ func service(ctx context.Context) (backend.Service, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getEcsAPIService(ecsCtx store.EcsContext) (*ecsAPIService, error) {
|
func getEcsAPIService(ecsCtx store.EcsContext) (*ecsAPIService, error) {
|
||||||
backend, err := ecs.NewBackend(ecsCtx.Profile, ecsCtx.Region)
|
backend, err := ecsplugin.NewBackend(ecsCtx.Profile, ecsCtx.Region)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ func getEcsAPIService(ecsCtx store.EcsContext) (*ecsAPIService, error) {
|
|||||||
|
|
||||||
type ecsAPIService struct {
|
type ecsAPIService struct {
|
||||||
ctx store.EcsContext
|
ctx store.EcsContext
|
||||||
composeBackend *ecs.Backend
|
composeBackend *ecsplugin.Backend
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *ecsAPIService) ContainerService() containers.Service {
|
func (a *ecsAPIService) ContainerService() containers.Service {
|
@ -13,7 +13,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package amazon
|
package ecs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -26,9 +26,10 @@ import (
|
|||||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||||
"github.com/aws/aws-sdk-go/aws/defaults"
|
"github.com/aws/aws-sdk-go/aws/defaults"
|
||||||
|
"gopkg.in/ini.v1"
|
||||||
|
|
||||||
"github.com/docker/api/context/store"
|
"github.com/docker/api/context/store"
|
||||||
"github.com/docker/api/prompt"
|
"github.com/docker/api/prompt"
|
||||||
"gopkg.in/ini.v1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type contextCreateAWSHelper struct {
|
type contextCreateAWSHelper struct {
|
14
ecs/doc.go
Normal file
14
ecs/doc.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 Docker, Inc.
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package ecs
|
@ -1,3 +1,16 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 Docker, Inc.
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
package prompt
|
package prompt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -37,8 +37,8 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/docker/api/azure"
|
azure "github.com/docker/api/aci"
|
||||||
"github.com/docker/api/azure/login"
|
"github.com/docker/api/aci/login"
|
||||||
"github.com/docker/api/context/store"
|
"github.com/docker/api/context/store"
|
||||||
"github.com/docker/api/tests/aci-e2e/storage"
|
"github.com/docker/api/tests/aci-e2e/storage"
|
||||||
. "github.com/docker/api/tests/framework"
|
. "github.com/docker/api/tests/framework"
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
"github.com/Azure/go-autorest/autorest"
|
"github.com/Azure/go-autorest/autorest"
|
||||||
"github.com/Azure/go-autorest/autorest/to"
|
"github.com/Azure/go-autorest/autorest/to"
|
||||||
|
|
||||||
"github.com/docker/api/azure/login"
|
"github.com/docker/api/aci/login"
|
||||||
"github.com/docker/api/context/store"
|
"github.com/docker/api/context/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user