Merge pull request #13 from thandayuthapani/master

Changes to cut tag in pipeline
diff --git a/bootstrap/bootstrap.go b/bootstrap/bootstrap.go
index 61ff28a..2c2c516 100644
--- a/bootstrap/bootstrap.go
+++ b/bootstrap/bootstrap.go
@@ -34,6 +34,7 @@
 	"github.com/go-chassis/go-chassis/core/lager"
 	"github.com/go-chassis/go-chassis/core/metadata"
 	"github.com/go-mesh/mesher/pkg/metrics"
+	"github.com/go-mesh/mesher/pkg/runtime"
 )
 
 // Start initialize configs and components
@@ -67,8 +68,8 @@
 
 //DecideMode get config mode
 func DecideMode() error {
-	config.Mode = cmd.Configs.Mode
-	lager.Logger.Info("Running as "+config.Mode, nil)
+	runtime.Mode = cmd.Configs.Mode
+	lager.Logger.Info("Running as "+runtime.Mode, nil)
 	return nil
 }
 
diff --git a/config/config.go b/config/config.go
index 915c361..14f6cd5 100644
--- a/config/config.go
+++ b/config/config.go
@@ -37,8 +37,6 @@
 	ConfFile = "mesher.yaml"
 )
 
-//Mode is of type string which gives mode of mesher deployment
-var Mode string
 var mesherConfig *MesherConfig
 
 //GetConfig returns mesher config
diff --git a/pkg/runtime/runtime.go b/pkg/runtime/runtime.go
new file mode 100644
index 0000000..bf2603c
--- /dev/null
+++ b/pkg/runtime/runtime.go
@@ -0,0 +1,6 @@
+package runtime
+
+var (
+	//Mode is of type string which gives mode of mesher deployment
+	Mode string
+)
diff --git a/protocol/dubbo/proxy/dubbo_proxy_ouput.go b/protocol/dubbo/proxy/dubbo_proxy_ouput.go
index 6ee6e06..a1b026a 100755
--- a/protocol/dubbo/proxy/dubbo_proxy_ouput.go
+++ b/protocol/dubbo/proxy/dubbo_proxy_ouput.go
@@ -24,14 +24,6 @@
 	"net/http"
 	"net/url"
 
-	mesherCommon "github.com/go-mesh/mesher/common"
-	"github.com/go-mesh/mesher/config"
-	"github.com/go-mesh/mesher/protocol/dubbo/client"
-	"github.com/go-mesh/mesher/protocol/dubbo/dubbo"
-	"github.com/go-mesh/mesher/protocol/dubbo/schema"
-	"github.com/go-mesh/mesher/protocol/dubbo/utils"
-	"github.com/go-mesh/mesher/resolver"
-
 	"github.com/go-chassis/go-chassis/client/rest"
 	"github.com/go-chassis/go-chassis/core/common"
 	chassisconfig "github.com/go-chassis/go-chassis/core/config"
@@ -43,7 +35,14 @@
 	"github.com/go-chassis/go-chassis/pkg/runtime"
 	"github.com/go-chassis/go-chassis/pkg/util/tags"
 	"github.com/go-chassis/go-chassis/third_party/forked/afex/hystrix-go/hystrix"
+	mesherCommon "github.com/go-mesh/mesher/common"
+	mesherRuntime "github.com/go-mesh/mesher/pkg/runtime"
 	"github.com/go-mesh/mesher/protocol"
+	"github.com/go-mesh/mesher/protocol/dubbo/client"
+	"github.com/go-mesh/mesher/protocol/dubbo/dubbo"
+	"github.com/go-mesh/mesher/protocol/dubbo/schema"
+	"github.com/go-mesh/mesher/protocol/dubbo/utils"
+	"github.com/go-mesh/mesher/resolver"
 )
 
 var dr = resolver.GetDestinationResolver("http")
@@ -197,7 +196,7 @@
 			ctx.Req.SetAttachment(common.HeaderSourceName, chassisconfig.SelfServiceName)
 			ctx.Req.SetAttachment(ProxyTag, "true")
 
-			if config.Mode == mesherCommon.ModeSidecar {
+			if mesherRuntime.Mode == mesherCommon.ModeSidecar {
 				c, err = handler.GetChain(common.Consumer, mesherCommon.ChainConsumerOutgoing)
 				if err != nil {
 					lager.Logger.Error("Get Consumer chain failed: " + err.Error())
@@ -303,7 +302,7 @@
 		return err
 	}
 
-	if config.Mode == mesherCommon.ModeSidecar {
+	if mesherRuntime.Mode == mesherCommon.ModeSidecar {
 		c, err = handler.GetChain(common.Consumer, mesherCommon.ChainConsumerOutgoing)
 		if err != nil {
 			lager.Logger.Error("Get chain failed: " + err.Error())
diff --git a/protocol/grpc/server.go b/protocol/grpc/server.go
index ab0e2e9..00cc4dc 100755
--- a/protocol/grpc/server.go
+++ b/protocol/grpc/server.go
@@ -22,7 +22,6 @@
 	"errors"
 	"fmt"
 	"github.com/go-mesh/mesher/common"
-	"github.com/go-mesh/mesher/config"
 	"github.com/go-mesh/mesher/resolver"
 	"net"
 	"strings"
@@ -32,6 +31,7 @@
 	"github.com/go-chassis/go-chassis/core/lager"
 	"github.com/go-chassis/go-chassis/core/server"
 	chassisTLS "github.com/go-chassis/go-chassis/core/tls"
+	"github.com/go-mesh/mesher/pkg/runtime"
 	"google.golang.org/grpc"
 	"google.golang.org/grpc/credentials"
 )
@@ -72,7 +72,7 @@
 		return fmt.Errorf("only support ipv4, input is [%s]", hs.opts.Address)
 	}
 
-	switch config.Mode {
+	switch runtime.Mode {
 	case common.ModeSidecar:
 		err = hs.startSidecar(host, port)
 	case common.ModePerHost:
diff --git a/protocol/http/http_server.go b/protocol/http/http_server.go
index e830c88..d6dbda0 100644
--- a/protocol/http/http_server.go
+++ b/protocol/http/http_server.go
@@ -34,6 +34,7 @@
 	"github.com/go-chassis/go-chassis/core/lager"
 	"github.com/go-chassis/go-chassis/core/server"
 	chassisTLS "github.com/go-chassis/go-chassis/core/tls"
+	"github.com/go-mesh/mesher/pkg/runtime"
 )
 
 const (
@@ -72,7 +73,7 @@
 		return fmt.Errorf("only support ipv4, input is [%s]", hs.opts.Address)
 	}
 
-	switch config.Mode {
+	switch runtime.Mode {
 	case common.ModeSidecar:
 		err = hs.startSidecar(host, port)
 	case common.ModePerHost:
diff --git a/protocol/http/reverse_proxy.go b/protocol/http/reverse_proxy.go
index 47c9b8c..2e708c0 100755
--- a/protocol/http/reverse_proxy.go
+++ b/protocol/http/reverse_proxy.go
@@ -74,8 +74,7 @@
 func consumerPreHandler(req *http.Request) *invocation.Invocation {
 	inv := preHandler(req)
 	inv.SourceServiceID = runtime.ServiceID
-	inv.SourceMicroService = chassisconfig.SelfServiceName
-	req.Header.Set(chassisCommon.HeaderSourceName, inv.SourceMicroService)
+	req.Header.Set(chassisCommon.HeaderSourceName, runtime.ServiceName)
 	inv.Ctx = context.TODO()
 	return inv
 }