mirror of https://github.com/docker/compose.git
Merge pull request #641 from docker/fix_metrics_default_context
In metrics, send context type, not context name (metrics for Moby calls)
This commit is contained in:
commit
91a668a413
|
@ -209,7 +209,7 @@ $ docker context create %s <name>`, cc.Type(), store.EcsContextType), ctype)
|
||||||
}
|
}
|
||||||
mobycli.ExecIfDefaultCtxType(ctx, root)
|
mobycli.ExecIfDefaultCtxType(ctx, root)
|
||||||
|
|
||||||
checkIfUnknownCommandExistInDefaultContext(err, currentContext, root)
|
checkIfUnknownCommandExistInDefaultContext(err, currentContext, root, ctype)
|
||||||
|
|
||||||
exit(root, currentContext, err, ctype)
|
exit(root, currentContext, err, ctype)
|
||||||
}
|
}
|
||||||
|
@ -242,14 +242,14 @@ func fatal(err error) {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkIfUnknownCommandExistInDefaultContext(err error, currentContext string, root *cobra.Command) {
|
func checkIfUnknownCommandExistInDefaultContext(err error, currentContext string, root *cobra.Command, contextType string) {
|
||||||
submatch := unknownCommandRegexp.FindSubmatch([]byte(err.Error()))
|
submatch := unknownCommandRegexp.FindSubmatch([]byte(err.Error()))
|
||||||
if len(submatch) == 2 {
|
if len(submatch) == 2 {
|
||||||
dockerCommand := string(submatch[1])
|
dockerCommand := string(submatch[1])
|
||||||
|
|
||||||
if mobycli.IsDefaultContextCommand(dockerCommand) {
|
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)
|
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(currentContext, os.Args[1:], root.PersistentFlags(), metrics.FailureStatus)
|
metrics.Track(contextType, os.Args[1:], root.PersistentFlags(), metrics.FailureStatus)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ func Exec(root *cobra.Command) {
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
childExit <- true
|
childExit <- true
|
||||||
if err != nil {
|
if err != nil {
|
||||||
metrics.Track(store.DefaultContextName, os.Args[1:], root.PersistentFlags(), metrics.FailureStatus)
|
metrics.Track(store.DefaultContextType, os.Args[1:], root.PersistentFlags(), metrics.FailureStatus)
|
||||||
|
|
||||||
if exiterr, ok := err.(*exec.ExitError); ok {
|
if exiterr, ok := err.(*exec.ExitError); ok {
|
||||||
os.Exit(exiterr.ExitCode())
|
os.Exit(exiterr.ExitCode())
|
||||||
|
@ -94,7 +94,7 @@ func Exec(root *cobra.Command) {
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
metrics.Track(store.DefaultContextName, os.Args[1:], root.PersistentFlags(), metrics.SuccessStatus)
|
metrics.Track(store.DefaultContextType, os.Args[1:], root.PersistentFlags(), metrics.SuccessStatus)
|
||||||
|
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue