mirror of https://github.com/docker/compose.git
Merge branch 'main' of github.com:docker/compose-cli into docker_compose_logs_since_option
This commit is contained in:
commit
df6d709aa5
|
@ -39,8 +39,8 @@ import (
|
|||
"github.com/docker/compose-cli/api/client"
|
||||
"github.com/docker/compose-cli/api/containers"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/api/progress"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/docker/compose-cli/pkg/progress"
|
||||
)
|
||||
|
||||
func createACIContainers(ctx context.Context, aciContext store.AciContext, groupDefinition containerinstance.ContainerGroup) error {
|
||||
|
@ -85,7 +85,7 @@ func autocreateFileshares(ctx context.Context, project *types.Project) error {
|
|||
}
|
||||
_, err = clt.VolumeService().Inspect(ctx, fmt.Sprintf("%s/%s", accountName, shareName))
|
||||
if err != nil { // Not found, autocreate fileshare
|
||||
if !errdefs.IsNotFoundError(err) {
|
||||
if !api.IsNotFoundError(err) {
|
||||
return err
|
||||
}
|
||||
aciVolumeOpts := &VolumeCreateOptions{
|
||||
|
@ -198,7 +198,7 @@ func stopACIContainerGroup(ctx context.Context, aciContext store.AciContext, con
|
|||
|
||||
result, err := containerGroupsClient.Stop(ctx, aciContext.ResourceGroup, containerGroupName)
|
||||
if result.IsHTTPStatus(http.StatusNotFound) {
|
||||
return errdefs.ErrNotFound
|
||||
return api.ErrNotFound
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -26,11 +26,11 @@ import (
|
|||
"github.com/docker/compose-cli/aci/convert"
|
||||
"github.com/docker/compose-cli/aci/login"
|
||||
"github.com/docker/compose-cli/api/backend"
|
||||
"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/pkg/api"
|
||||
|
||||
"github.com/docker/compose-cli/api/cloud"
|
||||
apicontext "github.com/docker/compose-cli/api/context"
|
||||
|
@ -115,7 +115,7 @@ func (a *aciAPIService) ContainerService() containers.Service {
|
|||
return a.aciContainerService
|
||||
}
|
||||
|
||||
func (a *aciAPIService) ComposeService() compose.Service {
|
||||
func (a *aciAPIService) ComposeService() api.Service {
|
||||
return a.aciComposeService
|
||||
}
|
||||
|
||||
|
|
115
aci/compose.go
115
aci/compose.go
|
@ -27,10 +27,9 @@ import (
|
|||
|
||||
"github.com/docker/compose-cli/aci/convert"
|
||||
"github.com/docker/compose-cli/aci/login"
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/api/progress"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/docker/compose-cli/pkg/progress"
|
||||
"github.com/docker/compose-cli/utils/formatter"
|
||||
)
|
||||
|
||||
|
@ -46,47 +45,47 @@ func newComposeService(ctx store.AciContext) aciComposeService {
|
|||
}
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Build(ctx context.Context, project *types.Project, options compose.BuildOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) Build(ctx context.Context, project *types.Project, options api.BuildOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Push(ctx context.Context, project *types.Project, options compose.PushOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) Push(ctx context.Context, project *types.Project, options api.PushOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Pull(ctx context.Context, project *types.Project, options compose.PullOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) Pull(ctx context.Context, project *types.Project, options api.PullOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Create(ctx context.Context, project *types.Project, opts compose.CreateOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) Create(ctx context.Context, project *types.Project, opts api.CreateOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Start(ctx context.Context, project *types.Project, options compose.StartOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) Start(ctx context.Context, project *types.Project, options api.StartOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Restart(ctx context.Context, project *types.Project, options compose.RestartOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) Restart(ctx context.Context, project *types.Project, options api.RestartOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Stop(ctx context.Context, project *types.Project, options compose.StopOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) Stop(ctx context.Context, project *types.Project, options api.StopOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Pause(ctx context.Context, project string, options compose.PauseOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) Pause(ctx context.Context, project string, options api.PauseOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) UnPause(ctx context.Context, project string, options compose.PauseOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) UnPause(ctx context.Context, project string, options api.PauseOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Copy(ctx context.Context, project *types.Project, options compose.CopyOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) Copy(ctx context.Context, project *types.Project, options api.CopyOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Up(ctx context.Context, project *types.Project, options compose.UpOptions) error {
|
||||
func (cs *aciComposeService) Up(ctx context.Context, project *types.Project, options api.UpOptions) error {
|
||||
return progress.Run(ctx, func(ctx context.Context) error {
|
||||
return cs.up(ctx, project)
|
||||
})
|
||||
|
@ -130,12 +129,12 @@ func (cs aciComposeService) warnKeepVolumeOnDown(ctx context.Context, projectNam
|
|||
return nil
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Down(ctx context.Context, projectName string, options compose.DownOptions) error {
|
||||
func (cs *aciComposeService) Down(ctx context.Context, projectName string, options api.DownOptions) error {
|
||||
if options.Volumes {
|
||||
return errors.Wrap(errdefs.ErrNotImplemented, "--volumes option is not supported on ACI")
|
||||
return errors.Wrap(api.ErrNotImplemented, "--volumes option is not supported on ACI")
|
||||
}
|
||||
if options.Images != "" {
|
||||
return errors.Wrap(errdefs.ErrNotImplemented, "--rmi option is not supported on ACI")
|
||||
return errors.Wrap(api.ErrNotImplemented, "--rmi option is not supported on ACI")
|
||||
}
|
||||
return progress.Run(ctx, func(ctx context.Context) error {
|
||||
logrus.Debugf("Down on project with name %q", projectName)
|
||||
|
@ -149,14 +148,14 @@ func (cs *aciComposeService) Down(ctx context.Context, projectName string, optio
|
|||
return err
|
||||
}
|
||||
if cg.IsHTTPStatus(http.StatusNoContent) {
|
||||
return errdefs.ErrNotFound
|
||||
return api.ErrNotFound
|
||||
}
|
||||
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Ps(ctx context.Context, projectName string, options compose.PsOptions) ([]compose.ContainerSummary, error) {
|
||||
func (cs *aciComposeService) Ps(ctx context.Context, projectName string, options api.PsOptions) ([]api.ContainerSummary, error) {
|
||||
groupsClient, err := login.NewContainerGroupsClient(cs.ctx.SubscriptionID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -171,15 +170,15 @@ func (cs *aciComposeService) Ps(ctx context.Context, projectName string, options
|
|||
return nil, fmt.Errorf("no containers found in ACI container group %s", projectName)
|
||||
}
|
||||
|
||||
res := []compose.ContainerSummary{}
|
||||
res := []api.ContainerSummary{}
|
||||
for _, container := range *group.Containers {
|
||||
if isContainerVisible(container, group, false) {
|
||||
continue
|
||||
}
|
||||
var publishers []compose.PortPublisher
|
||||
var publishers []api.PortPublisher
|
||||
urls := formatter.PortsToStrings(convert.ToPorts(group.IPAddress, *container.Ports), convert.FQDN(group, cs.ctx.Location))
|
||||
for i, p := range *container.Ports {
|
||||
publishers = append(publishers, compose.PortPublisher{
|
||||
publishers = append(publishers, api.PortPublisher{
|
||||
URL: urls[i],
|
||||
TargetPort: int(*p.Port),
|
||||
PublishedPort: int(*p.Port),
|
||||
|
@ -187,7 +186,7 @@ func (cs *aciComposeService) Ps(ctx context.Context, projectName string, options
|
|||
})
|
||||
}
|
||||
id := getContainerID(group, container)
|
||||
res = append(res, compose.ContainerSummary{
|
||||
res = append(res, api.ContainerSummary{
|
||||
ID: id,
|
||||
Name: id,
|
||||
Project: projectName,
|
||||
|
@ -199,26 +198,26 @@ func (cs *aciComposeService) Ps(ctx context.Context, projectName string, options
|
|||
return res, nil
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) List(ctx context.Context, opts compose.ListOptions) ([]compose.Stack, error) {
|
||||
func (cs *aciComposeService) List(ctx context.Context, opts api.ListOptions) ([]api.Stack, error) {
|
||||
containerGroups, err := getACIContainerGroups(ctx, cs.ctx.SubscriptionID, cs.ctx.ResourceGroup)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var stacks []compose.Stack
|
||||
var stacks []api.Stack
|
||||
for _, group := range containerGroups {
|
||||
if _, found := group.Tags[composeContainerTag]; !found {
|
||||
continue
|
||||
}
|
||||
state := compose.RUNNING
|
||||
state := api.RUNNING
|
||||
for _, container := range *group.ContainerGroupProperties.Containers {
|
||||
containerState := convert.GetStatus(container, group)
|
||||
if containerState != compose.RUNNING {
|
||||
if containerState != api.RUNNING {
|
||||
state = containerState
|
||||
break
|
||||
}
|
||||
}
|
||||
stacks = append(stacks, compose.Stack{
|
||||
stacks = append(stacks, api.Stack{
|
||||
ID: *group.ID,
|
||||
Name: *group.Name,
|
||||
Status: state,
|
||||
|
@ -227,41 +226,41 @@ func (cs *aciComposeService) List(ctx context.Context, opts compose.ListOptions)
|
|||
return stacks, nil
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Logs(ctx context.Context, projectName string, consumer compose.LogConsumer, options compose.LogOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) Logs(ctx context.Context, projectName string, consumer api.LogConsumer, options api.LogOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Convert(ctx context.Context, project *types.Project, options compose.ConvertOptions) ([]byte, error) {
|
||||
return nil, errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) Convert(ctx context.Context, project *types.Project, options api.ConvertOptions) ([]byte, error) {
|
||||
return nil, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Kill(ctx context.Context, project *types.Project, options compose.KillOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) Kill(ctx context.Context, project *types.Project, options api.KillOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) RunOneOffContainer(ctx context.Context, project *types.Project, opts compose.RunOptions) (int, error) {
|
||||
return 0, errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) RunOneOffContainer(ctx context.Context, project *types.Project, opts api.RunOptions) (int, error) {
|
||||
return 0, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Remove(ctx context.Context, project *types.Project, options compose.RemoveOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) Remove(ctx context.Context, project *types.Project, options api.RemoveOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Exec(ctx context.Context, project *types.Project, opts compose.RunOptions) (int, error) {
|
||||
return 0, errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) Exec(ctx context.Context, project *types.Project, opts api.RunOptions) (int, error) {
|
||||
return 0, api.ErrNotImplemented
|
||||
}
|
||||
func (cs *aciComposeService) Top(ctx context.Context, projectName string, services []string) ([]compose.ContainerProcSummary, error) {
|
||||
return nil, errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) Top(ctx context.Context, projectName string, services []string) ([]api.ContainerProcSummary, error) {
|
||||
return nil, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Events(ctx context.Context, project string, options compose.EventsOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) Events(ctx context.Context, project string, options api.EventsOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Port(ctx context.Context, project string, service string, port int, options compose.PortOptions) (string, int, error) {
|
||||
return "", 0, errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) Port(ctx context.Context, project string, service string, port int, options api.PortOptions) (string, int, error) {
|
||||
return "", 0, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs *aciComposeService) Images(ctx context.Context, projectName string, options compose.ImagesOptions) ([]compose.ImageSummary, error) {
|
||||
return nil, errdefs.ErrNotImplemented
|
||||
func (cs *aciComposeService) Images(ctx context.Context, projectName string, options api.ImagesOptions) ([]api.ImageSummary, error) {
|
||||
return nil, api.ErrNotImplemented
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import (
|
|||
"github.com/docker/compose-cli/aci/login"
|
||||
"github.com/docker/compose-cli/api/containers"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type aciContainerService struct {
|
||||
|
@ -107,7 +107,7 @@ func (cs *aciContainerService) Start(ctx context.Context, containerID string) er
|
|||
var aerr autorest.DetailedError
|
||||
if ok := errors.As(err, &aerr); ok {
|
||||
if aerr.StatusCode == http.StatusNotFound {
|
||||
return errdefs.ErrNotFound
|
||||
return api.ErrNotFound
|
||||
}
|
||||
}
|
||||
return err
|
||||
|
@ -207,7 +207,7 @@ func (cs *aciContainerService) Delete(ctx context.Context, containerID string, r
|
|||
cg, err := containerGroupsClient.Get(ctx, cs.ctx.ResourceGroup, groupName)
|
||||
if err != nil {
|
||||
if cg.StatusCode == http.StatusNotFound {
|
||||
return errdefs.ErrNotFound
|
||||
return api.ErrNotFound
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ func (cs *aciContainerService) Delete(ctx context.Context, containerID string, r
|
|||
status := convert.GetStatus(container, cg)
|
||||
|
||||
if status == convert.StatusRunning {
|
||||
return errdefs.ErrForbidden
|
||||
return api.ErrForbidden
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ func (cs *aciContainerService) Delete(ctx context.Context, containerID string, r
|
|||
cg, err := deleteACIContainerGroup(ctx, cs.ctx, groupName)
|
||||
// Delete returns `StatusNoContent` if the group is not found
|
||||
if cg.IsHTTPStatus(http.StatusNoContent) {
|
||||
return errdefs.ErrNotFound
|
||||
return api.ErrNotFound
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -244,7 +244,7 @@ func (cs *aciContainerService) Inspect(ctx context.Context, containerID string)
|
|||
return containers.Container{}, err
|
||||
}
|
||||
if cg.IsHTTPStatus(http.StatusNoContent) || cg.ContainerGroupProperties == nil || cg.ContainerGroupProperties.Containers == nil {
|
||||
return containers.Container{}, errdefs.ErrNotFound
|
||||
return containers.Container{}, api.ErrNotFound
|
||||
}
|
||||
|
||||
var cc containerinstance.Container
|
||||
|
@ -257,7 +257,7 @@ func (cs *aciContainerService) Inspect(ctx context.Context, containerID string)
|
|||
}
|
||||
}
|
||||
if !found {
|
||||
return containers.Container{}, errdefs.ErrNotFound
|
||||
return containers.Container{}, api.ErrNotFound
|
||||
}
|
||||
|
||||
return convert.ContainerGroupToContainer(containerID, cg, cc, cs.ctx.Location), nil
|
||||
|
|
|
@ -28,8 +28,8 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/utils/prompt"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/docker/compose-cli/pkg/prompt"
|
||||
)
|
||||
|
||||
// ContextParams options for creating ACI context
|
||||
|
@ -41,7 +41,7 @@ type ContextParams struct {
|
|||
}
|
||||
|
||||
// ErrSubscriptionNotFound is returned when a required subscription is not found
|
||||
var ErrSubscriptionNotFound = errors.Wrapf(errdefs.ErrNotFound, "subscription")
|
||||
var ErrSubscriptionNotFound = errors.Wrapf(api.ErrNotFound, "subscription")
|
||||
|
||||
// IsSubscriptionNotFoundError returns true if the unwrapped error is IsSubscriptionNotFoundError
|
||||
func IsSubscriptionNotFoundError(err error) bool {
|
||||
|
@ -145,7 +145,7 @@ func (helper contextCreateACIHelper) chooseGroup(ctx context.Context, subscripti
|
|||
group, err := helper.selector.Select("Select a resource group", groupNames)
|
||||
if err != nil {
|
||||
if err == terminal.InterruptErr {
|
||||
return resources.Group{}, errdefs.ErrCanceled
|
||||
return resources.Group{}, api.ErrCanceled
|
||||
}
|
||||
|
||||
return resources.Group{}, err
|
||||
|
|
|
@ -31,9 +31,9 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
|
||||
"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/context/store"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/docker/compose-cli/utils/formatter"
|
||||
)
|
||||
|
||||
|
@ -314,12 +314,12 @@ func gbToBytes(memInBytes float64) uint64 {
|
|||
}
|
||||
|
||||
// ContainerGroupToServiceStatus convert from an ACI container definition to service status
|
||||
func ContainerGroupToServiceStatus(containerID string, group containerinstance.ContainerGroup, container containerinstance.Container, region string) compose.ServiceStatus {
|
||||
func ContainerGroupToServiceStatus(containerID string, group containerinstance.ContainerGroup, container containerinstance.Container, region string) api.ServiceStatus {
|
||||
var replicas = 1
|
||||
if GetStatus(container, group) != StatusRunning {
|
||||
replicas = 0
|
||||
}
|
||||
return compose.ServiceStatus{
|
||||
return api.ServiceStatus{
|
||||
ID: containerID,
|
||||
Name: *container.Name,
|
||||
Ports: formatter.PortsToStrings(ToPorts(group.IPAddress, *container.Ports), FQDN(group, region)),
|
||||
|
@ -452,5 +452,5 @@ func GetGroupStatus(group containerinstance.ContainerGroup) string {
|
|||
if group.InstanceView != nil && group.InstanceView.State != nil {
|
||||
return "Node " + *group.InstanceView.State
|
||||
}
|
||||
return compose.UNKNOWN
|
||||
return api.UNKNOWN
|
||||
}
|
||||
|
|
|
@ -28,9 +28,9 @@ import (
|
|||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/containers"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -258,7 +258,7 @@ func TestContainerGroupToServiceStatus(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
var expectedService = compose.ServiceStatus{
|
||||
var expectedService = api.ServiceStatus{
|
||||
ID: "myContainerID",
|
||||
Name: "myContainerID",
|
||||
Ports: []string{"42.42.42.42:80->80/tcp"},
|
||||
|
|
|
@ -22,15 +22,13 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/docker/compose-cli/aci/login"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2019-12-01/containerinstance"
|
||||
"github.com/Azure/go-autorest/autorest/to"
|
||||
|
||||
"github.com/compose-spec/compose-go/types"
|
||||
|
||||
"github.com/docker/compose-cli/aci/login"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -151,10 +149,10 @@ func (v *volumeInput) parse(name string, candidate string) error {
|
|||
|
||||
sourceTokens := strings.Split(tokens[0], "/")
|
||||
if len(sourceTokens) != 2 || sourceTokens[0] == "" {
|
||||
return errors.Wrapf(errdefs.ErrParsingFailed, "volume specification %q does not include a storage account before '/'", candidate)
|
||||
return errors.Wrapf(api.ErrParsingFailed, "volume specification %q does not include a storage account before '/'", candidate)
|
||||
}
|
||||
if sourceTokens[1] == "" {
|
||||
return errors.Wrapf(errdefs.ErrParsingFailed, "volume specification %q does not include a storage file fileshare after '/'", candidate)
|
||||
return errors.Wrapf(api.ErrParsingFailed, "volume specification %q does not include a storage file fileshare after '/'", candidate)
|
||||
}
|
||||
v.storageAccount = sourceTokens[0]
|
||||
v.fileshare = sourceTokens[1]
|
||||
|
@ -168,11 +166,11 @@ func (v *volumeInput) parse(name string, candidate string) error {
|
|||
v.target = tokens[1]
|
||||
permissions := strings.ToLower(tokens[2])
|
||||
if permissions != "ro" && permissions != "rw" {
|
||||
return errors.Wrapf(errdefs.ErrParsingFailed, "volume specification %q has an invalid mode %q", candidate, permissions)
|
||||
return errors.Wrapf(api.ErrParsingFailed, "volume specification %q has an invalid mode %q", candidate, permissions)
|
||||
}
|
||||
v.readonly = permissions == "ro"
|
||||
default:
|
||||
return errors.Wrapf(errdefs.ErrParsingFailed, "volume specification %q has invalid format", candidate)
|
||||
return errors.Wrapf(api.ErrParsingFailed, "volume specification %q has invalid format", candidate)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -35,25 +35,23 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/profiles/2019-03-01/resources/mgmt/resources"
|
||||
"github.com/Azure/azure-storage-file-go/azfile"
|
||||
"github.com/Azure/go-autorest/autorest/to"
|
||||
"github.com/docker/docker/pkg/fileutils"
|
||||
|
||||
"github.com/prometheus/tsdb/fileutil"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/icmd"
|
||||
"gotest.tools/v3/poll"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/profiles/2019-03-01/resources/mgmt/resources"
|
||||
"github.com/Azure/azure-storage-file-go/azfile"
|
||||
"github.com/Azure/go-autorest/autorest/to"
|
||||
"github.com/prometheus/tsdb/fileutil"
|
||||
|
||||
"github.com/docker/compose-cli/aci"
|
||||
"github.com/docker/compose-cli/aci/convert"
|
||||
"github.com/docker/compose-cli/aci/login"
|
||||
"github.com/docker/compose-cli/api/containers"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/cli/cmd"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
. "github.com/docker/compose-cli/utils/e2e"
|
||||
)
|
||||
|
||||
|
@ -128,7 +126,7 @@ func TestLoginLogout(t *testing.T) {
|
|||
t.Run("create context fail", func(t *testing.T) {
|
||||
res := c.RunDockerOrExitError("context", "create", "aci", "fail-context")
|
||||
res.Assert(t, icmd.Expected{
|
||||
ExitCode: errdefs.ExitCodeLoginRequired,
|
||||
ExitCode: api.ExitCodeLoginRequired,
|
||||
Err: `not logged in to azure, you need to run "docker login azure" first`,
|
||||
})
|
||||
})
|
||||
|
|
|
@ -30,8 +30,8 @@ import (
|
|||
"github.com/Azure/go-autorest/autorest/date"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/internal"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
// NewContainerGroupsClient get client toi manipulate containerGrouos
|
||||
|
@ -88,7 +88,7 @@ func NewFileShareClient(subscriptionID string) (storage.FileSharesClient, error)
|
|||
func NewSubscriptionsClient() (subscription.SubscriptionsClient, error) {
|
||||
authorizer, mgmtURL, err := getClientSetupData()
|
||||
if err != nil {
|
||||
return subscription.SubscriptionsClient{}, errors.Wrap(errdefs.ErrLoginRequired, err.Error())
|
||||
return subscription.SubscriptionsClient{}, errors.Wrap(api.ErrLoginRequired, err.Error())
|
||||
}
|
||||
subc := subscription.NewSubscriptionsClientWithBaseURI(mgmtURL)
|
||||
setupClient(&subc.Client, authorizer)
|
||||
|
|
|
@ -25,12 +25,12 @@ import (
|
|||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
|
||||
"github.com/Azure/go-autorest/autorest/adal"
|
||||
"github.com/Azure/go-autorest/autorest/azure/auth"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/oauth2"
|
||||
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
)
|
||||
|
||||
//go login process, derived from code sample provided by MS at https://github.com/devigned/go-az-cli-stuff
|
||||
|
@ -98,20 +98,20 @@ func (login *azureLoginService) LoginServicePrincipal(clientID string, clientSec
|
|||
|
||||
spToken, err := creds.ServicePrincipalToken()
|
||||
if err != nil {
|
||||
return errors.Wrapf(errdefs.ErrLoginFailed, "could not login with service principal: %s", err)
|
||||
return errors.Wrapf(api.ErrLoginFailed, "could not login with service principal: %s", err)
|
||||
}
|
||||
err = spToken.Refresh()
|
||||
if err != nil {
|
||||
return errors.Wrapf(errdefs.ErrLoginFailed, "could not login with service principal: %s", err)
|
||||
return errors.Wrapf(api.ErrLoginFailed, "could not login with service principal: %s", err)
|
||||
}
|
||||
token, err := spToOAuthToken(spToken.Token())
|
||||
if err != nil {
|
||||
return errors.Wrapf(errdefs.ErrLoginFailed, "could not read service principal token expiry: %s", err)
|
||||
return errors.Wrapf(api.ErrLoginFailed, "could not read service principal token expiry: %s", err)
|
||||
}
|
||||
loginInfo := TokenInfo{TenantID: tenantID, Token: token, CloudEnvironment: cloudEnvironment}
|
||||
|
||||
if err := login.tokenStore.writeLoginInfo(loginInfo); err != nil {
|
||||
return errors.Wrapf(errdefs.ErrLoginFailed, "could not store login info: %s", err)
|
||||
return errors.Wrapf(api.ErrLoginFailed, "could not store login info: %s", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -134,28 +134,28 @@ func (login *azureLoginService) getTenantAndValidateLogin(
|
|||
) error {
|
||||
bits, statusCode, err := login.apiHelper.queryAPIWithHeader(ctx, ce.GetTenantQueryURL(), fmt.Sprintf("Bearer %s", accessToken))
|
||||
if err != nil {
|
||||
return errors.Wrapf(errdefs.ErrLoginFailed, "check auth failed: %s", err)
|
||||
return errors.Wrapf(api.ErrLoginFailed, "check auth failed: %s", err)
|
||||
}
|
||||
|
||||
if statusCode != http.StatusOK {
|
||||
return errors.Wrapf(errdefs.ErrLoginFailed, "unable to login status code %d: %s", statusCode, bits)
|
||||
return errors.Wrapf(api.ErrLoginFailed, "unable to login status code %d: %s", statusCode, bits)
|
||||
}
|
||||
var t tenantResult
|
||||
if err := json.Unmarshal(bits, &t); err != nil {
|
||||
return errors.Wrapf(errdefs.ErrLoginFailed, "unable to unmarshal tenant: %s", err)
|
||||
return errors.Wrapf(api.ErrLoginFailed, "unable to unmarshal tenant: %s", err)
|
||||
}
|
||||
tenantID, err := getTenantID(t.Value, requestedTenantID)
|
||||
if err != nil {
|
||||
return errors.Wrap(errdefs.ErrLoginFailed, err.Error())
|
||||
return errors.Wrap(api.ErrLoginFailed, err.Error())
|
||||
}
|
||||
tToken, err := login.refreshToken(refreshToken, tenantID, ce)
|
||||
if err != nil {
|
||||
return errors.Wrapf(errdefs.ErrLoginFailed, "unable to refresh token: %s", err)
|
||||
return errors.Wrapf(api.ErrLoginFailed, "unable to refresh token: %s", err)
|
||||
}
|
||||
loginInfo := TokenInfo{TenantID: tenantID, Token: tToken, CloudEnvironment: ce.Name}
|
||||
|
||||
if err := login.tokenStore.writeLoginInfo(loginInfo); err != nil {
|
||||
return errors.Wrapf(errdefs.ErrLoginFailed, "could not store login info: %s", err)
|
||||
return errors.Wrapf(api.ErrLoginFailed, "could not store login info: %s", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ func (login *azureLoginService) Login(ctx context.Context, requestedTenantID str
|
|||
|
||||
redirectURL := s.Addr()
|
||||
if redirectURL == "" {
|
||||
return errors.Wrap(errdefs.ErrLoginFailed, "empty redirect URL")
|
||||
return errors.Wrap(api.ErrLoginFailed, "empty redirect URL")
|
||||
}
|
||||
|
||||
deviceCodeFlowCh := make(chan deviceCodeFlowResponse, 1)
|
||||
|
@ -190,17 +190,17 @@ func (login *azureLoginService) Login(ctx context.Context, requestedTenantID str
|
|||
return ctx.Err()
|
||||
case dcft := <-deviceCodeFlowCh:
|
||||
if dcft.err != nil {
|
||||
return errors.Wrapf(errdefs.ErrLoginFailed, "could not get token using device code flow: %s", err)
|
||||
return errors.Wrapf(api.ErrLoginFailed, "could not get token using device code flow: %s", err)
|
||||
}
|
||||
token := dcft.token
|
||||
return login.getTenantAndValidateLogin(ctx, token.AccessToken, token.RefreshToken, requestedTenantID, ce)
|
||||
case q := <-queryCh:
|
||||
if q.err != nil {
|
||||
return errors.Wrapf(errdefs.ErrLoginFailed, "unhandled local login server error: %s", err)
|
||||
return errors.Wrapf(api.ErrLoginFailed, "unhandled local login server error: %s", err)
|
||||
}
|
||||
code, hasCode := q.values["code"]
|
||||
if !hasCode {
|
||||
return errors.Wrap(errdefs.ErrLoginFailed, "no login code")
|
||||
return errors.Wrap(api.ErrLoginFailed, "no login code")
|
||||
}
|
||||
data := url.Values{
|
||||
"grant_type": []string{"authorization_code"},
|
||||
|
@ -211,7 +211,7 @@ func (login *azureLoginService) Login(ctx context.Context, requestedTenantID str
|
|||
}
|
||||
token, err := login.apiHelper.queryToken(ce, data, "organizations")
|
||||
if err != nil {
|
||||
return errors.Wrapf(errdefs.ErrLoginFailed, "access token request failed: %s", err)
|
||||
return errors.Wrapf(api.ErrLoginFailed, "access token request failed: %s", err)
|
||||
}
|
||||
return login.getTenantAndValidateLogin(ctx, token.AccessToken, token.RefreshToken, requestedTenantID, ce)
|
||||
}
|
||||
|
|
|
@ -30,9 +30,9 @@ import (
|
|||
|
||||
"github.com/docker/compose-cli/aci/login"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/api/progress"
|
||||
"github.com/docker/compose-cli/api/volumes"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/docker/compose-cli/pkg/progress"
|
||||
)
|
||||
|
||||
type aciVolumeService struct {
|
||||
|
@ -138,7 +138,7 @@ func (cs *aciVolumeService) Create(ctx context.Context, name string, options int
|
|||
fileShare, err := fileShareClient.Get(ctx, cs.aciContext.ResourceGroup, *account.Name, name, "")
|
||||
if err == nil {
|
||||
w.Event(progress.ErrorEvent(name))
|
||||
return volumes.Volume{}, errors.Wrapf(errdefs.ErrAlreadyExists, "Azure fileshare %q already exists", name)
|
||||
return volumes.Volume{}, errors.Wrapf(api.ErrAlreadyExists, "Azure fileshare %q already exists", name)
|
||||
}
|
||||
if !fileShare.HasHTTPStatus(http.StatusNotFound) {
|
||||
w.Event(progress.ErrorEvent(name))
|
||||
|
@ -212,7 +212,7 @@ func (cs *aciVolumeService) Delete(ctx context.Context, id string, options inter
|
|||
if _, ok := account.Tags[dockerVolumeTag]; ok {
|
||||
result, err := storageAccountsClient.Delete(ctx, cs.aciContext.ResourceGroup, storageAccount)
|
||||
if result.IsHTTPStatus(http.StatusNoContent) {
|
||||
return errors.Wrapf(errdefs.ErrNotFound, "storage account %s does not exist", storageAccount)
|
||||
return errors.Wrapf(api.ErrNotFound, "storage account %s does not exist", storageAccount)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ func (cs *aciVolumeService) Delete(ctx context.Context, id string, options inter
|
|||
|
||||
result, err := fileShareClient.Delete(ctx, cs.aciContext.ResourceGroup, storageAccount, fileshare)
|
||||
if result.HasHTTPStatus(http.StatusNoContent) {
|
||||
return errors.Wrapf(errdefs.ErrNotFound, "fileshare %q", fileshare)
|
||||
return errors.Wrapf(api.ErrNotFound, "fileshare %q", fileshare)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ func (cs *aciVolumeService) Inspect(ctx context.Context, id string) (volumes.Vol
|
|||
res, err := fileShareClient.Get(ctx, cs.aciContext.ResourceGroup, storageAccount, fileshareName, "")
|
||||
if err != nil { // Just checks if it exists
|
||||
if res.HasHTTPStatus(http.StatusNotFound) {
|
||||
return volumes.Volume{}, errors.Wrapf(errdefs.ErrNotFound, "account %q, file share %q. Original message %s", storageAccount, fileshareName, err.Error())
|
||||
return volumes.Volume{}, errors.Wrapf(api.ErrNotFound, "account %q, file share %q. Original message %s", storageAccount, fileshareName, err.Error())
|
||||
}
|
||||
return volumes.Volume{}, err
|
||||
}
|
||||
|
|
|
@ -23,12 +23,11 @@ import (
|
|||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/docker/compose-cli/api/cloud"
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/containers"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"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/pkg/api"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -66,7 +65,7 @@ func WithBackend(s Service) {
|
|||
// Service aggregates the service interfaces
|
||||
type Service interface {
|
||||
ContainerService() containers.Service
|
||||
ComposeService() compose.Service
|
||||
ComposeService() api.Service
|
||||
ResourceService() resources.Service
|
||||
SecretsService() secrets.Service
|
||||
VolumeService() volumes.Service
|
||||
|
@ -103,7 +102,7 @@ func Get(backendType string) (Service, error) {
|
|||
}
|
||||
}
|
||||
|
||||
return nil, errdefs.ErrNotFound
|
||||
return nil, api.ErrNotFound
|
||||
}
|
||||
|
||||
// GetCloudService returns the backend registered for a particular type, it returns
|
||||
|
|
|
@ -21,14 +21,13 @@ import (
|
|||
|
||||
"github.com/docker/compose-cli/api/backend"
|
||||
"github.com/docker/compose-cli/api/cloud"
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/containers"
|
||||
apicontext "github.com/docker/compose-cli/api/context"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"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/pkg/api"
|
||||
)
|
||||
|
||||
// New returns a backend client associated with current context
|
||||
|
@ -43,7 +42,7 @@ func New(ctx context.Context) (*Client, error) {
|
|||
|
||||
service := backend.Current()
|
||||
if service == nil {
|
||||
return nil, errdefs.ErrNotFound
|
||||
return nil, api.ErrNotFound
|
||||
}
|
||||
|
||||
client := NewClient(cc.Type(), service)
|
||||
|
@ -84,7 +83,7 @@ func (c *Client) ContainerService() containers.Service {
|
|||
}
|
||||
|
||||
// ComposeService returns the backend service for the current context
|
||||
func (c *Client) ComposeService() compose.Service {
|
||||
func (c *Client) ComposeService() api.Service {
|
||||
if cs := c.bs.ComposeService(); cs != nil {
|
||||
return cs
|
||||
}
|
||||
|
|
|
@ -19,107 +19,105 @@ package client
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
|
||||
"github.com/compose-spec/compose-go/types"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type composeService struct {
|
||||
}
|
||||
|
||||
func (c *composeService) Build(ctx context.Context, project *types.Project, options compose.BuildOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (c *composeService) Build(ctx context.Context, project *types.Project, options api.BuildOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Push(ctx context.Context, project *types.Project, options compose.PushOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (c *composeService) Push(ctx context.Context, project *types.Project, options api.PushOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Pull(ctx context.Context, project *types.Project, options compose.PullOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (c *composeService) Pull(ctx context.Context, project *types.Project, options api.PullOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Create(ctx context.Context, project *types.Project, opts compose.CreateOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (c *composeService) Create(ctx context.Context, project *types.Project, opts api.CreateOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Start(ctx context.Context, project *types.Project, options compose.StartOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (c *composeService) Start(ctx context.Context, project *types.Project, options api.StartOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Restart(ctx context.Context, project *types.Project, options compose.RestartOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (c *composeService) Restart(ctx context.Context, project *types.Project, options api.RestartOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Stop(ctx context.Context, project *types.Project, options compose.StopOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (c *composeService) Stop(ctx context.Context, project *types.Project, options api.StopOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Up(context.Context, *types.Project, compose.UpOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (c *composeService) Up(context.Context, *types.Project, api.UpOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Down(context.Context, string, compose.DownOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (c *composeService) Down(context.Context, string, api.DownOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Logs(context.Context, string, compose.LogConsumer, compose.LogOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (c *composeService) Logs(context.Context, string, api.LogConsumer, api.LogOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Ps(context.Context, string, compose.PsOptions) ([]compose.ContainerSummary, error) {
|
||||
return nil, errdefs.ErrNotImplemented
|
||||
func (c *composeService) Ps(context.Context, string, api.PsOptions) ([]api.ContainerSummary, error) {
|
||||
return nil, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) List(context.Context, compose.ListOptions) ([]compose.Stack, error) {
|
||||
return nil, errdefs.ErrNotImplemented
|
||||
func (c *composeService) List(context.Context, api.ListOptions) ([]api.Stack, error) {
|
||||
return nil, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Convert(context.Context, *types.Project, compose.ConvertOptions) ([]byte, error) {
|
||||
return nil, errdefs.ErrNotImplemented
|
||||
func (c *composeService) Convert(context.Context, *types.Project, api.ConvertOptions) ([]byte, error) {
|
||||
return nil, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Kill(ctx context.Context, project *types.Project, options compose.KillOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (c *composeService) Kill(ctx context.Context, project *types.Project, options api.KillOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) RunOneOffContainer(ctx context.Context, project *types.Project, opts compose.RunOptions) (int, error) {
|
||||
return 0, errdefs.ErrNotImplemented
|
||||
func (c *composeService) RunOneOffContainer(ctx context.Context, project *types.Project, opts api.RunOptions) (int, error) {
|
||||
return 0, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Remove(ctx context.Context, project *types.Project, options compose.RemoveOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (c *composeService) Remove(ctx context.Context, project *types.Project, options api.RemoveOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Exec(ctx context.Context, project *types.Project, opts compose.RunOptions) (int, error) {
|
||||
return 0, errdefs.ErrNotImplemented
|
||||
func (c *composeService) Exec(ctx context.Context, project *types.Project, opts api.RunOptions) (int, error) {
|
||||
return 0, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Copy(ctx context.Context, project *types.Project, opts compose.CopyOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (c *composeService) Copy(ctx context.Context, project *types.Project, opts api.CopyOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Pause(ctx context.Context, project string, options compose.PauseOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (c *composeService) Pause(ctx context.Context, project string, options api.PauseOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) UnPause(ctx context.Context, project string, options compose.PauseOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (c *composeService) UnPause(ctx context.Context, project string, options api.PauseOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Top(ctx context.Context, projectName string, services []string) ([]compose.ContainerProcSummary, error) {
|
||||
return nil, errdefs.ErrNotImplemented
|
||||
func (c *composeService) Top(ctx context.Context, projectName string, services []string) ([]api.ContainerProcSummary, error) {
|
||||
return nil, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Events(ctx context.Context, project string, options compose.EventsOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (c *composeService) Events(ctx context.Context, project string, options api.EventsOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Port(ctx context.Context, project string, service string, port int, options compose.PortOptions) (string, int, error) {
|
||||
return "", 0, errdefs.ErrNotImplemented
|
||||
func (c *composeService) Port(ctx context.Context, project string, service string, port int, options api.PortOptions) (string, int, error) {
|
||||
return "", 0, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Images(ctx context.Context, projectName string, options compose.ImagesOptions) ([]compose.ImageSummary, error) {
|
||||
return nil, errdefs.ErrNotImplemented
|
||||
func (c *composeService) Images(ctx context.Context, projectName string, options api.ImagesOptions) ([]api.ImageSummary, error) {
|
||||
return nil, api.ErrNotImplemented
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"context"
|
||||
|
||||
"github.com/docker/compose-cli/api/containers"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type containerService struct {
|
||||
|
@ -28,44 +28,44 @@ type containerService struct {
|
|||
|
||||
// List returns all the containers
|
||||
func (c *containerService) List(context.Context, bool) ([]containers.Container, error) {
|
||||
return nil, errdefs.ErrNotImplemented
|
||||
return nil, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
// Start starts a stopped container
|
||||
func (c *containerService) Start(context.Context, string) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
// Stop stops the running container
|
||||
func (c *containerService) Stop(context.Context, string, *uint32) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *containerService) Kill(ctx context.Context, containerID string, signal string) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
// Run creates and starts a container
|
||||
func (c *containerService) Run(context.Context, containers.ContainerConfig) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
// Exec executes a command inside a running container
|
||||
func (c *containerService) Exec(context.Context, string, containers.ExecRequest) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
// Logs returns all the logs of a container
|
||||
func (c *containerService) Logs(context.Context, string, containers.LogsRequest) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
// Delete removes containers
|
||||
func (c *containerService) Delete(context.Context, string, containers.DeleteRequest) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
// Inspect get a specific container
|
||||
func (c *containerService) Inspect(context.Context, string) (containers.Container, error) {
|
||||
return containers.Container{}, errdefs.ErrNotImplemented
|
||||
return containers.Container{}, api.ErrNotImplemented
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ package client
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/api/resources"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type resourceService struct {
|
||||
|
@ -28,5 +28,5 @@ type resourceService struct {
|
|||
|
||||
// Prune prune resources
|
||||
func (c *resourceService) Prune(ctx context.Context, request resources.PruneRequest) (resources.PruneResult, error) {
|
||||
return resources.PruneResult{}, errdefs.ErrNotImplemented
|
||||
return resources.PruneResult{}, api.ErrNotImplemented
|
||||
}
|
||||
|
|
|
@ -19,25 +19,25 @@ package client
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/api/secrets"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type secretsService struct {
|
||||
}
|
||||
|
||||
func (s *secretsService) CreateSecret(context.Context, secrets.Secret) (string, error) {
|
||||
return "", errdefs.ErrNotImplemented
|
||||
return "", api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *secretsService) InspectSecret(context.Context, string) (secrets.Secret, error) {
|
||||
return secrets.Secret{}, errdefs.ErrNotImplemented
|
||||
return secrets.Secret{}, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *secretsService) ListSecrets(context.Context) ([]secrets.Secret, error) {
|
||||
return nil, errdefs.ErrNotImplemented
|
||||
return nil, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *secretsService) DeleteSecret(context.Context, string, bool) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
|
|
@ -19,25 +19,25 @@ package client
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/api/volumes"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type volumeService struct {
|
||||
}
|
||||
|
||||
func (c *volumeService) List(ctx context.Context) ([]volumes.Volume, error) {
|
||||
return nil, errdefs.ErrNotImplemented
|
||||
return nil, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *volumeService) Create(ctx context.Context, name string, options interface{}) (volumes.Volume, error) {
|
||||
return volumes.Volume{}, errdefs.ErrNotImplemented
|
||||
return volumes.Volume{}, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *volumeService) Delete(ctx context.Context, id string, options interface{}) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *volumeService) Inspect(ctx context.Context, volumeID string) (volumes.Volume, error) {
|
||||
return volumes.Volume{}, errdefs.ErrNotImplemented
|
||||
return volumes.Volume{}, api.ErrNotImplemented
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package cloud
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
// Service cloud specific services
|
||||
|
@ -42,13 +42,13 @@ type notImplementedCloudService struct {
|
|||
|
||||
// Logout login to cloud provider
|
||||
func (cs notImplementedCloudService) Logout(ctx context.Context) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs notImplementedCloudService) Login(ctx context.Context, params interface{}) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (cs notImplementedCloudService) CreateContextData(ctx context.Context, params interface{}) (interface{}, string, error) {
|
||||
return nil, "", errdefs.ErrNotImplemented
|
||||
return nil, "", api.ErrNotImplemented
|
||||
}
|
||||
|
|
|
@ -24,10 +24,10 @@ import (
|
|||
"path/filepath"
|
||||
"reflect"
|
||||
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
|
||||
"github.com/opencontainers/go-digest"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -130,7 +130,7 @@ func (s *store) Get(name string) (*DockerContext, error) {
|
|||
meta := filepath.Join(s.root, contextsDir, metadataDir, contextDirOf(name), metaFile)
|
||||
m, err := read(meta)
|
||||
if os.IsNotExist(err) {
|
||||
return nil, errors.Wrap(errdefs.ErrNotFound, objectName(name))
|
||||
return nil, errors.Wrap(api.ErrNotFound, objectName(name))
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ func (s *store) GetEndpoint(name string, data interface{}) error {
|
|||
}
|
||||
contextType := meta.Type()
|
||||
if _, ok := meta.Endpoints[contextType]; !ok {
|
||||
return errors.Wrapf(errdefs.ErrNotFound, "endpoint of type %q", contextType)
|
||||
return errors.Wrapf(api.ErrNotFound, "endpoint of type %q", contextType)
|
||||
}
|
||||
|
||||
dstPtrValue := reflect.ValueOf(data)
|
||||
|
@ -155,7 +155,7 @@ func (s *store) GetEndpoint(name string, data interface{}) error {
|
|||
valIndirect := reflect.Indirect(val)
|
||||
|
||||
if dstValue.Type() != valIndirect.Type() {
|
||||
return errdefs.ErrWrongContextType
|
||||
return api.ErrWrongContextType
|
||||
}
|
||||
|
||||
dstValue.Set(valIndirect)
|
||||
|
@ -223,7 +223,7 @@ func (s *store) ContextExists(name string) bool {
|
|||
|
||||
func (s *store) Create(name string, contextType string, description string, data interface{}) error {
|
||||
if s.ContextExists(name) {
|
||||
return errors.Wrap(errdefs.ErrAlreadyExists, objectName(name))
|
||||
return errors.Wrap(api.ErrAlreadyExists, objectName(name))
|
||||
}
|
||||
dir := contextDirOf(name)
|
||||
metaDir := filepath.Join(s.root, contextsDir, metadataDir, dir)
|
||||
|
@ -285,15 +285,15 @@ func (s *store) List() ([]*DockerContext, error) {
|
|||
|
||||
func (s *store) Remove(name string) error {
|
||||
if name == DefaultContextName {
|
||||
return errors.Wrap(errdefs.ErrForbidden, objectName(name))
|
||||
return errors.Wrap(api.ErrForbidden, objectName(name))
|
||||
}
|
||||
dir := filepath.Join(s.root, contextsDir, metadataDir, contextDirOf(name))
|
||||
// Check if directory exists because os.RemoveAll returns nil if it doesn't
|
||||
if _, err := os.Stat(dir); os.IsNotExist(err) {
|
||||
return errors.Wrap(errdefs.ErrNotFound, objectName(name))
|
||||
return errors.Wrap(api.ErrNotFound, objectName(name))
|
||||
}
|
||||
if err := os.RemoveAll(dir); err != nil {
|
||||
return errors.Wrapf(errdefs.ErrUnknown, "unable to remove %s: %s", objectName(name), err)
|
||||
return errors.Wrapf(api.ErrUnknown, "unable to remove %s: %s", objectName(name), err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/assert/cmp"
|
||||
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
)
|
||||
|
||||
func testStore(t *testing.T) Store {
|
||||
|
@ -49,7 +49,7 @@ func TestCreate(t *testing.T) {
|
|||
|
||||
err = s.Create("test", "test", "descrsiption", ContextMetadata{})
|
||||
assert.Error(t, err, `context "test": already exists`)
|
||||
assert.Assert(t, errdefs.IsAlreadyExistsError(err))
|
||||
assert.Assert(t, api.IsAlreadyExistsError(err))
|
||||
}
|
||||
|
||||
func TestGetEndpoint(t *testing.T) {
|
||||
|
@ -74,7 +74,7 @@ func TestGetUnknown(t *testing.T) {
|
|||
meta, err := s.Get("unknown")
|
||||
assert.Assert(t, cmp.Nil(meta))
|
||||
assert.Error(t, err, `context "unknown": not found`)
|
||||
assert.Assert(t, errdefs.IsNotFoundError(err))
|
||||
assert.Assert(t, api.IsNotFoundError(err))
|
||||
}
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
|
@ -99,7 +99,7 @@ func TestRemoveNotFound(t *testing.T) {
|
|||
s := testStore(t)
|
||||
err := s.Remove("notfound")
|
||||
assert.Error(t, err, `context "notfound": not found`)
|
||||
assert.Assert(t, errdefs.IsNotFoundError(err))
|
||||
assert.Assert(t, api.IsNotFoundError(err))
|
||||
}
|
||||
|
||||
func TestRemove(t *testing.T) {
|
||||
|
|
|
@ -55,7 +55,7 @@ cli:
|
|||
|
||||
.PHONY: compose-plugin
|
||||
compose-plugin:
|
||||
GOOS=${GOOS} GOARCH=${GOARCH} $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY_WITH_EXTENSION) .
|
||||
GOOS=${GOOS} GOARCH=${GOARCH} $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY_WITH_EXTENSION) ./cmd
|
||||
|
||||
.PHONY: cross
|
||||
cross:
|
||||
|
@ -69,13 +69,13 @@ cross:
|
|||
|
||||
.PHONY: cross-compose-plugin
|
||||
cross-compose-plugin:
|
||||
GOOS=linux GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-amd64 .
|
||||
GOOS=linux GOARCH=arm64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-arm64 .
|
||||
GOOS=linux GOARM=6 GOARCH=arm $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-armv6 .
|
||||
GOOS=linux GOARM=7 GOARCH=arm $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-armv7 .
|
||||
GOOS=darwin GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-darwin-amd64 .
|
||||
GOOS=darwin GOARCH=arm64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-darwin-arm64 .
|
||||
GOOS=windows GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-windows-amd64.exe .
|
||||
GOOS=linux GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-amd64 ./cmd
|
||||
GOOS=linux GOARCH=arm64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-arm64 ./cmd
|
||||
GOOS=linux GOARM=6 GOARCH=arm $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-armv6 ./cmd
|
||||
GOOS=linux GOARM=7 GOARCH=arm $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-armv7 ./cmd
|
||||
GOOS=darwin GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-darwin-amd64 ./cmd
|
||||
GOOS=darwin GOARCH=arm64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-darwin-arm64 ./cmd
|
||||
GOOS=windows GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-windows-amd64.exe ./cmd
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
"github.com/docker/compose-cli/aci"
|
||||
"github.com/docker/compose-cli/api/client"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -58,7 +58,7 @@ func createAciCommand() *cobra.Command {
|
|||
|
||||
func runCreateAci(ctx context.Context, contextName string, opts aci.ContextParams) error {
|
||||
if contextExists(contextName) {
|
||||
return errors.Wrapf(errdefs.ErrAlreadyExists, "context %s", contextName)
|
||||
return errors.Wrapf(api.ErrAlreadyExists, "context %s", contextName)
|
||||
}
|
||||
contextData, description, err := getAciContextData(ctx, opts)
|
||||
if err != nil {
|
||||
|
|
|
@ -28,8 +28,8 @@ import (
|
|||
|
||||
"github.com/docker/compose-cli/api/client"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/ecs"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -110,7 +110,7 @@ func parseAccessKeysFile(file string, opts *ecs.ContextParams) error {
|
|||
|
||||
func runCreateLocalSimulation(ctx context.Context, contextName string, opts ecs.ContextParams) error {
|
||||
if contextExists(contextName) {
|
||||
return errors.Wrapf(errdefs.ErrAlreadyExists, "context %q", contextName)
|
||||
return errors.Wrapf(api.ErrAlreadyExists, "context %q", contextName)
|
||||
}
|
||||
cs, err := client.GetCloudService(ctx, store.EcsLocalSimulationContextType)
|
||||
if err != nil {
|
||||
|
@ -125,7 +125,7 @@ func runCreateLocalSimulation(ctx context.Context, contextName string, opts ecs.
|
|||
|
||||
func runCreateEcs(ctx context.Context, contextName string, opts ecs.ContextParams) error {
|
||||
if contextExists(contextName) {
|
||||
return errors.Wrapf(errdefs.ErrAlreadyExists, "context %q", contextName)
|
||||
return errors.Wrapf(api.ErrAlreadyExists, "context %q", contextName)
|
||||
}
|
||||
contextData, description, err := getEcsContextData(ctx, opts)
|
||||
if err != nil {
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
package context
|
||||
|
||||
import (
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/kube"
|
||||
)
|
||||
|
||||
|
@ -56,7 +56,7 @@ func createKubeCommand() *cobra.Command {
|
|||
|
||||
func runCreateKube(contextName string, opts kube.ContextParams) error {
|
||||
if contextExists(contextName) {
|
||||
return errors.Wrapf(errdefs.ErrAlreadyExists, "context %q", contextName)
|
||||
return errors.Wrapf(api.ErrAlreadyExists, "context %q", contextName)
|
||||
}
|
||||
|
||||
contextData, description, err := opts.CreateContextData()
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
package context
|
||||
|
||||
import (
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/cli/mobycli"
|
||||
)
|
||||
|
||||
|
@ -76,7 +76,7 @@ func runUpdate(cmd *cobra.Command, name string) error {
|
|||
dockerContext, err := s.Get(name)
|
||||
if err == nil && dockerContext != nil {
|
||||
if dockerContext.Type() != store.DefaultContextType {
|
||||
return errors.Wrapf(errdefs.ErrNotImplemented, "context update for context type %q not supported", dockerContext.Type())
|
||||
return errors.Wrapf(api.ErrNotImplemented, "context update for context type %q not supported", dockerContext.Type())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/client"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/cli/formatter"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type killOpts struct {
|
||||
|
@ -60,7 +60,7 @@ func runKill(ctx context.Context, args []string, opts killOpts) error {
|
|||
for _, id := range args {
|
||||
err := c.ContainerService().Kill(ctx, id, opts.signal)
|
||||
if err != nil {
|
||||
if errdefs.IsNotFoundError(err) {
|
||||
if api.IsNotFoundError(err) {
|
||||
errs = multierror.Append(errs, fmt.Errorf("container %s not found", id))
|
||||
} else {
|
||||
errs = multierror.Append(errs, err)
|
||||
|
|
|
@ -24,8 +24,8 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/client"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/cli/mobycli"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
// Command returns the login command
|
||||
|
@ -56,7 +56,7 @@ func cloudLogin(cmd *cobra.Command, backendType string, params interface{}) erro
|
|||
ctx := cmd.Context()
|
||||
cs, err := client.GetCloudService(ctx, backendType)
|
||||
if err != nil {
|
||||
return errors.Wrap(errdefs.ErrLoginFailed, "cannot connect to backend")
|
||||
return errors.Wrap(api.ErrLoginFailed, "cannot connect to backend")
|
||||
}
|
||||
err = cs.Login(ctx, params)
|
||||
if errors.Is(err, context.Canceled) {
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/client"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
// AzureLogoutCommand returns the azure logout command
|
||||
|
@ -44,7 +44,7 @@ func cloudLogout(cmd *cobra.Command, backendType string) error {
|
|||
ctx := cmd.Context()
|
||||
cs, err := client.GetCloudService(ctx, backendType)
|
||||
if err != nil {
|
||||
return errors.Wrap(errdefs.ErrLoginFailed, "cannot connect to backend")
|
||||
return errors.Wrap(api.ErrLoginFailed, "cannot connect to backend")
|
||||
}
|
||||
err = cs.Logout(ctx)
|
||||
if errors.Is(err, context.Canceled) {
|
||||
|
|
|
@ -26,8 +26,8 @@ import (
|
|||
|
||||
"github.com/docker/compose-cli/api/client"
|
||||
"github.com/docker/compose-cli/api/containers"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/cli/formatter"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type rmOpts struct {
|
||||
|
@ -63,9 +63,9 @@ func runRm(ctx context.Context, args []string, opts rmOpts) error {
|
|||
Force: opts.force,
|
||||
})
|
||||
if err != nil {
|
||||
if errdefs.IsForbiddenError(err) {
|
||||
if api.IsForbiddenError(err) {
|
||||
errs = multierror.Append(errs, fmt.Errorf("you cannot remove a running container %s. Stop the container before attempting removal or force remove", id))
|
||||
} else if errdefs.IsNotFoundError(err) {
|
||||
} else if api.IsNotFoundError(err) {
|
||||
errs = multierror.Append(errs, fmt.Errorf("container %s not found", id))
|
||||
} else {
|
||||
errs = multierror.Append(errs, err)
|
||||
|
|
|
@ -29,8 +29,8 @@ import (
|
|||
"github.com/docker/compose-cli/api/client"
|
||||
"github.com/docker/compose-cli/api/containers"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/api/progress"
|
||||
"github.com/docker/compose-cli/cli/options/run"
|
||||
"github.com/docker/compose-cli/pkg/progress"
|
||||
)
|
||||
|
||||
// Command runs a container
|
||||
|
|
|
@ -25,8 +25,8 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/client"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/cli/formatter"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
// StartCommand starts containers
|
||||
|
@ -53,7 +53,7 @@ func runStart(ctx context.Context, args []string) error {
|
|||
for _, id := range args {
|
||||
err := c.ContainerService().Start(ctx, id)
|
||||
if err != nil {
|
||||
if errdefs.IsNotFoundError(err) {
|
||||
if api.IsNotFoundError(err) {
|
||||
errs = multierror.Append(errs, fmt.Errorf("container %s not found", id))
|
||||
} else {
|
||||
errs = multierror.Append(errs, err)
|
||||
|
|
|
@ -25,8 +25,8 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/client"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/cli/formatter"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type stopOpts struct {
|
||||
|
@ -60,7 +60,7 @@ func runStop(ctx context.Context, args []string, opts stopOpts) error {
|
|||
for _, id := range args {
|
||||
err := c.ContainerService().Stop(ctx, id, &opts.timeout)
|
||||
if err != nil {
|
||||
if errdefs.IsNotFoundError(err) {
|
||||
if api.IsNotFoundError(err) {
|
||||
errs = multierror.Append(errs, fmt.Errorf("container %s not found", id))
|
||||
} else {
|
||||
errs = multierror.Append(errs, err)
|
||||
|
|
|
@ -23,10 +23,10 @@ import (
|
|||
"github.com/docker/compose-cli/aci"
|
||||
"github.com/docker/compose-cli/api/client"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/api/progress"
|
||||
"github.com/docker/compose-cli/cli/formatter"
|
||||
formatter2 "github.com/docker/compose-cli/cli/formatter"
|
||||
format "github.com/docker/compose-cli/cli/formatter"
|
||||
"github.com/docker/compose-cli/ecs"
|
||||
"github.com/docker/compose-cli/pkg/progress"
|
||||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -146,7 +146,7 @@ func inspectVolume() *cobra.Command {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
outJSON, err := formatter2.ToStandardJSON(v)
|
||||
outJSON, err := format.ToStandardJSON(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ import (
|
|||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Print prints formatted lists in different formats
|
||||
|
@ -67,7 +67,7 @@ func Print(toJSON interface{}, format string, outWriter io.Writer, writerFn func
|
|||
_, _ = fmt.Fprintln(outWriter, outJSON)
|
||||
}
|
||||
default:
|
||||
return errors.Wrapf(errdefs.ErrParsingFailed, "format value %q could not be parsed", format)
|
||||
return errors.Wrapf(api.ErrParsingFailed, "format value %q could not be parsed", format)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -23,11 +23,11 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
// NewLogConsumer creates a new LogConsumer
|
||||
func NewLogConsumer(ctx context.Context, w io.Writer, color bool, prefix bool) compose.LogConsumer {
|
||||
func NewLogConsumer(ctx context.Context, w io.Writer, color bool, prefix bool) api.LogConsumer {
|
||||
return &logConsumer{
|
||||
ctx: ctx,
|
||||
presenters: map[string]*presenter{},
|
||||
|
|
38
cli/main.go
38
cli/main.go
|
@ -35,13 +35,10 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/backend"
|
||||
api "github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/config"
|
||||
apicontext "github.com/docker/compose-cli/api/context"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/cli/cmd"
|
||||
"github.com/docker/compose-cli/cli/cmd/compose"
|
||||
contextcmd "github.com/docker/compose-cli/cli/cmd/context"
|
||||
"github.com/docker/compose-cli/cli/cmd/login"
|
||||
"github.com/docker/compose-cli/cli/cmd/logout"
|
||||
|
@ -51,7 +48,10 @@ import (
|
|||
"github.com/docker/compose-cli/cli/metrics"
|
||||
"github.com/docker/compose-cli/cli/mobycli"
|
||||
cliopts "github.com/docker/compose-cli/cli/options"
|
||||
compose2 "github.com/docker/compose-cli/cmd/compose"
|
||||
"github.com/docker/compose-cli/local"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/docker/compose-cli/pkg/compose"
|
||||
|
||||
// Backend registrations
|
||||
_ "github.com/docker/compose-cli/aci"
|
||||
|
@ -226,7 +226,7 @@ func main() {
|
|||
if ctype != store.DefaultContextType {
|
||||
// On default context, "compose" is implemented by CLI Plugin
|
||||
proxy := api.NewServiceProxy().WithService(service.ComposeService())
|
||||
command := compose.RootCommand(ctype, proxy)
|
||||
command := compose2.RootCommand(ctype, proxy)
|
||||
|
||||
if ctype == store.AciContextType {
|
||||
customizeCliForACI(command, proxy)
|
||||
|
@ -238,7 +238,7 @@ func main() {
|
|||
if err = root.ExecuteContext(ctx); err != nil {
|
||||
handleError(ctx, err, ctype, currentContext, cc, root)
|
||||
}
|
||||
metrics.Track(ctype, os.Args[1:], metrics.SuccessStatus)
|
||||
metrics.Track(ctype, os.Args[1:], compose.SuccessStatus)
|
||||
}
|
||||
|
||||
func customizeCliForACI(command *cobra.Command, proxy *api.ServiceProxy) {
|
||||
|
@ -263,7 +263,7 @@ func getBackend(ctype string, configDir string, opts cliopts.GlobalOpts) (backen
|
|||
return local.GetLocalBackend(configDir, opts)
|
||||
}
|
||||
service, err := backend.Get(ctype)
|
||||
if errdefs.IsNotFoundError(err) {
|
||||
if api.IsNotFoundError(err) {
|
||||
return service, nil
|
||||
}
|
||||
return service, err
|
||||
|
@ -271,8 +271,8 @@ func getBackend(ctype string, configDir string, opts cliopts.GlobalOpts) (backen
|
|||
|
||||
func handleError(ctx context.Context, err error, ctype string, currentContext string, cc *store.DockerContext, root *cobra.Command) {
|
||||
// if user canceled request, simply exit without any error message
|
||||
if errdefs.IsErrCanceled(err) || errors.Is(ctx.Err(), context.Canceled) {
|
||||
metrics.Track(ctype, os.Args[1:], metrics.CanceledStatus)
|
||||
if api.IsErrCanceled(err) || errors.Is(ctx.Err(), context.Canceled) {
|
||||
metrics.Track(ctype, os.Args[1:], compose.CanceledStatus)
|
||||
os.Exit(130)
|
||||
}
|
||||
if ctype == store.AwsContextType {
|
||||
|
@ -294,34 +294,34 @@ $ docker context create %s <name>`, cc.Type(), store.EcsContextType), ctype)
|
|||
|
||||
func exit(ctx string, err error, ctype string) {
|
||||
if exit, ok := err.(cli.StatusError); ok {
|
||||
metrics.Track(ctype, os.Args[1:], metrics.SuccessStatus)
|
||||
metrics.Track(ctype, os.Args[1:], compose.SuccessStatus)
|
||||
os.Exit(exit.StatusCode)
|
||||
}
|
||||
|
||||
var composeErr metrics.ComposeError
|
||||
metricsStatus := metrics.FailureStatus
|
||||
var composeErr compose.Error
|
||||
metricsStatus := compose.FailureStatus
|
||||
exitCode := 1
|
||||
if errors.As(err, &composeErr) {
|
||||
metricsStatus = composeErr.GetMetricsFailureCategory().MetricsStatus
|
||||
exitCode = composeErr.GetMetricsFailureCategory().ExitCode
|
||||
}
|
||||
if strings.HasPrefix(err.Error(), "unknown shorthand flag:") || strings.HasPrefix(err.Error(), "unknown flag:") || strings.HasPrefix(err.Error(), "unknown docker command:") {
|
||||
metricsStatus = metrics.CommandSyntaxFailure.MetricsStatus
|
||||
exitCode = metrics.CommandSyntaxFailure.ExitCode
|
||||
metricsStatus = compose.CommandSyntaxFailure.MetricsStatus
|
||||
exitCode = compose.CommandSyntaxFailure.ExitCode
|
||||
}
|
||||
metrics.Track(ctype, os.Args[1:], metricsStatus)
|
||||
|
||||
if errors.Is(err, errdefs.ErrLoginRequired) {
|
||||
if errors.Is(err, api.ErrLoginRequired) {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(errdefs.ExitCodeLoginRequired)
|
||||
os.Exit(api.ExitCodeLoginRequired)
|
||||
}
|
||||
|
||||
if compose.Warning != "" {
|
||||
if compose2.Warning != "" {
|
||||
logrus.Warn(err)
|
||||
fmt.Fprintln(os.Stderr, compose.Warning)
|
||||
fmt.Fprintln(os.Stderr, compose2.Warning)
|
||||
}
|
||||
|
||||
if errors.Is(err, errdefs.ErrNotImplemented) {
|
||||
if errors.Is(err, api.ErrNotImplemented) {
|
||||
name := metrics.GetCommand(os.Args[1:])
|
||||
fmt.Fprintf(os.Stderr, "Command %q not available in current context (%s)\n", name, ctx)
|
||||
|
||||
|
@ -344,7 +344,7 @@ func checkIfUnknownCommandExistInDefaultContext(err error, currentContext string
|
|||
|
||||
if mobycli.IsDefaultContextCommand(dockerCommand) {
|
||||
fmt.Fprintf(os.Stderr, "Command %q not available in current context (%s), you can use the \"default\" context to run this command\n", dockerCommand, currentContext)
|
||||
metrics.Track(contextType, os.Args[1:], metrics.FailureStatus)
|
||||
metrics.Track(contextType, os.Args[1:], compose.FailureStatus)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/compose-cli/utils"
|
||||
"github.com/docker/compose-cli/pkg/utils"
|
||||
)
|
||||
|
||||
var managementCommands = []string{"ecs", "scan"}
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/compose-cli/utils"
|
||||
"github.com/docker/compose-cli/pkg/utils"
|
||||
)
|
||||
|
||||
// Track sends the tracking analytics to Docker Desktop
|
||||
|
|
|
@ -24,13 +24,14 @@ import (
|
|||
"os/signal"
|
||||
"regexp"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
apicontext "github.com/docker/compose-cli/api/context"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/cli/metrics"
|
||||
"github.com/docker/compose-cli/cli/mobycli/resolvepath"
|
||||
"github.com/docker/compose-cli/utils"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/pkg/compose"
|
||||
"github.com/docker/compose-cli/pkg/utils"
|
||||
)
|
||||
|
||||
var delegatedContextTypes = []string{store.DefaultContextType}
|
||||
|
@ -68,10 +69,10 @@ func Exec(root *cobra.Command) {
|
|||
if err != nil {
|
||||
if exiterr, ok := err.(*exec.ExitError); ok {
|
||||
exitCode := exiterr.ExitCode()
|
||||
metrics.Track(store.DefaultContextType, os.Args[1:], metrics.ByExitCode(exitCode).MetricsStatus)
|
||||
metrics.Track(store.DefaultContextType, os.Args[1:], compose.ByExitCode(exitCode).MetricsStatus)
|
||||
os.Exit(exitCode)
|
||||
}
|
||||
metrics.Track(store.DefaultContextType, os.Args[1:], metrics.FailureStatus)
|
||||
metrics.Track(store.DefaultContextType, os.Args[1:], compose.FailureStatus)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
@ -79,7 +80,7 @@ func Exec(root *cobra.Command) {
|
|||
if command == "build" && !metrics.HasQuietFlag(os.Args[1:]) {
|
||||
utils.DisplayScanSuggestMsg()
|
||||
}
|
||||
metrics.Track(store.DefaultContextType, os.Args[1:], metrics.SuccessStatus)
|
||||
metrics.Track(store.DefaultContextType, os.Args[1:], compose.SuccessStatus)
|
||||
|
||||
os.Exit(0)
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
|
||||
"github.com/docker/compose-cli/cli/metrics"
|
||||
"github.com/docker/compose-cli/cli/server/proxy"
|
||||
"github.com/docker/compose-cli/pkg/compose"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -60,16 +61,16 @@ func metricsServerInterceptor(client metrics.Client) grpc.UnaryServerInterceptor
|
|||
|
||||
data, err := handler(ctx, req)
|
||||
|
||||
status := metrics.SuccessStatus
|
||||
status := compose.SuccessStatus
|
||||
if err != nil {
|
||||
status = metrics.FailureStatus
|
||||
status = compose.FailureStatus
|
||||
}
|
||||
command := methodMapping[info.FullMethod]
|
||||
if command != "" {
|
||||
client.Send(metrics.Command{
|
||||
Command: command,
|
||||
Context: contextType,
|
||||
Source: metrics.APISource,
|
||||
Source: compose.APISource,
|
||||
Status: status,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -29,9 +29,7 @@ import (
|
|||
"gotest.tools/v3/assert"
|
||||
|
||||
"github.com/docker/compose-cli/api/client"
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/containers"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/api/secrets"
|
||||
"github.com/docker/compose-cli/api/volumes"
|
||||
"github.com/docker/compose-cli/cli/metrics"
|
||||
|
@ -40,6 +38,7 @@ import (
|
|||
streamsv1 "github.com/docker/compose-cli/cli/server/protos/streams/v1"
|
||||
volumesv1 "github.com/docker/compose-cli/cli/server/protos/volumes/v1"
|
||||
"github.com/docker/compose-cli/cli/server/proxy"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
func TestAllMethodsHaveCorrespondingCliCommand(t *testing.T) {
|
||||
|
@ -77,8 +76,8 @@ func TestTrackSFailures(t *testing.T) {
|
|||
interceptor := metricsServerInterceptor(mockMetrics)
|
||||
|
||||
ctx := proxy.WithClient(incomingContext("default"), &newClient)
|
||||
_, err := interceptor(ctx, nil, containerMethodRoute("Create"), mockHandler(errdefs.ErrLoginRequired))
|
||||
assert.Assert(t, err == errdefs.ErrLoginRequired)
|
||||
_, err := interceptor(ctx, nil, containerMethodRoute("Create"), mockHandler(api.ErrLoginRequired))
|
||||
assert.Assert(t, err == api.ErrLoginRequired)
|
||||
}
|
||||
|
||||
func containerMethodRoute(action string) *grpc.UnaryServerInfo {
|
||||
|
@ -115,7 +114,7 @@ func setupServer() *grpc.Server {
|
|||
type noopService struct{}
|
||||
|
||||
func (noopService) ContainerService() containers.Service { return nil }
|
||||
func (noopService) ComposeService() compose.Service { return nil }
|
||||
func (noopService) ComposeService() api.Service { return nil }
|
||||
func (noopService) SecretsService() secrets.Service { return nil }
|
||||
func (noopService) VolumeService() volumes.Service { return nil }
|
||||
func (noopService) ResourceService() resources.Service { return nil }
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
"github.com/compose-spec/compose-go/types"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type buildOptions struct {
|
||||
|
@ -38,7 +38,7 @@ type buildOptions struct {
|
|||
memory string
|
||||
}
|
||||
|
||||
func buildCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func buildCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := buildOptions{
|
||||
projectOptions: p,
|
||||
}
|
||||
|
@ -81,13 +81,13 @@ func buildCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func runBuild(ctx context.Context, backend compose.Service, opts buildOptions, services []string) error {
|
||||
func runBuild(ctx context.Context, backend api.Service, opts buildOptions, services []string) error {
|
||||
project, err := opts.toProject(services)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return backend.Build(ctx, project, compose.BuildOptions{
|
||||
return backend.Build(ctx, project, api.BuildOptions{
|
||||
Pull: opts.pull,
|
||||
Progress: opts.progress,
|
||||
Args: types.NewMappingWithEquals(opts.args),
|
|
@ -33,11 +33,10 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/cli/formatter"
|
||||
"github.com/docker/compose-cli/cli/metrics"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/docker/compose-cli/pkg/compose"
|
||||
)
|
||||
|
||||
//Command defines a compose CLI command as a func with args
|
||||
|
@ -59,11 +58,11 @@ func Adapt(fn Command) func(cmd *cobra.Command, args []string) error {
|
|||
}()
|
||||
}
|
||||
err := fn(ctx, args)
|
||||
var composeErr metrics.ComposeError
|
||||
if errdefs.IsErrCanceled(err) || errors.Is(ctx.Err(), context.Canceled) {
|
||||
var composeErr compose.Error
|
||||
if api.IsErrCanceled(err) || errors.Is(ctx.Err(), context.Canceled) {
|
||||
err = dockercli.StatusError{
|
||||
StatusCode: 130,
|
||||
Status: metrics.CanceledStatus,
|
||||
Status: compose.CanceledStatus,
|
||||
}
|
||||
}
|
||||
if errors.As(err, &composeErr) {
|
||||
|
@ -120,7 +119,7 @@ func (o *projectOptions) WithServices(fn ProjectServicesFunc) func(cmd *cobra.Co
|
|||
if s.Labels == nil {
|
||||
s.Labels = make(map[string]string)
|
||||
}
|
||||
s.Labels[compose.EnvironmentFileLabel] = ef
|
||||
s.Labels[api.EnvironmentFileLabel] = ef
|
||||
services = append(services, s)
|
||||
}
|
||||
}
|
||||
|
@ -156,12 +155,12 @@ func (o *projectOptions) toProjectName() (string, error) {
|
|||
func (o *projectOptions) toProject(services []string, po ...cli.ProjectOptionsFn) (*types.Project, error) {
|
||||
options, err := o.toProjectOptions(po...)
|
||||
if err != nil {
|
||||
return nil, metrics.WrapComposeError(err)
|
||||
return nil, compose.WrapComposeError(err)
|
||||
}
|
||||
|
||||
project, err := cli.ProjectFromOptions(options)
|
||||
if err != nil {
|
||||
return nil, metrics.WrapComposeError(err)
|
||||
return nil, compose.WrapComposeError(err)
|
||||
}
|
||||
|
||||
if len(services) > 0 {
|
||||
|
@ -195,7 +194,7 @@ func (o *projectOptions) toProjectOptions(po ...cli.ProjectOptionsFn) (*cli.Proj
|
|||
}
|
||||
|
||||
// RootCommand returns the compose command with its child commands
|
||||
func RootCommand(contextType string, backend compose.Service) *cobra.Command {
|
||||
func RootCommand(contextType string, backend api.Service) *cobra.Command {
|
||||
opts := projectOptions{}
|
||||
var ansi string
|
||||
var noAnsi bool
|
||||
|
@ -210,7 +209,7 @@ func RootCommand(contextType string, backend compose.Service) *cobra.Command {
|
|||
}
|
||||
_ = cmd.Help()
|
||||
return dockercli.StatusError{
|
||||
StatusCode: metrics.CommandSyntaxFailure.ExitCode,
|
||||
StatusCode: compose.CommandSyntaxFailure.ExitCode,
|
||||
Status: fmt.Sprintf("unknown docker command: %q", "compose "+args[0]),
|
||||
}
|
||||
},
|
|
@ -32,8 +32,8 @@ import (
|
|||
"github.com/opencontainers/go-digest"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/utils"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/docker/compose-cli/pkg/compose"
|
||||
)
|
||||
|
||||
type convertOptions struct {
|
||||
|
@ -51,7 +51,7 @@ type convertOptions struct {
|
|||
|
||||
var addFlagsFuncs []func(cmd *cobra.Command, opts *convertOptions)
|
||||
|
||||
func convertCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func convertCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := convertOptions{
|
||||
projectOptions: p,
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ func convertCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func runConvert(ctx context.Context, backend compose.Service, opts convertOptions, services []string) error {
|
||||
func runConvert(ctx context.Context, backend api.Service, opts convertOptions, services []string) error {
|
||||
var json []byte
|
||||
project, err := opts.toProject(services, cli.WithInterpolation(!opts.noInterpolate))
|
||||
if err != nil {
|
||||
|
@ -124,7 +124,7 @@ func runConvert(ctx context.Context, backend compose.Service, opts convertOption
|
|||
}
|
||||
}
|
||||
|
||||
json, err = backend.Convert(ctx, project, compose.ConvertOptions{
|
||||
json, err = backend.Convert(ctx, project, api.ConvertOptions{
|
||||
Format: opts.Format,
|
||||
Output: opts.Output,
|
||||
})
|
||||
|
@ -180,7 +180,7 @@ func runHash(opts convertOptions) error {
|
|||
return err
|
||||
}
|
||||
for _, s := range project.Services {
|
||||
hash, err := utils.ServiceHash(s)
|
||||
hash, err := compose.ServiceHash(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -23,7 +23,7 @@ import (
|
|||
"github.com/docker/cli/cli"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type copyOptions struct {
|
||||
|
@ -37,7 +37,7 @@ type copyOptions struct {
|
|||
copyUIDGID bool
|
||||
}
|
||||
|
||||
func copyCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func copyCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := copyOptions{
|
||||
projectOptions: p,
|
||||
}
|
||||
|
@ -71,13 +71,13 @@ func copyCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
return copyCmd
|
||||
}
|
||||
|
||||
func runCopy(ctx context.Context, backend compose.Service, opts copyOptions) error {
|
||||
func runCopy(ctx context.Context, backend api.Service, opts copyOptions) error {
|
||||
projects, err := opts.toProject(nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return backend.Copy(ctx, projects, compose.CopyOptions{
|
||||
return backend.Copy(ctx, projects, api.CopyOptions{
|
||||
Source: opts.source,
|
||||
Destination: opts.destination,
|
||||
All: opts.all,
|
|
@ -24,7 +24,7 @@ import (
|
|||
"github.com/compose-spec/compose-go/types"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type createOptions struct {
|
||||
|
@ -40,7 +40,7 @@ type createOptions struct {
|
|||
quietPull bool
|
||||
}
|
||||
|
||||
func createCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func createCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := createOptions{}
|
||||
cmd := &cobra.Command{
|
||||
Use: "create [SERVICE...]",
|
||||
|
@ -55,7 +55,7 @@ func createCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
return nil
|
||||
}),
|
||||
RunE: p.WithProject(func(ctx context.Context, project *types.Project) error {
|
||||
return backend.Create(ctx, project, compose.CreateOptions{
|
||||
return backend.Create(ctx, project, api.CreateOptions{
|
||||
RemoveOrphans: opts.removeOrphans,
|
||||
Recreate: opts.recreateStrategy(),
|
||||
RecreateDependencies: opts.dependenciesRecreateStrategy(),
|
||||
|
@ -75,22 +75,22 @@ func createCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
|
||||
func (opts createOptions) recreateStrategy() string {
|
||||
if opts.noRecreate {
|
||||
return compose.RecreateNever
|
||||
return api.RecreateNever
|
||||
}
|
||||
if opts.forceRecreate {
|
||||
return compose.RecreateForce
|
||||
return api.RecreateForce
|
||||
}
|
||||
return compose.RecreateDiverged
|
||||
return api.RecreateDiverged
|
||||
}
|
||||
|
||||
func (opts createOptions) dependenciesRecreateStrategy() string {
|
||||
if opts.noRecreate {
|
||||
return compose.RecreateNever
|
||||
return api.RecreateNever
|
||||
}
|
||||
if opts.recreateDeps {
|
||||
return compose.RecreateForce
|
||||
return api.RecreateForce
|
||||
}
|
||||
return compose.RecreateDiverged
|
||||
return api.RecreateDiverged
|
||||
}
|
||||
|
||||
func (opts createOptions) GetTimeout() *time.Duration {
|
|
@ -24,7 +24,7 @@ import (
|
|||
"github.com/compose-spec/compose-go/types"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type downOptions struct {
|
||||
|
@ -36,7 +36,7 @@ type downOptions struct {
|
|||
images string
|
||||
}
|
||||
|
||||
func downCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func downCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := downOptions{
|
||||
projectOptions: p,
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ func downCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
return downCmd
|
||||
}
|
||||
|
||||
func runDown(ctx context.Context, backend compose.Service, opts downOptions) error {
|
||||
func runDown(ctx context.Context, backend api.Service, opts downOptions) error {
|
||||
name := opts.ProjectName
|
||||
var project *types.Project
|
||||
if opts.ProjectName == "" {
|
||||
|
@ -83,7 +83,7 @@ func runDown(ctx context.Context, backend compose.Service, opts downOptions) err
|
|||
timeoutValue := time.Duration(opts.timeout) * time.Second
|
||||
timeout = &timeoutValue
|
||||
}
|
||||
return backend.Down(ctx, name, compose.DownOptions{
|
||||
return backend.Down(ctx, name, api.DownOptions{
|
||||
RemoveOrphans: opts.removeOrphans,
|
||||
Project: project,
|
||||
Timeout: timeout,
|
|
@ -21,7 +21,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
@ -31,7 +31,7 @@ type eventsOpts struct {
|
|||
json bool
|
||||
}
|
||||
|
||||
func eventsCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func eventsCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := eventsOpts{
|
||||
composeOptions: &composeOptions{
|
||||
projectOptions: p,
|
||||
|
@ -49,15 +49,15 @@ func eventsCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func runEvents(ctx context.Context, backend compose.Service, opts eventsOpts, services []string) error {
|
||||
func runEvents(ctx context.Context, backend api.Service, opts eventsOpts, services []string) error {
|
||||
project, err := opts.toProjectName()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return backend.Events(ctx, project, compose.EventsOptions{
|
||||
return backend.Events(ctx, project, api.EventsOptions{
|
||||
Services: services,
|
||||
Consumer: func(event compose.Event) error {
|
||||
Consumer: func(event api.Event) error {
|
||||
if opts.json {
|
||||
marshal, err := json.Marshal(map[string]interface{}{
|
||||
"time": event.Timestamp,
|
|
@ -25,7 +25,7 @@ import (
|
|||
"github.com/docker/cli/cli"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type execOpts struct {
|
||||
|
@ -43,7 +43,7 @@ type execOpts struct {
|
|||
privileged bool
|
||||
}
|
||||
|
||||
func execCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func execCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := execOpts{
|
||||
composeOptions: &composeOptions{
|
||||
projectOptions: p,
|
||||
|
@ -75,13 +75,13 @@ func execCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
return runCmd
|
||||
}
|
||||
|
||||
func runExec(ctx context.Context, backend compose.Service, opts execOpts) error {
|
||||
func runExec(ctx context.Context, backend api.Service, opts execOpts) error {
|
||||
project, err := opts.toProject(nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
execOpts := compose.RunOptions{
|
||||
execOpts := api.RunOptions{
|
||||
Service: opts.service,
|
||||
Command: opts.command,
|
||||
Environment: opts.environment,
|
|
@ -24,14 +24,13 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"github.com/docker/go-units"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/cli/formatter"
|
||||
"github.com/docker/compose-cli/utils"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
|
||||
"github.com/docker/go-units"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/docker/compose-cli/pkg/utils"
|
||||
)
|
||||
|
||||
type imageOptions struct {
|
||||
|
@ -39,7 +38,7 @@ type imageOptions struct {
|
|||
Quiet bool
|
||||
}
|
||||
|
||||
func imagesCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func imagesCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := imageOptions{
|
||||
projectOptions: p,
|
||||
}
|
||||
|
@ -54,13 +53,13 @@ func imagesCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
return imgCmd
|
||||
}
|
||||
|
||||
func runImages(ctx context.Context, backend compose.Service, opts imageOptions, services []string) error {
|
||||
func runImages(ctx context.Context, backend api.Service, opts imageOptions, services []string) error {
|
||||
projectName, err := opts.toProjectName()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
images, err := backend.Images(ctx, projectName, compose.ImagesOptions{
|
||||
images, err := backend.Images(ctx, projectName, api.ImagesOptions{
|
||||
Services: services,
|
||||
})
|
||||
if err != nil {
|
|
@ -22,11 +22,11 @@ import (
|
|||
"github.com/compose-spec/compose-go/types"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
func killCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
var opts compose.KillOptions
|
||||
func killCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
var opts api.KillOptions
|
||||
cmd := &cobra.Command{
|
||||
Use: "kill [options] [SERVICE...]",
|
||||
Short: "Force stop service containers.",
|
|
@ -26,9 +26,9 @@ import (
|
|||
"github.com/docker/cli/opts"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/cli/formatter"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type lsOptions struct {
|
||||
|
@ -38,7 +38,7 @@ type lsOptions struct {
|
|||
Filter opts.FilterOpt
|
||||
}
|
||||
|
||||
func listCommand(contextType string, backend compose.Service) *cobra.Command {
|
||||
func listCommand(contextType string, backend api.Service) *cobra.Command {
|
||||
opts := lsOptions{Filter: opts.NewFilterOpt()}
|
||||
lsCmd := &cobra.Command{
|
||||
Use: "ls",
|
||||
|
@ -61,14 +61,14 @@ var acceptedListFilters = map[string]bool{
|
|||
"name": true,
|
||||
}
|
||||
|
||||
func runList(ctx context.Context, backend compose.Service, opts lsOptions) error {
|
||||
func runList(ctx context.Context, backend api.Service, opts lsOptions) error {
|
||||
filters := opts.Filter.Value()
|
||||
err := filters.Validate(acceptedListFilters)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
stackList, err := backend.List(ctx, compose.ListOptions{All: opts.All})
|
||||
stackList, err := backend.List(ctx, api.ListOptions{All: opts.All})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ func runList(ctx context.Context, backend compose.Service, opts lsOptions) error
|
|||
}
|
||||
|
||||
if filters.Len() > 0 {
|
||||
var filtered []compose.Stack
|
||||
var filtered []api.Stack
|
||||
for _, s := range stackList {
|
||||
if filters.Contains("name") && !filters.Match("name", s.Name) {
|
||||
continue
|
||||
|
@ -103,7 +103,7 @@ type stackView struct {
|
|||
Status string
|
||||
}
|
||||
|
||||
func viewFromStackList(stackList []compose.Stack) []stackView {
|
||||
func viewFromStackList(stackList []api.Stack) []stackView {
|
||||
retList := make([]stackView, len(stackList))
|
||||
for i, s := range stackList {
|
||||
retList[i] = stackView{
|
|
@ -22,9 +22,9 @@ import (
|
|||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/cli/formatter"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type logsOptions struct {
|
||||
|
@ -39,7 +39,7 @@ type logsOptions struct {
|
|||
timestamps bool
|
||||
}
|
||||
|
||||
func logsCommand(p *projectOptions, contextType string, backend compose.Service) *cobra.Command {
|
||||
func logsCommand(p *projectOptions, contextType string, backend api.Service) *cobra.Command {
|
||||
opts := logsOptions{
|
||||
projectOptions: p,
|
||||
}
|
||||
|
@ -64,13 +64,13 @@ func logsCommand(p *projectOptions, contextType string, backend compose.Service)
|
|||
return logsCmd
|
||||
}
|
||||
|
||||
func runLogs(ctx context.Context, backend compose.Service, opts logsOptions, services []string) error {
|
||||
func runLogs(ctx context.Context, backend api.Service, opts logsOptions, services []string) error {
|
||||
projectName, err := opts.toProjectName()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
consumer := formatter.NewLogConsumer(ctx, os.Stdout, !opts.noColor, !opts.noPrefix)
|
||||
return backend.Logs(ctx, projectName, consumer, compose.LogOptions{
|
||||
return backend.Logs(ctx, projectName, consumer, api.LogOptions{
|
||||
Services: services,
|
||||
Follow: opts.follow,
|
||||
Tail: opts.tail,
|
|
@ -21,14 +21,14 @@ import (
|
|||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type pauseOptions struct {
|
||||
*projectOptions
|
||||
}
|
||||
|
||||
func pauseCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func pauseCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := pauseOptions{
|
||||
projectOptions: p,
|
||||
}
|
||||
|
@ -42,13 +42,13 @@ func pauseCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func runPause(ctx context.Context, backend compose.Service, opts pauseOptions, services []string) error {
|
||||
func runPause(ctx context.Context, backend api.Service, opts pauseOptions, services []string) error {
|
||||
project, err := opts.toProjectName()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return backend.Pause(ctx, project, compose.PauseOptions{
|
||||
return backend.Pause(ctx, project, api.PauseOptions{
|
||||
Services: services,
|
||||
})
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ type unpauseOptions struct {
|
|||
*projectOptions
|
||||
}
|
||||
|
||||
func unpauseCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func unpauseCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := unpauseOptions{
|
||||
projectOptions: p,
|
||||
}
|
||||
|
@ -71,13 +71,13 @@ func unpauseCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func runUnPause(ctx context.Context, backend compose.Service, opts unpauseOptions, services []string) error {
|
||||
func runUnPause(ctx context.Context, backend api.Service, opts unpauseOptions, services []string) error {
|
||||
project, err := opts.toProjectName()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return backend.UnPause(ctx, project, compose.PauseOptions{
|
||||
return backend.UnPause(ctx, project, api.PauseOptions{
|
||||
Services: services,
|
||||
})
|
||||
}
|
|
@ -23,7 +23,7 @@ import (
|
|||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type portOptions struct {
|
||||
|
@ -33,7 +33,7 @@ type portOptions struct {
|
|||
index int
|
||||
}
|
||||
|
||||
func portCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func portCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := portOptions{
|
||||
projectOptions: p,
|
||||
}
|
||||
|
@ -58,12 +58,12 @@ func portCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func runPort(ctx context.Context, backend compose.Service, opts portOptions, service string) error {
|
||||
func runPort(ctx context.Context, backend api.Service, opts portOptions, service string) error {
|
||||
projectName, err := opts.toProjectName()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ip, port, err := backend.Port(ctx, projectName, service, opts.port, compose.PortOptions{
|
||||
ip, port, err := backend.Port(ctx, projectName, service, opts.port, api.PortOptions{
|
||||
Protocol: opts.protocol,
|
||||
Index: opts.index,
|
||||
})
|
|
@ -26,9 +26,9 @@ import (
|
|||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/cli/formatter"
|
||||
"github.com/docker/compose-cli/utils"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/docker/compose-cli/pkg/utils"
|
||||
)
|
||||
|
||||
type psOptions struct {
|
||||
|
@ -39,7 +39,7 @@ type psOptions struct {
|
|||
Services bool
|
||||
}
|
||||
|
||||
func psCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func psCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := psOptions{
|
||||
projectOptions: p,
|
||||
}
|
||||
|
@ -57,12 +57,12 @@ func psCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
return psCmd
|
||||
}
|
||||
|
||||
func runPs(ctx context.Context, backend compose.Service, services []string, opts psOptions) error {
|
||||
func runPs(ctx context.Context, backend api.Service, services []string, opts psOptions) error {
|
||||
projectName, err := opts.toProjectName()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
containers, err := backend.Ps(ctx, projectName, compose.PsOptions{
|
||||
containers, err := backend.Ps(ctx, projectName, api.PsOptions{
|
||||
All: opts.All,
|
||||
Services: services,
|
||||
})
|
|
@ -24,8 +24,8 @@ import (
|
|||
"github.com/morikuni/aec"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/utils"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/docker/compose-cli/pkg/utils"
|
||||
)
|
||||
|
||||
type pullOptions struct {
|
||||
|
@ -38,7 +38,7 @@ type pullOptions struct {
|
|||
ignorePullFailures bool
|
||||
}
|
||||
|
||||
func pullCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func pullCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := pullOptions{
|
||||
projectOptions: p,
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ func pullCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func runPull(ctx context.Context, backend compose.Service, opts pullOptions, services []string) error {
|
||||
func runPull(ctx context.Context, backend api.Service, opts pullOptions, services []string) error {
|
||||
project, err := opts.toProject(services)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -85,7 +85,7 @@ func runPull(ctx context.Context, backend compose.Service, opts pullOptions, ser
|
|||
project.Services = enabled
|
||||
}
|
||||
|
||||
return backend.Pull(ctx, project, compose.PullOptions{
|
||||
return backend.Pull(ctx, project, api.PullOptions{
|
||||
Quiet: opts.quiet,
|
||||
IgnoreFailures: opts.ignorePullFailures,
|
||||
})
|
|
@ -21,7 +21,7 @@ import (
|
|||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type pushOptions struct {
|
||||
|
@ -31,7 +31,7 @@ type pushOptions struct {
|
|||
Ignorefailures bool
|
||||
}
|
||||
|
||||
func pushCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func pushCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := pushOptions{
|
||||
projectOptions: p,
|
||||
}
|
||||
|
@ -47,13 +47,13 @@ func pushCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
return pushCmd
|
||||
}
|
||||
|
||||
func runPush(ctx context.Context, backend compose.Service, opts pushOptions, services []string) error {
|
||||
func runPush(ctx context.Context, backend api.Service, opts pushOptions, services []string) error {
|
||||
project, err := opts.toProject(services)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return backend.Push(ctx, project, compose.PushOptions{
|
||||
return backend.Push(ctx, project, api.PushOptions{
|
||||
IgnoreFailures: opts.Ignorefailures,
|
||||
})
|
||||
}
|
|
@ -19,7 +19,7 @@ package compose
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -30,7 +30,7 @@ type removeOptions struct {
|
|||
volumes bool
|
||||
}
|
||||
|
||||
func removeCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func removeCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := removeOptions{
|
||||
projectOptions: p,
|
||||
}
|
||||
|
@ -57,19 +57,19 @@ Any data which is not in a volume will be lost.`,
|
|||
return cmd
|
||||
}
|
||||
|
||||
func runRemove(ctx context.Context, backend compose.Service, opts removeOptions, services []string) error {
|
||||
func runRemove(ctx context.Context, backend api.Service, opts removeOptions, services []string) error {
|
||||
project, err := opts.toProject(services)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if opts.stop {
|
||||
return backend.Stop(ctx, project, compose.StopOptions{
|
||||
return backend.Stop(ctx, project, api.StopOptions{
|
||||
Services: services,
|
||||
})
|
||||
}
|
||||
|
||||
return backend.Remove(ctx, project, compose.RemoveOptions{
|
||||
return backend.Remove(ctx, project, api.RemoveOptions{
|
||||
Services: services,
|
||||
})
|
||||
}
|
|
@ -22,7 +22,7 @@ import (
|
|||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type restartOptions struct {
|
||||
|
@ -30,7 +30,7 @@ type restartOptions struct {
|
|||
timeout int
|
||||
}
|
||||
|
||||
func restartCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func restartCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := restartOptions{
|
||||
projectOptions: p,
|
||||
}
|
||||
|
@ -47,14 +47,14 @@ func restartCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
return restartCmd
|
||||
}
|
||||
|
||||
func runRestart(ctx context.Context, backend compose.Service, opts restartOptions, services []string) error {
|
||||
func runRestart(ctx context.Context, backend api.Service, opts restartOptions, services []string) error {
|
||||
project, err := opts.toProject(services)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
timeout := time.Duration(opts.timeout) * time.Second
|
||||
return backend.Restart(ctx, project, compose.RestartOptions{
|
||||
return backend.Restart(ctx, project, api.RestartOptions{
|
||||
Timeout: &timeout,
|
||||
Services: services,
|
||||
})
|
|
@ -29,8 +29,8 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/progress"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/docker/compose-cli/pkg/progress"
|
||||
)
|
||||
|
||||
type runOptions struct {
|
||||
|
@ -100,7 +100,7 @@ func (opts runOptions) apply(project *types.Project) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func runCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func runCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := runOptions{
|
||||
composeOptions: &composeOptions{
|
||||
projectOptions: p,
|
||||
|
@ -152,7 +152,7 @@ func notAtTTY() bool {
|
|||
return !isatty.IsTerminal(os.Stdout.Fd())
|
||||
}
|
||||
|
||||
func runRun(ctx context.Context, backend compose.Service, project *types.Project, opts runOptions) error {
|
||||
func runRun(ctx context.Context, backend api.Service, project *types.Project, opts runOptions) error {
|
||||
err := opts.apply(project)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -183,7 +183,7 @@ func runRun(ctx context.Context, backend compose.Service, project *types.Project
|
|||
}
|
||||
|
||||
// start container and attach to container streams
|
||||
runOpts := compose.RunOptions{
|
||||
runOpts := api.RunOptions{
|
||||
Name: opts.name,
|
||||
Service: opts.Service,
|
||||
Command: opts.Command,
|
||||
|
@ -211,7 +211,7 @@ func runRun(ctx context.Context, backend compose.Service, project *types.Project
|
|||
return err
|
||||
}
|
||||
|
||||
func startDependencies(ctx context.Context, backend compose.Service, project types.Project, requestedServiceName string) error {
|
||||
func startDependencies(ctx context.Context, backend api.Service, project types.Project, requestedServiceName string) error {
|
||||
dependencies := types.Services{}
|
||||
var requestedService types.ServiceConfig
|
||||
for _, service := range project.Services {
|
||||
|
@ -224,8 +224,8 @@ func startDependencies(ctx context.Context, backend compose.Service, project typ
|
|||
|
||||
project.Services = dependencies
|
||||
project.DisabledServices = append(project.DisabledServices, requestedService)
|
||||
if err := backend.Create(ctx, &project, compose.CreateOptions{}); err != nil {
|
||||
if err := backend.Create(ctx, &project, api.CreateOptions{}); err != nil {
|
||||
return err
|
||||
}
|
||||
return backend.Start(ctx, &project, compose.StartOptions{})
|
||||
return backend.Start(ctx, &project, api.StartOptions{})
|
||||
}
|
|
@ -19,7 +19,7 @@ package compose
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -27,7 +27,7 @@ type startOptions struct {
|
|||
*projectOptions
|
||||
}
|
||||
|
||||
func startCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func startCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := startOptions{
|
||||
projectOptions: p,
|
||||
}
|
||||
|
@ -41,11 +41,11 @@ func startCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
return startCmd
|
||||
}
|
||||
|
||||
func runStart(ctx context.Context, backend compose.Service, opts startOptions, services []string) error {
|
||||
func runStart(ctx context.Context, backend api.Service, opts startOptions, services []string) error {
|
||||
project, err := opts.toProject(services)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return backend.Start(ctx, project, compose.StartOptions{})
|
||||
return backend.Start(ctx, project, api.StartOptions{})
|
||||
}
|
|
@ -22,7 +22,7 @@ import (
|
|||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type stopOptions struct {
|
||||
|
@ -31,7 +31,7 @@ type stopOptions struct {
|
|||
timeout int
|
||||
}
|
||||
|
||||
func stopCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func stopCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := stopOptions{
|
||||
projectOptions: p,
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func stopCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func runStop(ctx context.Context, backend compose.Service, opts stopOptions, services []string) error {
|
||||
func runStop(ctx context.Context, backend api.Service, opts stopOptions, services []string) error {
|
||||
project, err := opts.toProject(services)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -62,7 +62,7 @@ func runStop(ctx context.Context, backend compose.Service, opts stopOptions, ser
|
|||
timeoutValue := time.Duration(opts.timeout) * time.Second
|
||||
timeout = &timeoutValue
|
||||
}
|
||||
return backend.Stop(ctx, project, compose.StopOptions{
|
||||
return backend.Stop(ctx, project, api.StopOptions{
|
||||
Timeout: timeout,
|
||||
Services: services,
|
||||
})
|
|
@ -27,14 +27,14 @@ import (
|
|||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
type topOptions struct {
|
||||
*projectOptions
|
||||
}
|
||||
|
||||
func topCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func topCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
opts := topOptions{
|
||||
projectOptions: p,
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ func topCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
return topCmd
|
||||
}
|
||||
|
||||
func runTop(ctx context.Context, backend compose.Service, opts topOptions, services []string) error {
|
||||
func runTop(ctx context.Context, backend api.Service, opts topOptions, services []string) error {
|
||||
projectName, err := opts.toProjectName()
|
||||
if err != nil {
|
||||
return err
|
|
@ -24,10 +24,11 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/compose-spec/compose-go/types"
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/cli/formatter"
|
||||
"github.com/docker/compose-cli/utils"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/cli/formatter"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/docker/compose-cli/pkg/utils"
|
||||
)
|
||||
|
||||
// composeOptions hold options common to `up` and `run` to run compose project
|
||||
|
@ -89,7 +90,7 @@ func (opts upOptions) apply(project *types.Project, services []string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func upCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||
func upCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
up := upOptions{}
|
||||
create := createOptions{}
|
||||
upCmd := &cobra.Command{
|
||||
|
@ -144,7 +145,7 @@ func upCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
|||
return upCmd
|
||||
}
|
||||
|
||||
func runUp(ctx context.Context, backend compose.Service, createOptions createOptions, upOptions upOptions, project *types.Project, services []string) error {
|
||||
func runUp(ctx context.Context, backend api.Service, createOptions createOptions, upOptions upOptions, project *types.Project, services []string) error {
|
||||
if len(project.Services) == 0 {
|
||||
return fmt.Errorf("no service selected")
|
||||
}
|
||||
|
@ -156,7 +157,7 @@ func runUp(ctx context.Context, backend compose.Service, createOptions createOpt
|
|||
return err
|
||||
}
|
||||
|
||||
var consumer compose.LogConsumer
|
||||
var consumer api.LogConsumer
|
||||
if !upOptions.Detach {
|
||||
consumer = formatter.NewLogConsumer(ctx, os.Stdout, !upOptions.noColor, !upOptions.noPrefix)
|
||||
}
|
||||
|
@ -166,7 +167,7 @@ func runUp(ctx context.Context, backend compose.Service, createOptions createOpt
|
|||
attachTo = project.ServiceNames()
|
||||
}
|
||||
|
||||
create := compose.CreateOptions{
|
||||
create := api.CreateOptions{
|
||||
RemoveOrphans: createOptions.removeOrphans,
|
||||
Recreate: createOptions.recreateStrategy(),
|
||||
RecreateDependencies: createOptions.dependenciesRecreateStrategy(),
|
||||
|
@ -179,9 +180,9 @@ func runUp(ctx context.Context, backend compose.Service, createOptions createOpt
|
|||
return backend.Create(ctx, project, create)
|
||||
}
|
||||
|
||||
return backend.Up(ctx, project, compose.UpOptions{
|
||||
return backend.Up(ctx, project, api.UpOptions{
|
||||
Create: create,
|
||||
Start: compose.StartOptions{
|
||||
Start: api.StartOptions{
|
||||
Attach: consumer,
|
||||
AttachTo: attachTo,
|
||||
ExitCodeFrom: upOptions.exitCodeFrom,
|
|
@ -25,24 +25,23 @@ import (
|
|||
"github.com/docker/cli/cli/command"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
api "github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/cli/cmd/compose"
|
||||
"github.com/docker/compose-cli/cli/metrics"
|
||||
commands "github.com/docker/compose-cli/cmd/compose"
|
||||
"github.com/docker/compose-cli/internal"
|
||||
impl "github.com/docker/compose-cli/local/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/docker/compose-cli/pkg/compose"
|
||||
)
|
||||
|
||||
func main() {
|
||||
plugin.Run(func(dockerCli command.Cli) *cobra.Command {
|
||||
lazyInit := api.NewServiceProxy()
|
||||
cmd := compose.RootCommand(store.DefaultContextType, lazyInit)
|
||||
cmd := commands.RootCommand(store.DefaultContextType, lazyInit)
|
||||
originalPreRun := cmd.PersistentPreRunE
|
||||
cmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
|
||||
if err := plugin.PersistentPreRunE(cmd, args); err != nil {
|
||||
return err
|
||||
}
|
||||
lazyInit.WithService(impl.NewComposeService(dockerCli.Client(), dockerCli.ConfigFile()))
|
||||
lazyInit.WithService(compose.NewComposeService(dockerCli.Client(), dockerCli.ConfigFile()))
|
||||
if originalPreRun != nil {
|
||||
return originalPreRun(cmd, args)
|
||||
}
|
||||
|
@ -50,7 +49,7 @@ func main() {
|
|||
}
|
||||
cmd.SetFlagErrorFunc(func(c *cobra.Command, err error) error {
|
||||
return dockercli.StatusError{
|
||||
StatusCode: metrics.CommandSyntaxFailure.ExitCode,
|
||||
StatusCode: compose.CommandSyntaxFailure.ExitCode,
|
||||
Status: err.Error(),
|
||||
}
|
||||
})
|
|
@ -27,7 +27,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"github.com/docker/compose-cli/cli/cmd/compose"
|
||||
"github.com/docker/compose-cli/cmd/compose"
|
||||
. "github.com/docker/compose-cli/docs/yaml"
|
||||
)
|
||||
|
||||
|
|
10
ecs/aws.go
10
ecs/aws.go
|
@ -22,8 +22,8 @@ import (
|
|||
"github.com/aws/aws-sdk-go/service/cloudformation"
|
||||
"github.com/aws/aws-sdk-go/service/ecs"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/secrets"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -49,7 +49,7 @@ type API interface {
|
|||
UpdateStack(ctx context.Context, changeset string) error
|
||||
WaitStackComplete(ctx context.Context, name string, operation int) error
|
||||
GetStackID(ctx context.Context, name string) (string, error)
|
||||
ListStacks(ctx context.Context) ([]compose.Stack, error)
|
||||
ListStacks(ctx context.Context) ([]api.Stack, error)
|
||||
GetStackClusterID(ctx context.Context, stack string) (string, error)
|
||||
GetServiceTaskDefinition(ctx context.Context, cluster string, serviceArns []string) (map[string]string, error)
|
||||
ListStackServices(ctx context.Context, stack string) ([]string, error)
|
||||
|
@ -64,9 +64,9 @@ type API interface {
|
|||
ListSecrets(ctx context.Context) ([]secrets.Secret, error)
|
||||
DeleteSecret(ctx context.Context, id string, recover bool) error
|
||||
GetLogs(ctx context.Context, name string, consumer func(container string, service string, message string), follow bool) error
|
||||
DescribeService(ctx context.Context, cluster string, arn string) (compose.ServiceStatus, error)
|
||||
DescribeServiceTasks(ctx context.Context, cluster string, project string, service string) ([]compose.ContainerSummary, error)
|
||||
getURLWithPortMapping(ctx context.Context, targetGroupArns []string) ([]compose.PortPublisher, error)
|
||||
DescribeService(ctx context.Context, cluster string, arn string) (api.ServiceStatus, error)
|
||||
DescribeServiceTasks(ctx context.Context, cluster string, project string, service string) ([]api.ContainerSummary, error)
|
||||
getURLWithPortMapping(ctx context.Context, targetGroupArns []string) ([]api.PortPublisher, error)
|
||||
ListTasks(ctx context.Context, cluster string, family string) ([]string, error)
|
||||
GetPublicIPs(ctx context.Context, interfaces ...string) (map[string]string, error)
|
||||
ResolveLoadBalancer(ctx context.Context, nameOrArn string) (awsResource, string, string, []awsResource, error)
|
||||
|
|
|
@ -22,9 +22,6 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws/arn"
|
||||
"github.com/aws/aws-sdk-go/service/elbv2"
|
||||
"github.com/awslabs/goformation/v4/cloudformation"
|
||||
|
@ -33,6 +30,7 @@ import (
|
|||
"github.com/awslabs/goformation/v4/cloudformation/efs"
|
||||
"github.com/awslabs/goformation/v4/cloudformation/elasticloadbalancingv2"
|
||||
"github.com/compose-spec/compose-go/types"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
@ -156,7 +154,7 @@ func (b *ecsAPIService) parseClusterExtension(ctx context.Context, project *type
|
|||
return nil, err
|
||||
}
|
||||
if !ok {
|
||||
return nil, errors.Wrapf(errdefs.ErrNotFound, "cluster %q does not exist", cluster)
|
||||
return nil, errors.Wrapf(api.ErrNotFound, "cluster %q does not exist", cluster)
|
||||
}
|
||||
|
||||
template.Metadata["Cluster"] = cluster.ARN()
|
||||
|
@ -268,7 +266,7 @@ func (b *ecsAPIService) parseExternalNetworks(ctx context.Context, project *type
|
|||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.Wrapf(errdefs.ErrNotFound, "security group %q doesn't exist", net.Name)
|
||||
return nil, errors.Wrapf(api.ErrNotFound, "security group %q doesn't exist", net.Name)
|
||||
}
|
||||
securityGroups[name] = net.Name
|
||||
}
|
||||
|
@ -289,8 +287,8 @@ func (b *ecsAPIService) parseExternalVolumes(ctx context.Context, project *types
|
|||
|
||||
logrus.Debugf("searching for existing filesystem as volume %q", name)
|
||||
tags := map[string]string{
|
||||
compose.ProjectLabel: project.Name,
|
||||
compose.VolumeLabel: name,
|
||||
api.ProjectLabel: project.Name,
|
||||
api.VolumeLabel: name,
|
||||
}
|
||||
previous, err := b.aws.ListFileSystems(ctx, tags)
|
||||
if err != nil {
|
||||
|
@ -397,11 +395,11 @@ func (b *ecsAPIService) ensureVolumes(r *awsResources, project *types.Project, t
|
|||
FileSystemPolicy: nil,
|
||||
FileSystemTags: []efs.FileSystem_ElasticFileSystemTag{
|
||||
{
|
||||
Key: compose.ProjectLabel,
|
||||
Key: api.ProjectLabel,
|
||||
Value: project.Name,
|
||||
},
|
||||
{
|
||||
Key: compose.VolumeLabel,
|
||||
Key: api.VolumeLabel,
|
||||
Value: name,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -8,8 +8,8 @@ import (
|
|||
context "context"
|
||||
cloudformation "github.com/aws/aws-sdk-go/service/cloudformation"
|
||||
ecs "github.com/aws/aws-sdk-go/service/ecs"
|
||||
compose "github.com/docker/compose-cli/api/compose"
|
||||
secrets "github.com/docker/compose-cli/api/secrets"
|
||||
compose "github.com/docker/compose-cli/pkg/api"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
|
|
@ -23,14 +23,13 @@ import (
|
|||
"github.com/docker/compose-cli/api/backend"
|
||||
|
||||
"github.com/docker/compose-cli/api/cloud"
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/containers"
|
||||
apicontext "github.com/docker/compose-cli/api/context"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"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/pkg/api"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
|
@ -125,7 +124,7 @@ func (b *ecsAPIService) ContainerService() containers.Service {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (b *ecsAPIService) ComposeService() compose.Service {
|
||||
func (b *ecsAPIService) ComposeService() api.Service {
|
||||
return b
|
||||
}
|
||||
|
||||
|
@ -149,11 +148,11 @@ type ecsCloudService struct {
|
|||
}
|
||||
|
||||
func (a ecsCloudService) Login(ctx context.Context, params interface{}) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (a ecsCloudService) Logout(ctx context.Context) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (a ecsCloudService) CreateContextData(ctx context.Context, params interface{}) (interface{}, string, error) {
|
||||
|
|
|
@ -23,10 +23,6 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/config"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
|
||||
ecsapi "github.com/aws/aws-sdk-go/service/ecs"
|
||||
"github.com/aws/aws-sdk-go/service/elbv2"
|
||||
cloudmapapi "github.com/aws/aws-sdk-go/service/servicediscovery"
|
||||
|
@ -42,16 +38,18 @@ import (
|
|||
"github.com/compose-spec/compose-go/types"
|
||||
"github.com/distribution/distribution/v3/reference"
|
||||
cliconfig "github.com/docker/cli/cli/config"
|
||||
"github.com/docker/compose-cli/api/config"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/opencontainers/go-digest"
|
||||
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||
"sigs.k8s.io/kustomize/kyaml/yaml/merge2"
|
||||
)
|
||||
|
||||
func (b *ecsAPIService) Kill(ctx context.Context, project *types.Project, options compose.KillOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (b *ecsAPIService) Kill(ctx context.Context, project *types.Project, options api.KillOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (b *ecsAPIService) Convert(ctx context.Context, project *types.Project, options compose.ConvertOptions) ([]byte, error) {
|
||||
func (b *ecsAPIService) Convert(ctx context.Context, project *types.Project, options api.ConvertOptions) ([]byte, error) {
|
||||
err := b.resolveServiceImagesDigests(ctx, project)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
|
||||
"github.com/aws/aws-sdk-go/service/elbv2"
|
||||
"github.com/awslabs/goformation/v4/cloudformation"
|
||||
|
@ -406,8 +406,8 @@ volumes:
|
|||
provisioned_throughput: 1024
|
||||
`, useDefaultVPC, func(m *MockAPIMockRecorder) {
|
||||
m.ListFileSystems(gomock.Any(), map[string]string{
|
||||
compose.ProjectLabel: t.Name(),
|
||||
compose.VolumeLabel: "db-data",
|
||||
api.ProjectLabel: t.Name(),
|
||||
api.VolumeLabel: "db-data",
|
||||
}).Return(nil, nil)
|
||||
})
|
||||
n := volumeResourceName("db-data")
|
||||
|
@ -452,8 +452,8 @@ volumes:
|
|||
db-data: {}
|
||||
`, useDefaultVPC, func(m *MockAPIMockRecorder) {
|
||||
m.ListFileSystems(gomock.Any(), map[string]string{
|
||||
compose.ProjectLabel: t.Name(),
|
||||
compose.VolumeLabel: "db-data",
|
||||
api.ProjectLabel: t.Name(),
|
||||
api.VolumeLabel: "db-data",
|
||||
}).Return([]awsResource{
|
||||
existingAWSResource{
|
||||
id: "fs-123abc",
|
||||
|
@ -521,7 +521,7 @@ services:
|
|||
for i := 0; i < tags.Len(); i++ {
|
||||
k := tags.Index(i).FieldByName("Key").String()
|
||||
v := tags.Index(i).FieldByName("Value").String()
|
||||
if k == compose.ProjectLabel {
|
||||
if k == api.ProjectLabel {
|
||||
assert.Equal(t, v, t.Name())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,9 +24,7 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/utils/prompt"
|
||||
"github.com/docker/compose-cli/pkg/prompt"
|
||||
|
||||
"github.com/AlecAivazis/survey/v2/terminal"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
|
@ -34,6 +32,8 @@ import (
|
|||
"github.com/aws/aws-sdk-go/aws/defaults"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/pkg/errors"
|
||||
"gopkg.in/ini.v1"
|
||||
)
|
||||
|
@ -92,7 +92,7 @@ func (h contextCreateAWSHelper) createContextData(_ context.Context, opts Contex
|
|||
return nil, "", err
|
||||
}
|
||||
if !contains(profilesList, opts.Profile) {
|
||||
return nil, "", errors.Wrapf(errdefs.ErrNotFound, "profile %q not found", opts.Profile)
|
||||
return nil, "", errors.Wrapf(api.ErrNotFound, "profile %q not found", opts.Profile)
|
||||
}
|
||||
} else {
|
||||
// interactive
|
||||
|
@ -117,7 +117,7 @@ func (h contextCreateAWSHelper) createContextData(_ context.Context, opts Contex
|
|||
selected, err := h.user.Select("Create a Docker context using:", options)
|
||||
if err != nil {
|
||||
if err == terminal.InterruptErr {
|
||||
return nil, "", errdefs.ErrCanceled
|
||||
return nil, "", api.ErrCanceled
|
||||
}
|
||||
return nil, "", err
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ func (h contextCreateAWSHelper) chooseProfile(profiles []string) (string, error)
|
|||
selected, err := h.user.Select("Select AWS Profile", options)
|
||||
if err != nil {
|
||||
if err == terminal.InterruptErr {
|
||||
return "", errdefs.ErrCanceled
|
||||
return "", api.ErrCanceled
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/utils/prompt"
|
||||
"github.com/docker/compose-cli/pkg/prompt"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"gotest.tools/v3/assert"
|
||||
|
|
11
ecs/down.go
11
ecs/down.go
|
@ -21,17 +21,16 @@ import (
|
|||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/api/progress"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/docker/compose-cli/pkg/progress"
|
||||
)
|
||||
|
||||
func (b *ecsAPIService) Down(ctx context.Context, projectName string, options compose.DownOptions) error {
|
||||
func (b *ecsAPIService) Down(ctx context.Context, projectName string, options api.DownOptions) error {
|
||||
if options.Volumes {
|
||||
return errors.Wrap(errdefs.ErrNotImplemented, "--volumes option is not supported on ECS")
|
||||
return errors.Wrap(api.ErrNotImplemented, "--volumes option is not supported on ECS")
|
||||
}
|
||||
if options.Images != "" {
|
||||
return errors.Wrap(errdefs.ErrNotImplemented, "--rmi option is not supported on ECS")
|
||||
return errors.Wrap(api.ErrNotImplemented, "--rmi option is not supported on ECS")
|
||||
}
|
||||
return progress.Run(ctx, func(ctx context.Context) error {
|
||||
return b.down(ctx, projectName)
|
||||
|
|
|
@ -21,10 +21,9 @@ import (
|
|||
|
||||
"github.com/compose-spec/compose-go/types"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
func (b *ecsAPIService) Exec(ctx context.Context, project *types.Project, opts compose.RunOptions) (int, error) {
|
||||
return 0, errdefs.ErrNotImplemented
|
||||
func (b *ecsAPIService) Exec(ctx context.Context, project *types.Project, opts api.RunOptions) (int, error) {
|
||||
return 0, api.ErrNotImplemented
|
||||
}
|
||||
|
|
|
@ -19,10 +19,9 @@ package ecs
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
func (b *ecsAPIService) Images(ctx context.Context, projectName string, options compose.ImagesOptions) ([]compose.ImageSummary, error) {
|
||||
return nil, errdefs.ErrNotImplemented
|
||||
func (b *ecsAPIService) Images(ctx context.Context, projectName string, options api.ImagesOptions) ([]api.ImageSummary, error) {
|
||||
return nil, api.ErrNotImplemented
|
||||
}
|
||||
|
|
|
@ -20,19 +20,19 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
func (b *ecsAPIService) List(ctx context.Context, opts compose.ListOptions) ([]compose.Stack, error) {
|
||||
func (b *ecsAPIService) List(ctx context.Context, opts api.ListOptions) ([]api.Stack, error) {
|
||||
stacks, err := b.aws.ListStacks(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, stack := range stacks {
|
||||
if stack.Status == compose.STARTING {
|
||||
if stack.Status == api.STARTING {
|
||||
if err := b.checkStackState(ctx, stack.Name); err != nil {
|
||||
stack.Status = compose.FAILED
|
||||
stack.Status = api.FAILED
|
||||
stack.Reason = err.Error()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,13 +24,13 @@ import (
|
|||
|
||||
"github.com/docker/compose-cli/api/backend"
|
||||
"github.com/docker/compose-cli/api/cloud"
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/containers"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"github.com/docker/compose-cli/api/resources"
|
||||
"github.com/docker/compose-cli/api/secrets"
|
||||
"github.com/docker/compose-cli/api/volumes"
|
||||
local_compose "github.com/docker/compose-cli/local/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/docker/compose-cli/pkg/compose"
|
||||
)
|
||||
|
||||
const backendType = store.EcsLocalSimulationContextType
|
||||
|
@ -41,7 +41,7 @@ func init() {
|
|||
|
||||
type ecsLocalSimulation struct {
|
||||
moby *client.Client
|
||||
compose compose.Service
|
||||
compose api.Service
|
||||
}
|
||||
|
||||
func service() (backend.Service, error) {
|
||||
|
@ -52,7 +52,7 @@ func service() (backend.Service, error) {
|
|||
|
||||
return &ecsLocalSimulation{
|
||||
moby: apiClient,
|
||||
compose: local_compose.NewComposeService(apiClient, cliconfig.LoadDefaultConfigFile(os.Stderr)),
|
||||
compose: compose.NewComposeService(apiClient, cliconfig.LoadDefaultConfigFile(os.Stderr)),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ func (e ecsLocalSimulation) SecretsService() secrets.Service {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) ComposeService() compose.Service {
|
||||
func (e ecsLocalSimulation) ComposeService() api.Service {
|
||||
return e
|
||||
}
|
||||
|
||||
|
|
|
@ -28,23 +28,22 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
"github.com/sanathkr/go-yaml"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
func (e ecsLocalSimulation) Build(ctx context.Context, project *types.Project, options compose.BuildOptions) error {
|
||||
func (e ecsLocalSimulation) Build(ctx context.Context, project *types.Project, options api.BuildOptions) error {
|
||||
return e.compose.Build(ctx, project, options)
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Push(ctx context.Context, project *types.Project, options compose.PushOptions) error {
|
||||
func (e ecsLocalSimulation) Push(ctx context.Context, project *types.Project, options api.PushOptions) error {
|
||||
return e.compose.Push(ctx, project, options)
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Pull(ctx context.Context, project *types.Project, options compose.PullOptions) error {
|
||||
func (e ecsLocalSimulation) Pull(ctx context.Context, project *types.Project, options api.PullOptions) error {
|
||||
return e.compose.Pull(ctx, project, options)
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Create(ctx context.Context, project *types.Project, opts compose.CreateOptions) error {
|
||||
func (e ecsLocalSimulation) Create(ctx context.Context, project *types.Project, opts api.CreateOptions) error {
|
||||
enhanced, err := e.enhanceForLocalSimulation(project)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -53,27 +52,27 @@ func (e ecsLocalSimulation) Create(ctx context.Context, project *types.Project,
|
|||
return e.compose.Create(ctx, enhanced, opts)
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Start(ctx context.Context, project *types.Project, options compose.StartOptions) error {
|
||||
func (e ecsLocalSimulation) Start(ctx context.Context, project *types.Project, options api.StartOptions) error {
|
||||
return e.compose.Start(ctx, project, options)
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Restart(ctx context.Context, project *types.Project, options compose.RestartOptions) error {
|
||||
func (e ecsLocalSimulation) Restart(ctx context.Context, project *types.Project, options api.RestartOptions) error {
|
||||
return e.compose.Restart(ctx, project, options)
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Stop(ctx context.Context, project *types.Project, options compose.StopOptions) error {
|
||||
func (e ecsLocalSimulation) Stop(ctx context.Context, project *types.Project, options api.StopOptions) error {
|
||||
return e.compose.Stop(ctx, project, options)
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Up(ctx context.Context, project *types.Project, options compose.UpOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (e ecsLocalSimulation) Up(ctx context.Context, project *types.Project, options api.UpOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Kill(ctx context.Context, project *types.Project, options compose.KillOptions) error {
|
||||
func (e ecsLocalSimulation) Kill(ctx context.Context, project *types.Project, options api.KillOptions) error {
|
||||
return e.compose.Kill(ctx, project, options)
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Convert(ctx context.Context, project *types.Project, options compose.ConvertOptions) ([]byte, error) {
|
||||
func (e ecsLocalSimulation) Convert(ctx context.Context, project *types.Project, options api.ConvertOptions) ([]byte, error) {
|
||||
enhanced, err := e.enhanceForLocalSimulation(project)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -161,57 +160,57 @@ func (e ecsLocalSimulation) enhanceForLocalSimulation(project *types.Project) (*
|
|||
return project, nil
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Down(ctx context.Context, projectName string, options compose.DownOptions) error {
|
||||
func (e ecsLocalSimulation) Down(ctx context.Context, projectName string, options api.DownOptions) error {
|
||||
options.RemoveOrphans = true
|
||||
return e.compose.Down(ctx, projectName, options)
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Logs(ctx context.Context, projectName string, consumer compose.LogConsumer, options compose.LogOptions) error {
|
||||
func (e ecsLocalSimulation) Logs(ctx context.Context, projectName string, consumer api.LogConsumer, options api.LogOptions) error {
|
||||
return e.compose.Logs(ctx, projectName, consumer, options)
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Ps(ctx context.Context, projectName string, options compose.PsOptions) ([]compose.ContainerSummary, error) {
|
||||
func (e ecsLocalSimulation) Ps(ctx context.Context, projectName string, options api.PsOptions) ([]api.ContainerSummary, error) {
|
||||
return e.compose.Ps(ctx, projectName, options)
|
||||
}
|
||||
func (e ecsLocalSimulation) List(ctx context.Context, opts compose.ListOptions) ([]compose.Stack, error) {
|
||||
func (e ecsLocalSimulation) List(ctx context.Context, opts api.ListOptions) ([]api.Stack, error) {
|
||||
return e.compose.List(ctx, opts)
|
||||
}
|
||||
func (e ecsLocalSimulation) RunOneOffContainer(ctx context.Context, project *types.Project, opts compose.RunOptions) (int, error) {
|
||||
return 0, errors.Wrap(errdefs.ErrNotImplemented, "use docker-compose run")
|
||||
func (e ecsLocalSimulation) RunOneOffContainer(ctx context.Context, project *types.Project, opts api.RunOptions) (int, error) {
|
||||
return 0, errors.Wrap(api.ErrNotImplemented, "use docker-compose run")
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Remove(ctx context.Context, project *types.Project, options compose.RemoveOptions) error {
|
||||
func (e ecsLocalSimulation) Remove(ctx context.Context, project *types.Project, options api.RemoveOptions) error {
|
||||
return e.compose.Remove(ctx, project, options)
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Exec(ctx context.Context, project *types.Project, opts compose.RunOptions) (int, error) {
|
||||
return 0, errdefs.ErrNotImplemented
|
||||
func (e ecsLocalSimulation) Exec(ctx context.Context, project *types.Project, opts api.RunOptions) (int, error) {
|
||||
return 0, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Copy(ctx context.Context, project *types.Project, opts compose.CopyOptions) error {
|
||||
func (e ecsLocalSimulation) Copy(ctx context.Context, project *types.Project, opts api.CopyOptions) error {
|
||||
return e.compose.Copy(ctx, project, opts)
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Pause(ctx context.Context, project string, options compose.PauseOptions) error {
|
||||
func (e ecsLocalSimulation) Pause(ctx context.Context, project string, options api.PauseOptions) error {
|
||||
return e.compose.Pause(ctx, project, options)
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) UnPause(ctx context.Context, project string, options compose.PauseOptions) error {
|
||||
func (e ecsLocalSimulation) UnPause(ctx context.Context, project string, options api.PauseOptions) error {
|
||||
return e.compose.UnPause(ctx, project, options)
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Top(ctx context.Context, projectName string, services []string) ([]compose.ContainerProcSummary, error) {
|
||||
func (e ecsLocalSimulation) Top(ctx context.Context, projectName string, services []string) ([]api.ContainerProcSummary, error) {
|
||||
return e.compose.Top(ctx, projectName, services)
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Events(ctx context.Context, project string, options compose.EventsOptions) error {
|
||||
func (e ecsLocalSimulation) Events(ctx context.Context, project string, options api.EventsOptions) error {
|
||||
return e.compose.Events(ctx, project, options)
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Port(ctx context.Context, project string, service string, port int, options compose.PortOptions) (string, int, error) {
|
||||
return "", 0, errdefs.ErrNotImplemented
|
||||
func (e ecsLocalSimulation) Port(ctx context.Context, project string, service string, port int, options api.PortOptions) (string, int, error) {
|
||||
return "", 0, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Images(ctx context.Context, projectName string, options compose.ImagesOptions) ([]compose.ImageSummary, error) {
|
||||
return nil, errdefs.ErrNotImplemented
|
||||
func (e ecsLocalSimulation) Images(ctx context.Context, projectName string, options api.ImagesOptions) ([]api.ImageSummary, error) {
|
||||
return nil, api.ErrNotImplemented
|
||||
}
|
||||
|
|
|
@ -20,18 +20,18 @@ import (
|
|||
"context"
|
||||
|
||||
"github.com/docker/compose-cli/api/cloud"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/ecs"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
var _ cloud.Service = ecsLocalSimulation{}
|
||||
|
||||
func (e ecsLocalSimulation) Login(ctx context.Context, params interface{}) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) Logout(ctx context.Context) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (e ecsLocalSimulation) CreateContextData(ctx context.Context, params interface{}) (contextData interface{}, description string, err error) {
|
||||
|
|
|
@ -19,11 +19,11 @@ package ecs
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/docker/compose-cli/utils"
|
||||
)
|
||||
|
||||
func (b *ecsAPIService) Logs(ctx context.Context, projectName string, consumer compose.LogConsumer, options compose.LogOptions) error {
|
||||
func (b *ecsAPIService) Logs(ctx context.Context, projectName string, consumer api.LogConsumer, options api.LogOptions) error {
|
||||
if len(options.Services) > 0 {
|
||||
consumer = utils.FilteredLogConsumer(consumer, options.Services)
|
||||
}
|
||||
|
|
|
@ -19,10 +19,10 @@ package ecs
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
func (b *ecsAPIService) Ps(ctx context.Context, projectName string, options compose.PsOptions) ([]compose.ContainerSummary, error) {
|
||||
func (b *ecsAPIService) Ps(ctx context.Context, projectName string, options api.PsOptions) ([]api.ContainerSummary, error) {
|
||||
cluster, err := b.aws.GetStackClusterID(ctx, projectName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -36,7 +36,7 @@ func (b *ecsAPIService) Ps(ctx context.Context, projectName string, options comp
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
summary := []compose.ContainerSummary{}
|
||||
summary := []api.ContainerSummary{}
|
||||
for _, arn := range servicesARN {
|
||||
service, err := b.aws.DescribeService(ctx, cluster, arn)
|
||||
if err != nil {
|
||||
|
|
11
ecs/run.go
11
ecs/run.go
|
@ -21,14 +21,13 @@ import (
|
|||
|
||||
"github.com/compose-spec/compose-go/types"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
func (b *ecsAPIService) RunOneOffContainer(ctx context.Context, project *types.Project, opts compose.RunOptions) (int, error) {
|
||||
return 0, errdefs.ErrNotImplemented
|
||||
func (b *ecsAPIService) RunOneOffContainer(ctx context.Context, project *types.Project, opts api.RunOptions) (int, error) {
|
||||
return 0, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (b *ecsAPIService) Remove(ctx context.Context, project *types.Project, options compose.RemoveOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (b *ecsAPIService) Remove(ctx context.Context, project *types.Project, options api.RemoveOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
|
59
ecs/sdk.go
59
ecs/sdk.go
|
@ -24,10 +24,9 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/api/secrets"
|
||||
"github.com/docker/compose-cli/internal"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/arn"
|
||||
|
@ -126,7 +125,7 @@ func (s sdk) ResolveCluster(ctx context.Context, nameOrArn string) (awsResource,
|
|||
return nil, err
|
||||
}
|
||||
if len(clusters.Clusters) == 0 {
|
||||
return nil, errors.Wrapf(errdefs.ErrNotFound, "cluster %q does not exist", nameOrArn)
|
||||
return nil, errors.Wrapf(api.ErrNotFound, "cluster %q does not exist", nameOrArn)
|
||||
}
|
||||
it := clusters.Clusters[0]
|
||||
return existingAWSResource{
|
||||
|
@ -341,7 +340,7 @@ func (s sdk) CreateStack(ctx context.Context, name string, region string, templa
|
|||
},
|
||||
Tags: []*cloudformation.Tag{
|
||||
{
|
||||
Key: aws.String(compose.ProjectLabel),
|
||||
Key: aws.String(api.ProjectLabel),
|
||||
Value: aws.String(name),
|
||||
},
|
||||
},
|
||||
|
@ -444,10 +443,10 @@ func (s sdk) GetStackID(ctx context.Context, name string) (string, error) {
|
|||
return *stacks.Stacks[0].StackId, nil
|
||||
}
|
||||
|
||||
func (s sdk) ListStacks(ctx context.Context) ([]compose.Stack, error) {
|
||||
func (s sdk) ListStacks(ctx context.Context) ([]api.Stack, error) {
|
||||
params := cloudformation.DescribeStacksInput{}
|
||||
var token *string
|
||||
var stacks []compose.Stack
|
||||
var stacks []api.Stack
|
||||
for {
|
||||
response, err := s.CF.DescribeStacksWithContext(ctx, ¶ms)
|
||||
if err != nil {
|
||||
|
@ -455,18 +454,18 @@ func (s sdk) ListStacks(ctx context.Context) ([]compose.Stack, error) {
|
|||
}
|
||||
for _, stack := range response.Stacks {
|
||||
for _, t := range stack.Tags {
|
||||
if *t.Key == compose.ProjectLabel {
|
||||
status := compose.RUNNING
|
||||
if *t.Key == api.ProjectLabel {
|
||||
status := api.RUNNING
|
||||
switch aws.StringValue(stack.StackStatus) {
|
||||
case "CREATE_IN_PROGRESS":
|
||||
status = compose.STARTING
|
||||
status = api.STARTING
|
||||
case "DELETE_IN_PROGRESS":
|
||||
status = compose.REMOVING
|
||||
status = api.REMOVING
|
||||
case "UPDATE_IN_PROGRESS":
|
||||
status = compose.UPDATING
|
||||
status = api.UPDATING
|
||||
default:
|
||||
}
|
||||
stacks = append(stacks, compose.Stack{
|
||||
stacks = append(stacks, api.Stack{
|
||||
ID: aws.StringValue(stack.StackId),
|
||||
Name: aws.StringValue(stack.StackName),
|
||||
Status: status,
|
||||
|
@ -516,7 +515,7 @@ func (s sdk) GetStackClusterID(ctx context.Context, stack string) (string, error
|
|||
return "", err
|
||||
}
|
||||
if m.Cluster == "" {
|
||||
return "", errors.Wrap(errdefs.ErrNotFound, "CloudFormation is missing cluster metadata")
|
||||
return "", errors.Wrap(api.ErrNotFound, "CloudFormation is missing cluster metadata")
|
||||
}
|
||||
|
||||
return m.Cluster, nil
|
||||
|
@ -844,28 +843,28 @@ func (s sdk) GetLogs(ctx context.Context, name string, consumer func(container s
|
|||
}
|
||||
}
|
||||
|
||||
func (s sdk) DescribeService(ctx context.Context, cluster string, arn string) (compose.ServiceStatus, error) {
|
||||
func (s sdk) DescribeService(ctx context.Context, cluster string, arn string) (api.ServiceStatus, error) {
|
||||
services, err := s.ECS.DescribeServicesWithContext(ctx, &ecs.DescribeServicesInput{
|
||||
Cluster: aws.String(cluster),
|
||||
Services: []*string{aws.String(arn)},
|
||||
Include: aws.StringSlice([]string{"TAGS"}),
|
||||
})
|
||||
if err != nil {
|
||||
return compose.ServiceStatus{}, err
|
||||
return api.ServiceStatus{}, err
|
||||
}
|
||||
|
||||
for _, f := range services.Failures {
|
||||
return compose.ServiceStatus{}, errors.Wrapf(errdefs.ErrNotFound, "can't get service status %s: %s", aws.StringValue(f.Detail), aws.StringValue(f.Reason))
|
||||
return api.ServiceStatus{}, errors.Wrapf(api.ErrNotFound, "can't get service status %s: %s", aws.StringValue(f.Detail), aws.StringValue(f.Reason))
|
||||
}
|
||||
service := services.Services[0]
|
||||
var name string
|
||||
for _, t := range service.Tags {
|
||||
if *t.Key == compose.ServiceLabel {
|
||||
if *t.Key == api.ServiceLabel {
|
||||
name = aws.StringValue(t.Value)
|
||||
}
|
||||
}
|
||||
if name == "" {
|
||||
return compose.ServiceStatus{}, fmt.Errorf("service %s doesn't have a %s tag", *service.ServiceArn, compose.ServiceLabel)
|
||||
return api.ServiceStatus{}, fmt.Errorf("service %s doesn't have a %s tag", *service.ServiceArn, api.ServiceLabel)
|
||||
}
|
||||
targetGroupArns := []string{}
|
||||
for _, lb := range service.LoadBalancers {
|
||||
|
@ -875,9 +874,9 @@ func (s sdk) DescribeService(ctx context.Context, cluster string, arn string) (c
|
|||
// one to get the target groups and another for load balancers
|
||||
loadBalancers, err := s.getURLWithPortMapping(ctx, targetGroupArns)
|
||||
if err != nil {
|
||||
return compose.ServiceStatus{}, err
|
||||
return api.ServiceStatus{}, err
|
||||
}
|
||||
return compose.ServiceStatus{
|
||||
return api.ServiceStatus{
|
||||
ID: aws.StringValue(service.ServiceName),
|
||||
Name: name,
|
||||
Replicas: int(aws.Int64Value(service.RunningCount)),
|
||||
|
@ -886,8 +885,8 @@ func (s sdk) DescribeService(ctx context.Context, cluster string, arn string) (c
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (s sdk) DescribeServiceTasks(ctx context.Context, cluster string, project string, service string) ([]compose.ContainerSummary, error) {
|
||||
var summary []compose.ContainerSummary
|
||||
func (s sdk) DescribeServiceTasks(ctx context.Context, cluster string, project string, service string) ([]api.ContainerSummary, error) {
|
||||
var summary []api.ContainerSummary
|
||||
familly := fmt.Sprintf("%s-%s", project, service)
|
||||
var token *string
|
||||
for {
|
||||
|
@ -919,9 +918,9 @@ func (s sdk) DescribeServiceTasks(ctx context.Context, cluster string, project s
|
|||
var service string
|
||||
for _, tag := range t.Tags {
|
||||
switch aws.StringValue(tag.Key) {
|
||||
case compose.ProjectLabel:
|
||||
case api.ProjectLabel:
|
||||
project = aws.StringValue(tag.Value)
|
||||
case compose.ServiceLabel:
|
||||
case api.ServiceLabel:
|
||||
service = aws.StringValue(tag.Value)
|
||||
}
|
||||
}
|
||||
|
@ -931,7 +930,7 @@ func (s sdk) DescribeServiceTasks(ctx context.Context, cluster string, project s
|
|||
return nil, err
|
||||
}
|
||||
|
||||
summary = append(summary, compose.ContainerSummary{
|
||||
summary = append(summary, api.ContainerSummary{
|
||||
ID: id.String(),
|
||||
Name: id.Resource,
|
||||
Project: project,
|
||||
|
@ -949,7 +948,7 @@ func (s sdk) DescribeServiceTasks(ctx context.Context, cluster string, project s
|
|||
return summary, nil
|
||||
}
|
||||
|
||||
func (s sdk) getURLWithPortMapping(ctx context.Context, targetGroupArns []string) ([]compose.PortPublisher, error) {
|
||||
func (s sdk) getURLWithPortMapping(ctx context.Context, targetGroupArns []string) ([]api.PortPublisher, error) {
|
||||
if len(targetGroupArns) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -983,14 +982,14 @@ func (s sdk) getURLWithPortMapping(ctx context.Context, targetGroupArns []string
|
|||
}
|
||||
return nil
|
||||
}
|
||||
loadBalancers := []compose.PortPublisher{}
|
||||
loadBalancers := []api.PortPublisher{}
|
||||
for _, tg := range groups.TargetGroups {
|
||||
for _, lbarn := range tg.LoadBalancerArns {
|
||||
lb := filterLB(lbarn, lbs.LoadBalancers)
|
||||
if lb == nil {
|
||||
continue
|
||||
}
|
||||
loadBalancers = append(loadBalancers, compose.PortPublisher{
|
||||
loadBalancers = append(loadBalancers, api.PortPublisher{
|
||||
URL: fmt.Sprintf("%s:%d", aws.StringValue(lb.DNSName), aws.Int64Value(tg.Port)),
|
||||
TargetPort: int(aws.Int64Value(tg.Port)),
|
||||
PublishedPort: int(aws.Int64Value(tg.Port)),
|
||||
|
@ -1063,7 +1062,7 @@ func (s sdk) ResolveLoadBalancer(ctx context.Context, nameOrArn string) (awsReso
|
|||
return nil, "", "", nil, err
|
||||
}
|
||||
if len(lbs.LoadBalancers) == 0 {
|
||||
return nil, "", "", nil, errors.Wrapf(errdefs.ErrNotFound, "load balancer %q does not exist", nameOrArn)
|
||||
return nil, "", "", nil, errors.Wrapf(api.ErrNotFound, "load balancer %q does not exist", nameOrArn)
|
||||
}
|
||||
it := lbs.LoadBalancers[0]
|
||||
var subNets []awsResource
|
||||
|
@ -1151,7 +1150,7 @@ func (s sdk) ResolveFileSystem(ctx context.Context, id string) (awsResource, err
|
|||
return nil, err
|
||||
}
|
||||
if len(desc.FileSystems) == 0 {
|
||||
return nil, errors.Wrapf(errdefs.ErrNotFound, "EFS file system %q doesn't exist", id)
|
||||
return nil, errors.Wrapf(api.ErrNotFound, "EFS file system %q doesn't exist", id)
|
||||
}
|
||||
it := desc.FileSystems[0]
|
||||
return existingAWSResource{
|
||||
|
|
12
ecs/tags.go
12
ecs/tags.go
|
@ -20,13 +20,13 @@ import (
|
|||
"github.com/awslabs/goformation/v4/cloudformation/tags"
|
||||
"github.com/compose-spec/compose-go/types"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
func projectTags(project *types.Project) []tags.Tag {
|
||||
return []tags.Tag{
|
||||
{
|
||||
Key: compose.ProjectLabel,
|
||||
Key: api.ProjectLabel,
|
||||
Value: project.Name,
|
||||
},
|
||||
}
|
||||
|
@ -35,11 +35,11 @@ func projectTags(project *types.Project) []tags.Tag {
|
|||
func serviceTags(project *types.Project, service types.ServiceConfig) []tags.Tag {
|
||||
return []tags.Tag{
|
||||
{
|
||||
Key: compose.ProjectLabel,
|
||||
Key: api.ProjectLabel,
|
||||
Value: project.Name,
|
||||
},
|
||||
{
|
||||
Key: compose.ServiceLabel,
|
||||
Key: api.ServiceLabel,
|
||||
Value: service.Name,
|
||||
},
|
||||
}
|
||||
|
@ -48,11 +48,11 @@ func serviceTags(project *types.Project, service types.ServiceConfig) []tags.Tag
|
|||
func networkTags(project *types.Project, net types.NetworkConfig) []tags.Tag {
|
||||
return []tags.Tag{
|
||||
{
|
||||
Key: compose.ProjectLabel,
|
||||
Key: api.ProjectLabel,
|
||||
Value: project.Name,
|
||||
},
|
||||
{
|
||||
Key: compose.NetworkLabel,
|
||||
Key: api.NetworkLabel,
|
||||
Value: net.Name,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -19,10 +19,9 @@ package ecs
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
func (b *ecsAPIService) Top(ctx context.Context, projectName string, services []string) ([]compose.ContainerProcSummary, error) {
|
||||
return nil, errdefs.ErrNotImplemented
|
||||
func (b *ecsAPIService) Top(ctx context.Context, projectName string, services []string) ([]api.ContainerProcSummary, error) {
|
||||
return nil, api.ErrNotImplemented
|
||||
}
|
||||
|
|
61
ecs/up.go
61
ecs/up.go
|
@ -26,73 +26,72 @@ import (
|
|||
"github.com/compose-spec/compose-go/types"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/api/progress"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/docker/compose-cli/pkg/progress"
|
||||
)
|
||||
|
||||
func (b *ecsAPIService) Build(ctx context.Context, project *types.Project, options compose.BuildOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (b *ecsAPIService) Build(ctx context.Context, project *types.Project, options api.BuildOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (b *ecsAPIService) Push(ctx context.Context, project *types.Project, options compose.PushOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (b *ecsAPIService) Push(ctx context.Context, project *types.Project, options api.PushOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (b *ecsAPIService) Pull(ctx context.Context, project *types.Project, options compose.PullOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (b *ecsAPIService) Pull(ctx context.Context, project *types.Project, options api.PullOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (b *ecsAPIService) Create(ctx context.Context, project *types.Project, opts compose.CreateOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (b *ecsAPIService) Create(ctx context.Context, project *types.Project, opts api.CreateOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (b *ecsAPIService) Start(ctx context.Context, project *types.Project, options compose.StartOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (b *ecsAPIService) Start(ctx context.Context, project *types.Project, options api.StartOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (b *ecsAPIService) Restart(ctx context.Context, project *types.Project, options compose.RestartOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (b *ecsAPIService) Restart(ctx context.Context, project *types.Project, options api.RestartOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (b *ecsAPIService) Stop(ctx context.Context, project *types.Project, options compose.StopOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (b *ecsAPIService) Stop(ctx context.Context, project *types.Project, options api.StopOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (b *ecsAPIService) Pause(ctx context.Context, project string, options compose.PauseOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (b *ecsAPIService) Pause(ctx context.Context, project string, options api.PauseOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (b *ecsAPIService) UnPause(ctx context.Context, project string, options compose.PauseOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (b *ecsAPIService) UnPause(ctx context.Context, project string, options api.PauseOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (b *ecsAPIService) Events(ctx context.Context, project string, options compose.EventsOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (b *ecsAPIService) Events(ctx context.Context, project string, options api.EventsOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (b *ecsAPIService) Port(ctx context.Context, project string, service string, port int, options compose.PortOptions) (string, int, error) {
|
||||
return "", 0, errdefs.ErrNotImplemented
|
||||
func (b *ecsAPIService) Port(ctx context.Context, project string, service string, port int, options api.PortOptions) (string, int, error) {
|
||||
return "", 0, api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (b *ecsAPIService) Copy(ctx context.Context, project *types.Project, options compose.CopyOptions) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
func (b *ecsAPIService) Copy(ctx context.Context, project *types.Project, options api.CopyOptions) error {
|
||||
return api.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (b *ecsAPIService) Up(ctx context.Context, project *types.Project, options compose.UpOptions) error {
|
||||
func (b *ecsAPIService) Up(ctx context.Context, project *types.Project, options api.UpOptions) error {
|
||||
return progress.Run(ctx, func(ctx context.Context) error {
|
||||
return b.up(ctx, project, options)
|
||||
})
|
||||
}
|
||||
|
||||
func (b *ecsAPIService) up(ctx context.Context, project *types.Project, options compose.UpOptions) error {
|
||||
func (b *ecsAPIService) up(ctx context.Context, project *types.Project, options api.UpOptions) error {
|
||||
logrus.Debugf("deploying on AWS with region=%q", b.Region)
|
||||
err := b.aws.CheckRequirements(ctx, b.Region)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
template, err := b.Convert(ctx, project, compose.ConvertOptions{
|
||||
template, err := b.Convert(ctx, project, api.ConvertOptions{
|
||||
Format: "yaml",
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -138,7 +137,7 @@ func (b *ecsAPIService) up(ctx context.Context, project *types.Project, options
|
|||
go func() {
|
||||
<-signalChan
|
||||
fmt.Println("user interrupted deployment. Deleting stack...")
|
||||
b.Down(ctx, project.Name, compose.DownOptions{}) // nolint:errcheck
|
||||
b.Down(ctx, project.Name, api.DownOptions{}) // nolint:errcheck
|
||||
}()
|
||||
|
||||
err = b.WaitStackCompletion(ctx, project.Name, operation, previousEvents...)
|
||||
|
|
|
@ -20,9 +20,8 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/errdefs"
|
||||
"github.com/docker/compose-cli/api/volumes"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
|
||||
"github.com/awslabs/goformation/v4/cloudformation"
|
||||
"github.com/awslabs/goformation/v4/cloudformation/efs"
|
||||
|
@ -63,11 +62,11 @@ func (b *ecsAPIService) createAccessPoints(project *types.Project, r awsResource
|
|||
ap := efs.AccessPoint{
|
||||
AccessPointTags: []efs.AccessPoint_AccessPointTag{
|
||||
{
|
||||
Key: compose.ProjectLabel,
|
||||
Key: api.ProjectLabel,
|
||||
Value: project.Name,
|
||||
},
|
||||
{
|
||||
Key: compose.VolumeLabel,
|
||||
Key: api.VolumeLabel,
|
||||
Value: name,
|
||||
},
|
||||
{
|
||||
|
@ -147,7 +146,7 @@ func (e ecsVolumeService) Delete(ctx context.Context, volumeID string, options i
|
|||
func (e ecsVolumeService) Inspect(ctx context.Context, volumeID string) (volumes.Volume, error) {
|
||||
ok, err := e.backend.aws.ResolveFileSystem(ctx, volumeID)
|
||||
if ok == nil {
|
||||
err = errors.Wrapf(errdefs.ErrNotFound, "filesystem %q does not exists", volumeID)
|
||||
err = errors.Wrapf(api.ErrNotFound, "filesystem %q does not exists", volumeID)
|
||||
}
|
||||
return volumes.Volume{
|
||||
ID: volumeID,
|
||||
|
|
|
@ -23,10 +23,10 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/docker/compose-cli/pkg/progress"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/iancoleman/strcase"
|
||||
|
||||
"github.com/docker/compose-cli/api/progress"
|
||||
)
|
||||
|
||||
func (b *ecsAPIService) WaitStackCompletion(ctx context.Context, name string, operation int, ignored ...string) error { //nolint:gocyclo
|
||||
|
|
|
@ -21,18 +21,18 @@ package kube
|
|||
import (
|
||||
"github.com/docker/compose-cli/api/backend"
|
||||
"github.com/docker/compose-cli/api/cloud"
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/containers"
|
||||
"github.com/docker/compose-cli/api/context/store"
|
||||
"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/pkg/api"
|
||||
)
|
||||
|
||||
const backendType = store.KubeContextType
|
||||
|
||||
type kubeAPIService struct {
|
||||
composeService compose.Service
|
||||
composeService api.Service
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -53,7 +53,7 @@ func (s *kubeAPIService) ContainerService() containers.Service {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *kubeAPIService) ComposeService() compose.Service {
|
||||
func (s *kubeAPIService) ComposeService() api.Service {
|
||||
return s.composeService
|
||||
}
|
||||
|
||||
|
|
|
@ -27,8 +27,9 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/utils"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
"github.com/docker/compose-cli/pkg/utils"
|
||||
|
||||
"golang.org/x/sync/errgroup"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
@ -77,7 +78,7 @@ func NewKubeClient(config genericclioptions.RESTClientGetter) (*KubeClient, erro
|
|||
// GetPod retrieves a service pod
|
||||
func (kc KubeClient) GetPod(ctx context.Context, projectName, serviceName string) (*corev1.Pod, error) {
|
||||
pods, err := kc.client.CoreV1().Pods(kc.namespace).List(ctx, metav1.ListOptions{
|
||||
LabelSelector: fmt.Sprintf("%s=%s", compose.ProjectLabel, projectName),
|
||||
LabelSelector: fmt.Sprintf("%s=%s", api.ProjectLabel, projectName),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -87,7 +88,7 @@ func (kc KubeClient) GetPod(ctx context.Context, projectName, serviceName string
|
|||
}
|
||||
var pod corev1.Pod
|
||||
for _, p := range pods.Items {
|
||||
service := p.Labels[compose.ServiceLabel]
|
||||
service := p.Labels[api.ServiceLabel]
|
||||
if service == serviceName {
|
||||
pod = p
|
||||
break
|
||||
|
@ -97,7 +98,7 @@ func (kc KubeClient) GetPod(ctx context.Context, projectName, serviceName string
|
|||
}
|
||||
|
||||
// Exec executes a command in a container
|
||||
func (kc KubeClient) Exec(ctx context.Context, projectName string, opts compose.RunOptions) error {
|
||||
func (kc KubeClient) Exec(ctx context.Context, projectName string, opts api.RunOptions) error {
|
||||
pod, err := kc.GetPod(ctx, projectName, opts.Service)
|
||||
if err != nil || pod == nil {
|
||||
return err
|
||||
|
@ -148,24 +149,24 @@ func (kc KubeClient) Exec(ctx context.Context, projectName string, opts compose.
|
|||
}
|
||||
|
||||
// GetContainers get containers for a given compose project
|
||||
func (kc KubeClient) GetContainers(ctx context.Context, projectName string, all bool) ([]compose.ContainerSummary, error) {
|
||||
func (kc KubeClient) GetContainers(ctx context.Context, projectName string, all bool) ([]api.ContainerSummary, error) {
|
||||
fieldSelector := ""
|
||||
if !all {
|
||||
fieldSelector = "status.phase=Running"
|
||||
}
|
||||
|
||||
pods, err := kc.client.CoreV1().Pods(kc.namespace).List(ctx, metav1.ListOptions{
|
||||
LabelSelector: fmt.Sprintf("%s=%s", compose.ProjectLabel, projectName),
|
||||
LabelSelector: fmt.Sprintf("%s=%s", api.ProjectLabel, projectName),
|
||||
FieldSelector: fieldSelector,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
services := map[string][]compose.PortPublisher{}
|
||||
result := []compose.ContainerSummary{}
|
||||
services := map[string][]api.PortPublisher{}
|
||||
result := []api.ContainerSummary{}
|
||||
for _, pod := range pods.Items {
|
||||
summary := podToContainerSummary(pod)
|
||||
serviceName := pod.GetObjectMeta().GetLabels()[compose.ServiceLabel]
|
||||
serviceName := pod.GetObjectMeta().GetLabels()[api.ServiceLabel]
|
||||
ports, ok := services[serviceName]
|
||||
if !ok {
|
||||
s, err := kc.client.CoreV1().Services(kc.namespace).Get(ctx, serviceName, metav1.GetOptions{})
|
||||
|
@ -176,11 +177,11 @@ func (kc KubeClient) GetContainers(ctx context.Context, projectName string, all
|
|||
result = append(result, summary)
|
||||
continue
|
||||
}
|
||||
ports = []compose.PortPublisher{}
|
||||
ports = []api.PortPublisher{}
|
||||
if s != nil {
|
||||
if s.Spec.Type == corev1.ServiceTypeLoadBalancer {
|
||||
if len(s.Status.LoadBalancer.Ingress) > 0 {
|
||||
port := compose.PortPublisher{URL: s.Status.LoadBalancer.Ingress[0].IP}
|
||||
port := api.PortPublisher{URL: s.Status.LoadBalancer.Ingress[0].IP}
|
||||
if len(s.Spec.Ports) > 0 {
|
||||
port.URL = fmt.Sprintf("%s:%d", port.URL, s.Spec.Ports[0].Port)
|
||||
port.TargetPort = s.Spec.Ports[0].TargetPort.IntValue()
|
||||
|
@ -200,9 +201,9 @@ func (kc KubeClient) GetContainers(ctx context.Context, projectName string, all
|
|||
}
|
||||
|
||||
// GetLogs retrieves pod logs
|
||||
func (kc *KubeClient) GetLogs(ctx context.Context, projectName string, consumer compose.LogConsumer, follow bool) error {
|
||||
func (kc *KubeClient) GetLogs(ctx context.Context, projectName string, consumer api.LogConsumer, follow bool) error {
|
||||
pods, err := kc.client.CoreV1().Pods(kc.namespace).List(ctx, metav1.ListOptions{
|
||||
LabelSelector: fmt.Sprintf("%s=%s", compose.ProjectLabel, projectName),
|
||||
LabelSelector: fmt.Sprintf("%s=%s", api.ProjectLabel, projectName),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -210,7 +211,7 @@ func (kc *KubeClient) GetLogs(ctx context.Context, projectName string, consumer
|
|||
eg, ctx := errgroup.WithContext(ctx)
|
||||
for _, pod := range pods.Items {
|
||||
request := kc.client.CoreV1().Pods(kc.namespace).GetLogs(pod.Name, &corev1.PodLogOptions{Follow: follow})
|
||||
service := pod.Labels[compose.ServiceLabel]
|
||||
service := pod.Labels[api.ServiceLabel]
|
||||
w := utils.GetWriter(func(line string) {
|
||||
consumer.Log(pod.Name, service, line)
|
||||
})
|
||||
|
@ -243,7 +244,7 @@ func (kc KubeClient) WaitForPodState(ctx context.Context, opts WaitForStatusOpti
|
|||
time.Sleep(500 * time.Millisecond)
|
||||
|
||||
pods, err := kc.client.CoreV1().Pods(kc.namespace).List(ctx, metav1.ListOptions{
|
||||
LabelSelector: fmt.Sprintf("%s=%s", compose.ProjectLabel, opts.ProjectName),
|
||||
LabelSelector: fmt.Sprintf("%s=%s", api.ProjectLabel, opts.ProjectName),
|
||||
})
|
||||
if err != nil {
|
||||
errch <- err
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
|
||||
"gotest.tools/v3/assert"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/pkg/api"
|
||||
)
|
||||
|
||||
func TestPodToContainerSummary(t *testing.T) {
|
||||
|
@ -34,8 +34,8 @@ func TestPodToContainerSummary(t *testing.T) {
|
|||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "c1-123",
|
||||
Labels: map[string]string{
|
||||
compose.ProjectLabel: "myproject",
|
||||
compose.ServiceLabel: "service1",
|
||||
api.ProjectLabel: "myproject",
|
||||
api.ServiceLabel: "service1",
|
||||
},
|
||||
},
|
||||
Status: v1.PodStatus{
|
||||
|
@ -45,7 +45,7 @@ func TestPodToContainerSummary(t *testing.T) {
|
|||
|
||||
container := podToContainerSummary(pod)
|
||||
|
||||
expected := compose.ContainerSummary{
|
||||
expected := api.ContainerSummary{
|
||||
ID: "c1-123",
|
||||
Name: "c1-123",
|
||||
Project: "myproject",
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue