From cc078f6a36a5f3fe119c4adc10ee0a0e745b069a Mon Sep 17 00:00:00 2001 From: Kadu Artur Prussek Date: Mon, 21 Sep 2020 17:45:26 -0300 Subject: [PATCH 1/5] Update metric api Signed-off-by: Kadu Artur Prussek --- .circleci/scripts/credentials.sh | 8 ++++++++ .circleci/scripts/ritchie_metric_server.sh | 4 ++-- Makefile | 7 ++++--- pkg/metric/http_sender.go | 8 ++++++++ 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.circleci/scripts/credentials.sh b/.circleci/scripts/credentials.sh index 2fe50eeb7..b6458a288 100755 --- a/.circleci/scripts/credentials.sh +++ b/.circleci/scripts/credentials.sh @@ -3,18 +3,26 @@ if expr "$CIRCLE_BRANCH" : 'qa' >/dev/null; then export AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID_QA" export AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY_QA" + export METRIC_BASIC_USER="$METRIC_BASIC_USER_QA" + export METRIC_BASIC_PASS="$METRIC_BASIC_PASS_QA" elif expr "$CIRCLE_BRANCH" : '^release-.*' >/dev/null; then export AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID_PROD" export AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY_PROD" + export METRIC_BASIC_USER="$METRIC_BASIC_USER_PROD" + export METRIC_BASIC_PASS="$METRIC_BASIC_PASS_PROD" elif expr "$CIRCLE_BRANCH" : '^nightly' >/dev/null; then export AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID_PROD" export AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY_PROD" + export METRIC_BASIC_USER="$METRIC_BASIC_USER_PROD" + export METRIC_BASIC_PASS="$METRIC_BASIC_PASS_PROD" elif expr "$CIRCLE_BRANCH" : '^beta' >/dev/null; then export AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID_PROD" export AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY_PROD" + export METRIC_BASIC_USER="$METRIC_BASIC_USER_PROD" + export METRIC_BASIC_PASS="$METRIC_BASIC_PASS_PROD" else echo "" fi diff --git a/.circleci/scripts/ritchie_metric_server.sh b/.circleci/scripts/ritchie_metric_server.sh index 6efc7fa72..be5c939a9 100755 --- a/.circleci/scripts/ritchie_metric_server.sh +++ b/.circleci/scripts/ritchie_metric_server.sh @@ -1,9 +1,9 @@ #!/bin/sh if expr "$VERSION" : '.*qa.*' >/dev/null; then - echo "https://ritchie-metrics.itiaws.dev/metrics" + echo "https://ritchie-metrics.devdennis.zup.io/v2/metrics" elif expr "$VERSION" : '^[0-9]\+' >/dev/null; then - echo "https://ritchie-metrics.zup.io/metrics" + echo "https://ritchie-metrics.zup.io/v2/metrics" else echo "" fi diff --git a/Makefile b/Makefile index 9aa29ec46..cf61db6a5 100644 --- a/Makefile +++ b/Makefile @@ -25,18 +25,19 @@ IS_NIGHTLY=$(shell echo $(VERSION) | egrep "*.nightly.*") GONNA_RELEASE=$(shell ./.circleci/scripts/gonna_release.sh) NEXT_VERSION=$(shell ./.circleci/scripts/next_version.sh) METRIC_SERVER_URL=$(shell VERSION=$(VERSION) ./.circleci/scripts/ritchie_metric_server.sh) +BUILD_ENVS='-X $(MODULE)/pkg/metric.BasicUser=$(METRIC_BASIC_USER) -X $(MODULE)/pkg/metric.BasicPass=$(METRIC_BASIC_PASS) -X $(MODULE)/pkg/metric.ServerRestURL=$(METRIC_SERVER_URL) -X $(MODULE)/pkg/cmd.Version=$(VERSION) -X $(MODULE)/pkg/cmd.BuildDate=$(DATE)' build-linux: mkdir -p $(DIST_LINUX) - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO_BUILD) -ldflags '-X $(MODULE)/pkg/metric.ServerRestURL=$(METRIC_SERVER_URL) -X $(MODULE)/pkg/cmd.Version=$(VERSION) -X $(MODULE)/pkg/cmd.BuildDate=$(DATE)' -o ./$(DIST_LINUX)/$(BINARY_NAME) -v $(CMD_PATH) + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO_BUILD) -ldflags $(BUILD_ENVS) -o ./$(DIST_LINUX)/$(BINARY_NAME) -v $(CMD_PATH) build-mac: mkdir -p $(DIST_MAC) - GOOS=darwin GOARCH=amd64 $(GO_BUILD) -ldflags '-X $(MODULE)/pkg/metric.ServerRestURL=$(METRIC_SERVER_URL) -X $(MODULE)/pkg/cmd.Version=$(VERSION) -X $(MODULE)/pkg/cmd.BuildDate=$(DATE)' -o ./$(DIST_MAC)/$(BINARY_NAME) -v $(CMD_PATH) + GOOS=darwin GOARCH=amd64 $(GO_BUILD) -ldflags $(BUILD_ENVS) -o ./$(DIST_MAC)/$(BINARY_NAME) -v $(CMD_PATH) build-windows: mkdir -p $(DIST_WIN) - GOOS=windows GOARCH=amd64 $(GO_BUILD) -ldflags '-X $(MODULE)/pkg/metric.ServerRestURL=$(METRIC_SERVER_URL) -X $(MODULE)/pkg/cmd.Version=$(VERSION) -X $(MODULE)/pkg/cmd.BuildDate=$(DATE)' -o ./$(DIST_WIN)/$(BINARY_NAME).exe -v $(CMD_PATH) + GOOS=windows GOARCH=amd64 $(GO_BUILD) -ldflags $(BUILD_ENVS) -o ./$(DIST_WIN)/$(BINARY_NAME).exe -v $(CMD_PATH) build: build-linux build-mac build-windows ifneq "$(BUCKET)" "" diff --git a/pkg/metric/http_sender.go b/pkg/metric/http_sender.go index 1180d040d..3b963fe92 100644 --- a/pkg/metric/http_sender.go +++ b/pkg/metric/http_sender.go @@ -19,11 +19,17 @@ package metric import ( "bytes" "encoding/json" + "fmt" "net/http" ) var _ Sender = SendManagerHttp{} +var ( + BasicUser = "" + BasicPass = "" +) + type SendManagerHttp struct { URL string client *http.Client @@ -37,6 +43,7 @@ func NewHttpSender(url string, client *http.Client) SendManagerHttp { } func (sm SendManagerHttp) Send(APIData APIData) { + fmt.Println(sm.URL) reqBody, err := json.Marshal(&APIData) if err != nil { return @@ -47,6 +54,7 @@ func (sm SendManagerHttp) Send(APIData APIData) { return } + req.SetBasicAuth(BasicUser, BasicPass) req.Header.Add("Content-Type", "application/json") _, _ = sm.client.Do(req) } From ef48d0f38afeb59f60323cfb6bc63b6ad59a1372 Mon Sep 17 00:00:00 2001 From: Kadu Artur Prussek Date: Mon, 21 Sep 2020 17:46:32 -0300 Subject: [PATCH 2/5] Update metric api Signed-off-by: Kadu Artur Prussek --- pkg/metric/http_sender.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/metric/http_sender.go b/pkg/metric/http_sender.go index 3b963fe92..b2386134b 100644 --- a/pkg/metric/http_sender.go +++ b/pkg/metric/http_sender.go @@ -19,7 +19,6 @@ package metric import ( "bytes" "encoding/json" - "fmt" "net/http" ) @@ -43,7 +42,6 @@ func NewHttpSender(url string, client *http.Client) SendManagerHttp { } func (sm SendManagerHttp) Send(APIData APIData) { - fmt.Println(sm.URL) reqBody, err := json.Marshal(&APIData) if err != nil { return From 0c0bc1b6de6a84d958bef142a11d8df045f1ddc7 Mon Sep 17 00:00:00 2001 From: Kadu Artur Prussek Date: Mon, 21 Sep 2020 18:29:19 -0300 Subject: [PATCH 3/5] Export envs to makefile Signed-off-by: Kadu Artur Prussek --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index cf61db6a5..137413b59 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,8 @@ IS_NIGHTLY=$(shell echo $(VERSION) | egrep "*.nightly.*") GONNA_RELEASE=$(shell ./.circleci/scripts/gonna_release.sh) NEXT_VERSION=$(shell ./.circleci/scripts/next_version.sh) METRIC_SERVER_URL=$(shell VERSION=$(VERSION) ./.circleci/scripts/ritchie_metric_server.sh) +METRIC_BASIC_USER=$(METRIC_BASIC_USER) +METRIC_BASIC_PASS=$(METRIC_BASIC_PASS) BUILD_ENVS='-X $(MODULE)/pkg/metric.BasicUser=$(METRIC_BASIC_USER) -X $(MODULE)/pkg/metric.BasicPass=$(METRIC_BASIC_PASS) -X $(MODULE)/pkg/metric.ServerRestURL=$(METRIC_SERVER_URL) -X $(MODULE)/pkg/cmd.Version=$(VERSION) -X $(MODULE)/pkg/cmd.BuildDate=$(DATE)' build-linux: From f2103575815c07d1c25c48e77a2ffa469afe5653 Mon Sep 17 00:00:00 2001 From: Kadu Artur Prussek Date: Mon, 21 Sep 2020 18:32:24 -0300 Subject: [PATCH 4/5] Fix envs name Signed-off-by: Kadu Artur Prussek --- .circleci/scripts/credentials.sh | 16 ++++++++-------- Makefile | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.circleci/scripts/credentials.sh b/.circleci/scripts/credentials.sh index b6458a288..6b8b0f532 100755 --- a/.circleci/scripts/credentials.sh +++ b/.circleci/scripts/credentials.sh @@ -3,26 +3,26 @@ if expr "$CIRCLE_BRANCH" : 'qa' >/dev/null; then export AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID_QA" export AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY_QA" - export METRIC_BASIC_USER="$METRIC_BASIC_USER_QA" - export METRIC_BASIC_PASS="$METRIC_BASIC_PASS_QA" + export METRIC_BASIC_USERNAME="$METRIC_BASIC_USER_QA" + export METRIC_BASIC_PASSWORD="$METRIC_BASIC_PASS_QA" elif expr "$CIRCLE_BRANCH" : '^release-.*' >/dev/null; then export AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID_PROD" export AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY_PROD" - export METRIC_BASIC_USER="$METRIC_BASIC_USER_PROD" - export METRIC_BASIC_PASS="$METRIC_BASIC_PASS_PROD" + export METRIC_BASIC_USERNAME="$METRIC_BASIC_USER_PROD" + export METRIC_BASIC_PASSWORD="$METRIC_BASIC_PASS_PROD" elif expr "$CIRCLE_BRANCH" : '^nightly' >/dev/null; then export AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID_PROD" export AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY_PROD" - export METRIC_BASIC_USER="$METRIC_BASIC_USER_PROD" - export METRIC_BASIC_PASS="$METRIC_BASIC_PASS_PROD" + export METRIC_BASIC_USERNAME="$METRIC_BASIC_USER_PROD" + export METRIC_BASIC_PASSWORD="$METRIC_BASIC_PASS_PROD" elif expr "$CIRCLE_BRANCH" : '^beta' >/dev/null; then export AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID_PROD" export AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY_PROD" - export METRIC_BASIC_USER="$METRIC_BASIC_USER_PROD" - export METRIC_BASIC_PASS="$METRIC_BASIC_PASS_PROD" + export METRIC_BASIC_USERNAME="$METRIC_BASIC_USER_PROD" + export METRIC_BASIC_PASSWORD="$METRIC_BASIC_PASS_PROD" else echo "" fi diff --git a/Makefile b/Makefile index 137413b59..951898af6 100644 --- a/Makefile +++ b/Makefile @@ -25,8 +25,8 @@ IS_NIGHTLY=$(shell echo $(VERSION) | egrep "*.nightly.*") GONNA_RELEASE=$(shell ./.circleci/scripts/gonna_release.sh) NEXT_VERSION=$(shell ./.circleci/scripts/next_version.sh) METRIC_SERVER_URL=$(shell VERSION=$(VERSION) ./.circleci/scripts/ritchie_metric_server.sh) -METRIC_BASIC_USER=$(METRIC_BASIC_USER) -METRIC_BASIC_PASS=$(METRIC_BASIC_PASS) +METRIC_BASIC_USER=$(METRIC_BASIC_USERNAME) +METRIC_BASIC_PASS=$(METRIC_BASIC_PASSWORD) BUILD_ENVS='-X $(MODULE)/pkg/metric.BasicUser=$(METRIC_BASIC_USER) -X $(MODULE)/pkg/metric.BasicPass=$(METRIC_BASIC_PASS) -X $(MODULE)/pkg/metric.ServerRestURL=$(METRIC_SERVER_URL) -X $(MODULE)/pkg/cmd.Version=$(VERSION) -X $(MODULE)/pkg/cmd.BuildDate=$(DATE)' build-linux: From 4ccb0e382bb1da6c01fd8b246cb670be42c39569 Mon Sep 17 00:00:00 2001 From: Kadu Artur Prussek Date: Mon, 21 Sep 2020 18:40:39 -0300 Subject: [PATCH 5/5] Fix envs name Signed-off-by: Kadu Artur Prussek --- .circleci/config.yml | 1 + .circleci/scripts/credentials.sh | 16 ++++++++-------- Makefile | 2 -- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1fd1da046..2fc5616ec 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -194,6 +194,7 @@ jobs: name: Running build command: | . ./.circleci/scripts/version.sh + . ./.circleci/scripts/credentials.sh make build-circle - run: name: Persist version file diff --git a/.circleci/scripts/credentials.sh b/.circleci/scripts/credentials.sh index 6b8b0f532..b6458a288 100755 --- a/.circleci/scripts/credentials.sh +++ b/.circleci/scripts/credentials.sh @@ -3,26 +3,26 @@ if expr "$CIRCLE_BRANCH" : 'qa' >/dev/null; then export AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID_QA" export AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY_QA" - export METRIC_BASIC_USERNAME="$METRIC_BASIC_USER_QA" - export METRIC_BASIC_PASSWORD="$METRIC_BASIC_PASS_QA" + export METRIC_BASIC_USER="$METRIC_BASIC_USER_QA" + export METRIC_BASIC_PASS="$METRIC_BASIC_PASS_QA" elif expr "$CIRCLE_BRANCH" : '^release-.*' >/dev/null; then export AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID_PROD" export AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY_PROD" - export METRIC_BASIC_USERNAME="$METRIC_BASIC_USER_PROD" - export METRIC_BASIC_PASSWORD="$METRIC_BASIC_PASS_PROD" + export METRIC_BASIC_USER="$METRIC_BASIC_USER_PROD" + export METRIC_BASIC_PASS="$METRIC_BASIC_PASS_PROD" elif expr "$CIRCLE_BRANCH" : '^nightly' >/dev/null; then export AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID_PROD" export AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY_PROD" - export METRIC_BASIC_USERNAME="$METRIC_BASIC_USER_PROD" - export METRIC_BASIC_PASSWORD="$METRIC_BASIC_PASS_PROD" + export METRIC_BASIC_USER="$METRIC_BASIC_USER_PROD" + export METRIC_BASIC_PASS="$METRIC_BASIC_PASS_PROD" elif expr "$CIRCLE_BRANCH" : '^beta' >/dev/null; then export AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID_PROD" export AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY_PROD" - export METRIC_BASIC_USERNAME="$METRIC_BASIC_USER_PROD" - export METRIC_BASIC_PASSWORD="$METRIC_BASIC_PASS_PROD" + export METRIC_BASIC_USER="$METRIC_BASIC_USER_PROD" + export METRIC_BASIC_PASS="$METRIC_BASIC_PASS_PROD" else echo "" fi diff --git a/Makefile b/Makefile index 951898af6..cf61db6a5 100644 --- a/Makefile +++ b/Makefile @@ -25,8 +25,6 @@ IS_NIGHTLY=$(shell echo $(VERSION) | egrep "*.nightly.*") GONNA_RELEASE=$(shell ./.circleci/scripts/gonna_release.sh) NEXT_VERSION=$(shell ./.circleci/scripts/next_version.sh) METRIC_SERVER_URL=$(shell VERSION=$(VERSION) ./.circleci/scripts/ritchie_metric_server.sh) -METRIC_BASIC_USER=$(METRIC_BASIC_USERNAME) -METRIC_BASIC_PASS=$(METRIC_BASIC_PASSWORD) BUILD_ENVS='-X $(MODULE)/pkg/metric.BasicUser=$(METRIC_BASIC_USER) -X $(MODULE)/pkg/metric.BasicPass=$(METRIC_BASIC_PASS) -X $(MODULE)/pkg/metric.ServerRestURL=$(METRIC_SERVER_URL) -X $(MODULE)/pkg/cmd.Version=$(VERSION) -X $(MODULE)/pkg/cmd.BuildDate=$(DATE)' build-linux: