Browse Source

etcdmain: support grpc-proxy/gateway compiled with -tags cov

Anthony Romano 8 years ago
parent
commit
7c22d35dff
1 changed files with 8 additions and 1 deletions
  1. 8 1
      etcdmain/main.go

+ 8 - 1
etcdmain/main.go

@@ -17,6 +17,7 @@ package etcdmain
 import (
 	"fmt"
 	"os"
+	"strings"
 
 	"github.com/coreos/go-systemd/daemon"
 	systemdutil "github.com/coreos/go-systemd/util"
@@ -26,7 +27,13 @@ func Main() {
 	checkSupportArch()
 
 	if len(os.Args) > 1 {
-		switch os.Args[1] {
+		cmd := os.Args[1]
+		if covArgs := os.Getenv("ETCDCOV_ARGS"); len(covArgs) > 0 {
+			args := strings.Split(os.Getenv("ETCDCOV_ARGS"), "\xe7\xcd")[1:]
+			rootCmd.SetArgs(args)
+			cmd = "grpc-proxy"
+		}
+		switch cmd {
 		case "gateway", "grpc-proxy":
 			if err := rootCmd.Execute(); err != nil {
 				fmt.Fprint(os.Stderr, err)