cert-manager/Makefile
Maël Valais de5c0bf381 make: the AppVersion and AppGitCommit weren't set
When checking how User-Agent headers would differ from v1.7.1 to
v1.8.0, The User-Agent looked off:

    cert-manager-issuers/v1.8.0 (linux/amd64) cert-manager/

The ending "/" should be followed by the git commit hash. It seems like
we forgot to port what Bazel does to fill AppVersion, AppGitCommit, and
AppGitState. This commit adds this feature to the Makefile. The
User-Agent should now look like this:

    cert-manager-issuers/v1.8.0 (linux/amd64) cert-manager/9dd5f6c85fde2c3ed58cd6c9e465bb5a4c1ca2b2
                 <----->
                This part depends
                on the component.

Signed-off-by: Maël Valais <mael@vls.dev>
2022-03-25 20:44:04 +01:00

63 lines
2.2 KiB
Makefile

# Copyright 2020 The cert-manager Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For details on some of these "prelude" settings, see:
# https://clarkgrubb.com/makefile-style-guide
MAKEFLAGS += --warn-undefined-variables --no-builtin-rules
SHELL := /bin/bash
.SHELLFLAGS := -uo pipefail -c
.DEFAULT_GOAL := help
.DELETE_ON_ERROR:
.SUFFIXES:
SOURCES := $(shell find . -type f -name "*.go" -not -path "./bin/*" -not -path "./make/*")
include make/git.mk
include make/tools.mk
include make/ci.mk
include make/test.mk
include make/base_images.mk
include make/cmctl.mk
include make/server.mk
include make/containers.mk
include make/release.mk
include make/manifests.mk
include make/licenses.mk
include make/e2e-setup.mk
include make/help.mk
## GOBUILDPROCS is passed to GOMAXPROCS when running go build; if you're running
## make in parallel using "-jN" then you'll probably want to reduce the value
## of GOBUILDPROCS or else you could end up running N parallel invocations of
## go build, each of which will spin up as many threads as are available on your
## system.
GOBUILDPROCS ?=
GOFLAGS := -trimpath -ldflags '-w -s \
-X github.com/cert-manager/cert-manager/pkg/util.AppVersion=$(RELEASE_VERSION) \
-X github.com/cert-manager/cert-manager/pkg/util.AppGitCommit=$(GITCOMMIT)'
.PHONY: clean
## Remove the kind cluster and everything that was built. The downloaded images
## and tools are kept intact to avoid re-downloading everything. To really wipe
## out everything, run the command:
##
## rm -rf bin
##
## @category Development
clean:
@$(eval KIND_CLUSTER_NAME ?= kind)
bin/tools/kind delete cluster --name=$(shell cat bin/scratch/kind-exists 2>/dev/null || echo $(KIND_CLUSTER_NAME)) -q 2>/dev/null || true
rm -rf $(filter-out bin/downloaded,$(wildcard bin/*))