diff --git a/Makefile b/Makefile index e8750a76287caf0b42a60ce1fbe7d2c536f5af77..46b3fdbfbb9d2747a4fa7b9003a26e07cbc8181e 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,9 @@ SERVER_OUT := "bin/server" PKG := "code.vereign.com/code/key-storage-agent" SERVER_PKG_BUILD := "${PKG}" PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/) +BRANCH := $(shell git branch | grep \* | cut -d ' ' -f2) +COMMIT := $(shell git branch | git describe --always --long --dirty) +VER := $(BRANCH).$(COMMIT) .PHONY: all api server @@ -10,7 +13,7 @@ all: server dep: ## Get the dependencies dep ensure server: dep ## Build the binary file for server - @go build -i -v -o $(SERVER_OUT) $(SERVER_PKG_BUILD) + @go build -ldflags="-X code.vereign.com/code/key-storage-agent/handler.version=$(VER)" -i -v -o $(SERVER_OUT) $(SERVER_PKG_BUILD) clean: ## Remove previous builds @rm $(SERVER_OUT) diff --git a/handler/handler.go b/handler/handler.go index fac6e94d1b167a93fabceb2c157b913340ed6448..b53e59b673818784d4bcddcac9c7ca0a6da98a02 100644 --- a/handler/handler.go +++ b/handler/handler.go @@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. package handler import ( + "fmt" "io/ioutil" "strings" @@ -43,6 +44,8 @@ type KeyStorageServerImpl struct { MaxMessageSize int } +var version = "undefined" + func (s *KeyStorageServerImpl) CreateAuthentication(ctx context.Context) *authentication.Authentication { if md, ok := metadata.FromIncomingContext(ctx); ok { uuid := strings.Join(md["uuid"], "") @@ -194,3 +197,8 @@ func (s *KeyStorageServerImpl) ReserveKeyUUID(ctx context.Context, in *api.Reser return reserveKeyUUIDResponse, nil } + +func (s *KeyStorageServerImpl) GetVersionKSA(ctx context.Context, in *api.GetVersionKSAMessage) (*api.GetVersionKSAResponseMessage, error) { + fmt.Println("Version: " + version) + return &api.GetVersionKSAResponseMessage{Version: version, Errors: ""}, nil +} \ No newline at end of file