Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Upgrade metric api #539

Merged
merged 6 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions .circleci/scripts/credentials.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions .circleci/scripts/ritchie_metric_server.sh
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)" ""
Expand Down
6 changes: 6 additions & 0 deletions pkg/metric/http_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ import (

var _ Sender = SendManagerHttp{}

var (
BasicUser = ""
BasicPass = ""
)

type SendManagerHttp struct {
URL string
client *http.Client
Expand All @@ -47,6 +52,7 @@ func (sm SendManagerHttp) Send(APIData APIData) {
return
}

req.SetBasicAuth(BasicUser, BasicPass)
req.Header.Add("Content-Type", "application/json")
_, _ = sm.client.Do(req)
}