mirror of https://github.com/docker/compose.git
Add ResourceService definition and ACI NOOP implementation
Signed-off-by: Guillaume Tardif <guillaume.tardif@docker.com>
This commit is contained in:
parent
660c7bbdcf
commit
7cf7b00584
|
@ -28,6 +28,7 @@ import (
|
|||
"github.com/docker/compose-cli/aci/login"
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/containers"
|
||||
"github.com/docker/compose-cli/api/resources"
|
||||
"github.com/docker/compose-cli/api/secrets"
|
||||
"github.com/docker/compose-cli/api/volumes"
|
||||
"github.com/docker/compose-cli/backend"
|
||||
|
@ -103,6 +104,7 @@ type aciAPIService struct {
|
|||
*aciContainerService
|
||||
*aciComposeService
|
||||
*aciVolumeService
|
||||
*aciResourceService
|
||||
}
|
||||
|
||||
func (a *aciAPIService) ContainerService() containers.Service {
|
||||
|
@ -123,6 +125,10 @@ func (a *aciAPIService) VolumeService() volumes.Service {
|
|||
return a.aciVolumeService
|
||||
}
|
||||
|
||||
func (a *aciAPIService) ResourceService() resources.Service {
|
||||
return a.aciResourceService
|
||||
}
|
||||
|
||||
func getContainerID(group containerinstance.ContainerGroup, container containerinstance.Container) string {
|
||||
containerID := *group.Name + composeContainerSeparator + *container.Name
|
||||
if _, ok := group.Tags[singleContainerTag]; ok {
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
Copyright 2020 Docker Compose CLI authors
|
||||
|
||||
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 aci
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/compose-cli/api/resources"
|
||||
"github.com/docker/compose-cli/context/store"
|
||||
)
|
||||
|
||||
type aciResourceService struct {
|
||||
aciContext store.AciContext
|
||||
}
|
||||
|
||||
func (cs *aciResourceService) Prune(ctx context.Context, request resources.PruneRequest) ([]string, error) {
|
||||
fmt.Println("PRUNE " + cs.aciContext.ResourceGroup)
|
||||
return nil, nil
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
Copyright 2020 Docker Compose CLI authors
|
||||
|
||||
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 resources
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// PruneRequest options on what to prune
|
||||
type PruneRequest struct {
|
||||
Force bool
|
||||
}
|
||||
|
||||
// Service interacts with the underlying container backend
|
||||
type Service interface {
|
||||
// Prune prune resources
|
||||
Prune(ctx context.Context, request PruneRequest) ([]string, error)
|
||||
}
|
|
@ -25,6 +25,7 @@ import (
|
|||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/containers"
|
||||
"github.com/docker/compose-cli/api/resources"
|
||||
"github.com/docker/compose-cli/api/secrets"
|
||||
"github.com/docker/compose-cli/api/volumes"
|
||||
"github.com/docker/compose-cli/context/cloud"
|
||||
|
@ -55,6 +56,7 @@ var backends = struct {
|
|||
type Service interface {
|
||||
ContainerService() containers.Service
|
||||
ComposeService() compose.Service
|
||||
ResourceService() resources.Service
|
||||
SecretsService() secrets.Service
|
||||
VolumeService() volumes.Service
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import (
|
|||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/containers"
|
||||
"github.com/docker/compose-cli/api/resources"
|
||||
"github.com/docker/compose-cli/api/secrets"
|
||||
"github.com/docker/compose-cli/api/volumes"
|
||||
"github.com/docker/compose-cli/backend"
|
||||
|
@ -103,6 +104,10 @@ func (a *ecsAPIService) VolumeService() volumes.Service {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (a *ecsAPIService) ResourceService() resources.Service {
|
||||
return nil
|
||||
}
|
||||
|
||||
func getCloudService() (cloud.Service, error) {
|
||||
return ecsCloudService{}, nil
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/containers"
|
||||
"github.com/docker/compose-cli/api/resources"
|
||||
"github.com/docker/compose-cli/api/secrets"
|
||||
"github.com/docker/compose-cli/api/volumes"
|
||||
"github.com/docker/compose-cli/backend"
|
||||
|
@ -70,3 +71,7 @@ func (e ecsLocalSimulation) SecretsService() secrets.Service {
|
|||
func (e ecsLocalSimulation) ComposeService() compose.Service {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) ResourceService() resources.Service {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/containers"
|
||||
"github.com/docker/compose-cli/api/resources"
|
||||
"github.com/docker/compose-cli/api/secrets"
|
||||
"github.com/docker/compose-cli/api/volumes"
|
||||
"github.com/docker/compose-cli/backend"
|
||||
|
@ -56,6 +57,10 @@ func (a *apiService) VolumeService() volumes.Service {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (a *apiService) ResourceService() resources.Service {
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
backend.Register("example", "example", service, cloud.NotImplementedCloudService)
|
||||
}
|
||||
|
@ -68,9 +73,9 @@ type containerService struct{}
|
|||
|
||||
func (cs *containerService) Inspect(ctx context.Context, id string) (containers.Container, error) {
|
||||
return containers.Container{
|
||||
ID: "id",
|
||||
Image: "nginx",
|
||||
Platform: "Linux",
|
||||
ID: "id",
|
||||
Image: "nginx",
|
||||
Platform: "Linux",
|
||||
HostConfig: &containers.HostConfig{
|
||||
RestartPolicy: "none",
|
||||
},
|
||||
|
|
|
@ -38,6 +38,7 @@ import (
|
|||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/containers"
|
||||
"github.com/docker/compose-cli/api/resources"
|
||||
"github.com/docker/compose-cli/api/secrets"
|
||||
"github.com/docker/compose-cli/api/volumes"
|
||||
"github.com/docker/compose-cli/backend"
|
||||
|
@ -80,6 +81,10 @@ func (ms *local) VolumeService() volumes.Service {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (ms *local) ResourceService() resources.Service {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ms *local) Inspect(ctx context.Context, id string) (containers.Container, error) {
|
||||
c, err := ms.apiClient.ContainerInspect(ctx, id)
|
||||
if err != nil {
|
||||
|
|
|
@ -21,6 +21,8 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/compose-cli/api/resources"
|
||||
|
||||
"github.com/stretchr/testify/mock"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
@ -116,6 +118,7 @@ func (noopService) ContainerService() containers.Service { return nil }
|
|||
func (noopService) ComposeService() compose.Service { return nil }
|
||||
func (noopService) SecretsService() secrets.Service { return nil }
|
||||
func (noopService) VolumeService() volumes.Service { return nil }
|
||||
func (noopService) ResourceService() resources.Service { return nil }
|
||||
|
||||
type mockMetricsClient struct {
|
||||
mock.Mock
|
||||
|
|
Loading…
Reference in New Issue