@@ -27,10 +27,9 @@ import (
27
27
28
28
"github.com/docker/compose-cli/aci/convert"
29
29
"github.com/docker/compose-cli/aci/login"
30
- "github.com/docker/compose-cli/api/compose"
31
30
"github.com/docker/compose-cli/api/context/store"
32
- "github.com/docker/compose-cli/api/errdefs "
33
- "github.com/docker/compose-cli/api /progress"
31
+ "github.com/docker/compose-cli/pkg/api "
32
+ "github.com/docker/compose-cli/pkg /progress"
34
33
"github.com/docker/compose-cli/utils/formatter"
35
34
)
36
35
@@ -46,47 +45,47 @@ func newComposeService(ctx store.AciContext) aciComposeService {
46
45
}
47
46
}
48
47
49
- func (cs * aciComposeService ) Build (ctx context.Context , project * types.Project , options compose .BuildOptions ) error {
50
- return errdefs .ErrNotImplemented
48
+ func (cs * aciComposeService ) Build (ctx context.Context , project * types.Project , options api .BuildOptions ) error {
49
+ return api .ErrNotImplemented
51
50
}
52
51
53
- func (cs * aciComposeService ) Push (ctx context.Context , project * types.Project , options compose .PushOptions ) error {
54
- return errdefs .ErrNotImplemented
52
+ func (cs * aciComposeService ) Push (ctx context.Context , project * types.Project , options api .PushOptions ) error {
53
+ return api .ErrNotImplemented
55
54
}
56
55
57
- func (cs * aciComposeService ) Pull (ctx context.Context , project * types.Project , options compose .PullOptions ) error {
58
- return errdefs .ErrNotImplemented
56
+ func (cs * aciComposeService ) Pull (ctx context.Context , project * types.Project , options api .PullOptions ) error {
57
+ return api .ErrNotImplemented
59
58
}
60
59
61
- func (cs * aciComposeService ) Create (ctx context.Context , project * types.Project , opts compose .CreateOptions ) error {
62
- return errdefs .ErrNotImplemented
60
+ func (cs * aciComposeService ) Create (ctx context.Context , project * types.Project , opts api .CreateOptions ) error {
61
+ return api .ErrNotImplemented
63
62
}
64
63
65
- func (cs * aciComposeService ) Start (ctx context.Context , project * types.Project , options compose .StartOptions ) error {
66
- return errdefs .ErrNotImplemented
64
+ func (cs * aciComposeService ) Start (ctx context.Context , project * types.Project , options api .StartOptions ) error {
65
+ return api .ErrNotImplemented
67
66
}
68
67
69
- func (cs * aciComposeService ) Restart (ctx context.Context , project * types.Project , options compose .RestartOptions ) error {
70
- return errdefs .ErrNotImplemented
68
+ func (cs * aciComposeService ) Restart (ctx context.Context , project * types.Project , options api .RestartOptions ) error {
69
+ return api .ErrNotImplemented
71
70
}
72
71
73
- func (cs * aciComposeService ) Stop (ctx context.Context , project * types.Project , options compose .StopOptions ) error {
74
- return errdefs .ErrNotImplemented
72
+ func (cs * aciComposeService ) Stop (ctx context.Context , project * types.Project , options api .StopOptions ) error {
73
+ return api .ErrNotImplemented
75
74
}
76
75
77
- func (cs * aciComposeService ) Pause (ctx context.Context , project string , options compose .PauseOptions ) error {
78
- return errdefs .ErrNotImplemented
76
+ func (cs * aciComposeService ) Pause (ctx context.Context , project string , options api .PauseOptions ) error {
77
+ return api .ErrNotImplemented
79
78
}
80
79
81
- func (cs * aciComposeService ) UnPause (ctx context.Context , project string , options compose .PauseOptions ) error {
82
- return errdefs .ErrNotImplemented
80
+ func (cs * aciComposeService ) UnPause (ctx context.Context , project string , options api .PauseOptions ) error {
81
+ return api .ErrNotImplemented
83
82
}
84
83
85
- func (cs * aciComposeService ) Copy (ctx context.Context , project * types.Project , options compose .CopyOptions ) error {
86
- return errdefs .ErrNotImplemented
84
+ func (cs * aciComposeService ) Copy (ctx context.Context , project * types.Project , options api .CopyOptions ) error {
85
+ return api .ErrNotImplemented
87
86
}
88
87
89
- func (cs * aciComposeService ) Up (ctx context.Context , project * types.Project , options compose .UpOptions ) error {
88
+ func (cs * aciComposeService ) Up (ctx context.Context , project * types.Project , options api .UpOptions ) error {
90
89
return progress .Run (ctx , func (ctx context.Context ) error {
91
90
return cs .up (ctx , project )
92
91
})
@@ -130,12 +129,12 @@ func (cs aciComposeService) warnKeepVolumeOnDown(ctx context.Context, projectNam
130
129
return nil
131
130
}
132
131
133
- func (cs * aciComposeService ) Down (ctx context.Context , projectName string , options compose .DownOptions ) error {
132
+ func (cs * aciComposeService ) Down (ctx context.Context , projectName string , options api .DownOptions ) error {
134
133
if options .Volumes {
135
- return errors .Wrap (errdefs .ErrNotImplemented , "--volumes option is not supported on ACI" )
134
+ return errors .Wrap (api .ErrNotImplemented , "--volumes option is not supported on ACI" )
136
135
}
137
136
if options .Images != "" {
138
- return errors .Wrap (errdefs .ErrNotImplemented , "--rmi option is not supported on ACI" )
137
+ return errors .Wrap (api .ErrNotImplemented , "--rmi option is not supported on ACI" )
139
138
}
140
139
return progress .Run (ctx , func (ctx context.Context ) error {
141
140
logrus .Debugf ("Down on project with name %q" , projectName )
@@ -149,14 +148,14 @@ func (cs *aciComposeService) Down(ctx context.Context, projectName string, optio
149
148
return err
150
149
}
151
150
if cg .IsHTTPStatus (http .StatusNoContent ) {
152
- return errdefs .ErrNotFound
151
+ return api .ErrNotFound
153
152
}
154
153
155
154
return err
156
155
})
157
156
}
158
157
159
- func (cs * aciComposeService ) Ps (ctx context.Context , projectName string , options compose .PsOptions ) ([]compose .ContainerSummary , error ) {
158
+ func (cs * aciComposeService ) Ps (ctx context.Context , projectName string , options api .PsOptions ) ([]api .ContainerSummary , error ) {
160
159
groupsClient , err := login .NewContainerGroupsClient (cs .ctx .SubscriptionID )
161
160
if err != nil {
162
161
return nil , err
@@ -171,23 +170,23 @@ func (cs *aciComposeService) Ps(ctx context.Context, projectName string, options
171
170
return nil , fmt .Errorf ("no containers found in ACI container group %s" , projectName )
172
171
}
173
172
174
- res := []compose .ContainerSummary {}
173
+ res := []api .ContainerSummary {}
175
174
for _ , container := range * group .Containers {
176
175
if isContainerVisible (container , group , false ) {
177
176
continue
178
177
}
179
- var publishers []compose .PortPublisher
178
+ var publishers []api .PortPublisher
180
179
urls := formatter .PortsToStrings (convert .ToPorts (group .IPAddress , * container .Ports ), convert .FQDN (group , cs .ctx .Location ))
181
180
for i , p := range * container .Ports {
182
- publishers = append (publishers , compose .PortPublisher {
181
+ publishers = append (publishers , api .PortPublisher {
183
182
URL : urls [i ],
184
183
TargetPort : int (* p .Port ),
185
184
PublishedPort : int (* p .Port ),
186
185
Protocol : string (p .Protocol ),
187
186
})
188
187
}
189
188
id := getContainerID (group , container )
190
- res = append (res , compose .ContainerSummary {
189
+ res = append (res , api .ContainerSummary {
191
190
ID : id ,
192
191
Name : id ,
193
192
Project : projectName ,
@@ -199,26 +198,26 @@ func (cs *aciComposeService) Ps(ctx context.Context, projectName string, options
199
198
return res , nil
200
199
}
201
200
202
- func (cs * aciComposeService ) List (ctx context.Context , opts compose .ListOptions ) ([]compose .Stack , error ) {
201
+ func (cs * aciComposeService ) List (ctx context.Context , opts api .ListOptions ) ([]api .Stack , error ) {
203
202
containerGroups , err := getACIContainerGroups (ctx , cs .ctx .SubscriptionID , cs .ctx .ResourceGroup )
204
203
if err != nil {
205
204
return nil , err
206
205
}
207
206
208
- var stacks []compose .Stack
207
+ var stacks []api .Stack
209
208
for _ , group := range containerGroups {
210
209
if _ , found := group .Tags [composeContainerTag ]; ! found {
211
210
continue
212
211
}
213
- state := compose .RUNNING
212
+ state := api .RUNNING
214
213
for _ , container := range * group .ContainerGroupProperties .Containers {
215
214
containerState := convert .GetStatus (container , group )
216
- if containerState != compose .RUNNING {
215
+ if containerState != api .RUNNING {
217
216
state = containerState
218
217
break
219
218
}
220
219
}
221
- stacks = append (stacks , compose .Stack {
220
+ stacks = append (stacks , api .Stack {
222
221
ID : * group .ID ,
223
222
Name : * group .Name ,
224
223
Status : state ,
@@ -227,41 +226,41 @@ func (cs *aciComposeService) List(ctx context.Context, opts compose.ListOptions)
227
226
return stacks , nil
228
227
}
229
228
230
- func (cs * aciComposeService ) Logs (ctx context.Context , projectName string , consumer compose .LogConsumer , options compose .LogOptions ) error {
231
- return errdefs .ErrNotImplemented
229
+ func (cs * aciComposeService ) Logs (ctx context.Context , projectName string , consumer api .LogConsumer , options api .LogOptions ) error {
230
+ return api .ErrNotImplemented
232
231
}
233
232
234
- func (cs * aciComposeService ) Convert (ctx context.Context , project * types.Project , options compose .ConvertOptions ) ([]byte , error ) {
235
- return nil , errdefs .ErrNotImplemented
233
+ func (cs * aciComposeService ) Convert (ctx context.Context , project * types.Project , options api .ConvertOptions ) ([]byte , error ) {
234
+ return nil , api .ErrNotImplemented
236
235
}
237
236
238
- func (cs * aciComposeService ) Kill (ctx context.Context , project * types.Project , options compose .KillOptions ) error {
239
- return errdefs .ErrNotImplemented
237
+ func (cs * aciComposeService ) Kill (ctx context.Context , project * types.Project , options api .KillOptions ) error {
238
+ return api .ErrNotImplemented
240
239
}
241
240
242
- func (cs * aciComposeService ) RunOneOffContainer (ctx context.Context , project * types.Project , opts compose .RunOptions ) (int , error ) {
243
- return 0 , errdefs .ErrNotImplemented
241
+ func (cs * aciComposeService ) RunOneOffContainer (ctx context.Context , project * types.Project , opts api .RunOptions ) (int , error ) {
242
+ return 0 , api .ErrNotImplemented
244
243
}
245
244
246
- func (cs * aciComposeService ) Remove (ctx context.Context , project * types.Project , options compose .RemoveOptions ) error {
247
- return errdefs .ErrNotImplemented
245
+ func (cs * aciComposeService ) Remove (ctx context.Context , project * types.Project , options api .RemoveOptions ) error {
246
+ return api .ErrNotImplemented
248
247
}
249
248
250
- func (cs * aciComposeService ) Exec (ctx context.Context , project * types.Project , opts compose .RunOptions ) (int , error ) {
251
- return 0 , errdefs .ErrNotImplemented
249
+ func (cs * aciComposeService ) Exec (ctx context.Context , project * types.Project , opts api .RunOptions ) (int , error ) {
250
+ return 0 , api .ErrNotImplemented
252
251
}
253
- func (cs * aciComposeService ) Top (ctx context.Context , projectName string , services []string ) ([]compose .ContainerProcSummary , error ) {
254
- return nil , errdefs .ErrNotImplemented
252
+ func (cs * aciComposeService ) Top (ctx context.Context , projectName string , services []string ) ([]api .ContainerProcSummary , error ) {
253
+ return nil , api .ErrNotImplemented
255
254
}
256
255
257
- func (cs * aciComposeService ) Events (ctx context.Context , project string , options compose .EventsOptions ) error {
258
- return errdefs .ErrNotImplemented
256
+ func (cs * aciComposeService ) Events (ctx context.Context , project string , options api .EventsOptions ) error {
257
+ return api .ErrNotImplemented
259
258
}
260
259
261
- func (cs * aciComposeService ) Port (ctx context.Context , project string , service string , port int , options compose .PortOptions ) (string , int , error ) {
262
- return "" , 0 , errdefs .ErrNotImplemented
260
+ func (cs * aciComposeService ) Port (ctx context.Context , project string , service string , port int , options api .PortOptions ) (string , int , error ) {
261
+ return "" , 0 , api .ErrNotImplemented
263
262
}
264
263
265
- func (cs * aciComposeService ) Images (ctx context.Context , projectName string , options compose .ImagesOptions ) ([]compose .ImageSummary , error ) {
266
- return nil , errdefs .ErrNotImplemented
264
+ func (cs * aciComposeService ) Images (ctx context.Context , projectName string , options api .ImagesOptions ) ([]api .ImageSummary , error ) {
265
+ return nil , api .ErrNotImplemented
267
266
}
0 commit comments