|
|
@@ -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
|
|
|
}
|