Correctly set version info when building, fixed build script and added headers for apps endpoints.

This commit is contained in:
Stanislav Nikitin 2020-11-28 23:46:24 +05:00
parent cdf9997cfe
commit e679fecf6e
Signed by: pztrn
GPG Key ID: 1E944A0F0568B550
4 changed files with 18 additions and 4 deletions

View File

@ -5,7 +5,7 @@ help: Makefile
@echo -e "Metricator Makefile available subcommands:\n" @echo -e "Metricator Makefile available subcommands:\n"
@cat $< | grep "## " | sort | sed -n 's/^## //p' @cat $< | grep "## " | sort | sed -n 's/^## //p'
@echo "" @echo ""
@make -f Makefile show-git-data @make show-git-data
.DEFAULT_GOAL := help .DEFAULT_GOAL := help
@ -14,8 +14,8 @@ check-build-dir:
## metricatord-build: builds metricator daemon and places into ${PWD}/._bin. ## metricatord-build: builds metricator daemon and places into ${PWD}/._bin.
metricatord-build: check-build-dir metricatord-build: check-build-dir
rm ./._bin/metricatord || true @rm ./._bin/metricatord || true
cd cmd/metricatord && go build -o ../../._bin/metricatord @scripts/build.sh metricatord
## metricatord-run: starts metricator daemon. ## metricatord-run: starts metricator daemon.
metricatord-run: metricatord-build metricatord-run: metricatord-build

View File

@ -27,6 +27,8 @@ type Config struct {
// Endpoint is a remote application endpoint which should give us metrics // Endpoint is a remote application endpoint which should give us metrics
// in Prometheus format. // in Prometheus format.
Endpoint string Endpoint string
// Headers is a list of headers that should be added to metrics request.
Headers map[string]string
// TimeBetweenRequests is a minimal amount of time which should pass // TimeBetweenRequests is a minimal amount of time which should pass
// between requests. // between requests.
TimeBetweenRequests time.Duration TimeBetweenRequests time.Duration

View File

@ -3,3 +3,15 @@
# Metricator build script. # Metricator build script.
source ./scripts/shell_helpers/get_git_data.sh source ./scripts/shell_helpers/get_git_data.sh
WHATTOBUILD=$1
LINKERFLAGS="\
-X go.dev.pztrn.name/metricator/internal/common.Branch=${BRANCHNAME} \
-X go.dev.pztrn.name/metricator/internal/common.Build=${BUILDID} \
-X go.dev.pztrn.name/metricator/internal/common.CommitHash=${COMMITHASH} \
-X go.dev.pztrn.name/metricator/internal/common.Version=${VERSION}"
cd cmd/${WHATTOBUILD}
go build -tags netgo -ldflags "${LINKERFLAGS} -w -extldflags '-static'" -o ../../._bin/${WHATTOBUILD}

View File

@ -3,7 +3,7 @@
# Showing git data in console. # Showing git data in console.
source ./scripts/shell_helpers/get_git_data.sh source ./scripts/shell_helpers/get_git_data.sh
echo "* Branch: ${BRANCH}" echo "* Branch: ${BRANCHNAME}"
echo "* Build ID: ${BUILDID}" echo "* Build ID: ${BUILDID}"
echo "* Commit hash: ${COMMITHASH}" echo "* Commit hash: ${COMMITHASH}"
echo "* Version: ${VERSION}" echo "* Version: ${VERSION}"