|
|
@@ -1,3 +1,18 @@
|
|
|
+// +build ecs
|
|
|
+
|
|
|
+/*
|
|
|
+ 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 amazon
|
|
|
|
|
|
import (
|
|
|
@@ -9,9 +24,12 @@ import (
|
|
|
apicontext "github.com/docker/api/context"
|
|
|
"github.com/docker/api/context/cloud"
|
|
|
"github.com/docker/api/context/store"
|
|
|
- aws "github.com/docker/ecs-plugin/pkg/amazon/backend"
|
|
|
+ "github.com/docker/api/errdefs"
|
|
|
+ ecs "github.com/docker/ecs-plugin/pkg/amazon/backend"
|
|
|
)
|
|
|
|
|
|
+const backendType = store.EcsContextType
|
|
|
+
|
|
|
// ContextParams options for creating AWS context
|
|
|
type ContextParams struct {
|
|
|
Description string
|
|
|
@@ -23,61 +41,61 @@ type ContextParams struct {
|
|
|
}
|
|
|
|
|
|
func init() {
|
|
|
- backend.Register("aws", "aws", service, getCloudService)
|
|
|
+ backend.Register(backendType, backendType, service, getCloudService)
|
|
|
}
|
|
|
|
|
|
func service(ctx context.Context) (backend.Service, error) {
|
|
|
contextStore := store.ContextStore(ctx)
|
|
|
currentContext := apicontext.CurrentContext(ctx)
|
|
|
- var awsContext store.AwsContext
|
|
|
+ var ecsContext store.EcsContext
|
|
|
|
|
|
- if err := contextStore.GetEndpoint(currentContext, &awsContext); err != nil {
|
|
|
+ if err := contextStore.GetEndpoint(currentContext, &ecsContext); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
- return getAwsAPIService(awsContext)
|
|
|
+ return getEcsAPIService(ecsContext)
|
|
|
}
|
|
|
|
|
|
-func getAwsAPIService(awsCtx store.AwsContext) (*awsAPIService, error) {
|
|
|
- backend, err := aws.NewBackend(awsCtx.Profile, awsCtx.Region)
|
|
|
+func getEcsAPIService(ecsCtx store.EcsContext) (*ecsAPIService, error) {
|
|
|
+ backend, err := ecs.NewBackend(ecsCtx.Profile, ecsCtx.Region)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- return &awsAPIService{
|
|
|
- ctx: awsCtx,
|
|
|
+ return &ecsAPIService{
|
|
|
+ ctx: ecsCtx,
|
|
|
composeBackend: backend,
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
-type awsAPIService struct {
|
|
|
- ctx store.AwsContext
|
|
|
- composeBackend *aws.Backend
|
|
|
+type ecsAPIService struct {
|
|
|
+ ctx store.EcsContext
|
|
|
+ composeBackend *ecs.Backend
|
|
|
}
|
|
|
|
|
|
-func (a *awsAPIService) ContainerService() containers.Service {
|
|
|
+func (a *ecsAPIService) ContainerService() containers.Service {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func (a *awsAPIService) ComposeService() compose.Service {
|
|
|
+func (a *ecsAPIService) ComposeService() compose.Service {
|
|
|
return a.composeBackend
|
|
|
}
|
|
|
|
|
|
func getCloudService() (cloud.Service, error) {
|
|
|
- return awsCloudService{}, nil
|
|
|
+ return ecsCloudService{}, nil
|
|
|
}
|
|
|
|
|
|
-type awsCloudService struct {
|
|
|
+type ecsCloudService struct {
|
|
|
}
|
|
|
|
|
|
-func (a awsCloudService) Login(ctx context.Context, params interface{}) error {
|
|
|
- return nil
|
|
|
+func (a ecsCloudService) Login(ctx context.Context, params interface{}) error {
|
|
|
+ return errdefs.ErrNotImplemented
|
|
|
}
|
|
|
|
|
|
-func (a awsCloudService) Logout(ctx context.Context) error {
|
|
|
- return nil
|
|
|
+func (a ecsCloudService) Logout(ctx context.Context) error {
|
|
|
+ return errdefs.ErrNotImplemented
|
|
|
}
|
|
|
|
|
|
-func (a awsCloudService) CreateContextData(ctx context.Context, params interface{}) (interface{}, string, error) {
|
|
|
+func (a ecsCloudService) CreateContextData(ctx context.Context, params interface{}) (interface{}, string, error) {
|
|
|
contextHelper := newContextCreateHelper()
|
|
|
createOpts := params.(ContextParams)
|
|
|
return contextHelper.createContextData(ctx, createOpts)
|