@@ -256,7 +256,7 @@ func main() {
256
256
if err = root .ExecuteContext (ctx ); err != nil {
257
257
handleError (ctx , err , ctype , currentContext , cc , root )
258
258
}
259
- metricsClient .Track (ctype , os .Args [1 :], compose .SuccessStatus )
259
+ metricsClient .Track (ctype , os .Args [1 :], metrics .SuccessStatus )
260
260
}
261
261
262
262
func customizeCliForACI (command * cobra.Command , proxy * api.ServiceProxy ) {
@@ -278,7 +278,7 @@ func customizeCliForACI(command *cobra.Command, proxy *api.ServiceProxy) {
278
278
func handleError (ctx context.Context , err error , ctype string , currentContext string , cc * store.DockerContext , root * cobra.Command ) {
279
279
// if user canceled request, simply exit without any error message
280
280
if api .IsErrCanceled (err ) || errors .Is (ctx .Err (), context .Canceled ) {
281
- metricsClient .Track (ctype , os .Args [1 :], compose .CanceledStatus )
281
+ metricsClient .Track (ctype , os .Args [1 :], metrics .CanceledStatus )
282
282
os .Exit (130 )
283
283
}
284
284
if ctype == store .AwsContextType {
@@ -300,20 +300,21 @@ $ docker context create %s <name>`, cc.Type(), store.EcsContextType), ctype)
300
300
301
301
func exit (ctx string , err error , ctype string ) {
302
302
if exit , ok := err .(cli.StatusError ); ok {
303
- metricsClient .Track (ctype , os .Args [1 :], compose .SuccessStatus )
303
+ // TODO(milas): shouldn't this use the exit code to determine status?
304
+ metricsClient .Track (ctype , os .Args [1 :], metrics .SuccessStatus )
304
305
os .Exit (exit .StatusCode )
305
306
}
306
307
307
308
var composeErr compose.Error
308
- metricsStatus := compose .FailureStatus
309
+ metricsStatus := metrics .FailureStatus
309
310
exitCode := 1
310
311
if errors .As (err , & composeErr ) {
311
312
metricsStatus = composeErr .GetMetricsFailureCategory ().MetricsStatus
312
313
exitCode = composeErr .GetMetricsFailureCategory ().ExitCode
313
314
}
314
315
if strings .HasPrefix (err .Error (), "unknown shorthand flag:" ) || strings .HasPrefix (err .Error (), "unknown flag:" ) || strings .HasPrefix (err .Error (), "unknown docker command:" ) {
315
- metricsStatus = compose .CommandSyntaxFailure .MetricsStatus
316
- exitCode = compose .CommandSyntaxFailure .ExitCode
316
+ metricsStatus = metrics .CommandSyntaxFailure .MetricsStatus
317
+ exitCode = metrics .CommandSyntaxFailure .ExitCode
317
318
}
318
319
metricsClient .Track (ctype , os .Args [1 :], metricsStatus )
319
320
@@ -350,7 +351,7 @@ func checkIfUnknownCommandExistInDefaultContext(err error, currentContext string
350
351
351
352
if mobycli .IsDefaultContextCommand (dockerCommand ) {
352
353
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 )
353
- metricsClient .Track (contextType , os .Args [1 :], compose .FailureStatus )
354
+ metricsClient .Track (contextType , os .Args [1 :], metrics .FailureStatus )
354
355
os .Exit (1 )
355
356
}
356
357
}
0 commit comments