@@ -256,7 +256,7 @@ func main() {
256256 if err = root .ExecuteContext (ctx ); err != nil {
257257 handleError (ctx , err , ctype , currentContext , cc , root )
258258 }
259- metricsClient .Track (ctype , os .Args [1 :], compose .SuccessStatus )
259+ metricsClient .Track (ctype , os .Args [1 :], metrics .SuccessStatus )
260260}
261261
262262func customizeCliForACI (command * cobra.Command , proxy * api.ServiceProxy ) {
@@ -278,7 +278,7 @@ func customizeCliForACI(command *cobra.Command, proxy *api.ServiceProxy) {
278278func handleError (ctx context.Context , err error , ctype string , currentContext string , cc * store.DockerContext , root * cobra.Command ) {
279279 // if user canceled request, simply exit without any error message
280280 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 )
282282 os .Exit (130 )
283283 }
284284 if ctype == store .AwsContextType {
@@ -300,20 +300,21 @@ $ docker context create %s <name>`, cc.Type(), store.EcsContextType), ctype)
300300
301301func exit (ctx string , err error , ctype string ) {
302302 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 )
304305 os .Exit (exit .StatusCode )
305306 }
306307
307308 var composeErr compose.Error
308- metricsStatus := compose .FailureStatus
309+ metricsStatus := metrics .FailureStatus
309310 exitCode := 1
310311 if errors .As (err , & composeErr ) {
311312 metricsStatus = composeErr .GetMetricsFailureCategory ().MetricsStatus
312313 exitCode = composeErr .GetMetricsFailureCategory ().ExitCode
313314 }
314315 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
317318 }
318319 metricsClient .Track (ctype , os .Args [1 :], metricsStatus )
319320
@@ -350,7 +351,7 @@ func checkIfUnknownCommandExistInDefaultContext(err error, currentContext string
350351
351352 if mobycli .IsDefaultContextCommand (dockerCommand ) {
352353 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 )
354355 os .Exit (1 )
355356 }
356357 }
0 commit comments