Skip to content
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
21 changes: 20 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ endif
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

BUILD_DATE := $(shell date +%Y-%m-%d\ %H:%M)
BUILD_TAG_SHA := $(shell git rev-list --abbrev-commit --tags --max-count=1)
BUILD_TAG_NAME := $(shell git describe --abbrev=0 --tags ${BUILD_TAG_SHA} 2>/dev/null || true)
BUILD_SHA := $(shell git rev-parse --short HEAD)
BUILD_VERSION := $(BUILD_TAG_NAME:v%=%)
ifneq ($(BUILD_SHA), $(BUILD_TAG_SHA))
BUILD_VERSION := $(BUILD_VERSION)-$(BUILD_SHA)
endif
ifneq ($(shell git status --porcelain),)
BUILD_VERSION := $(BUILD_VERSION)-dirty
endif

.PHONY: all
all: build

Expand Down Expand Up @@ -147,7 +159,14 @@ modules: ## Update Go dependencies.

.PHONY: build
build: modules fmt vet ## Build manager binary.
go build -o bin/manager main.go
go build \
-ldflags " \
-X 'main.OperatorVersion=$(BUILD_VERSION)' \
-X 'main.McadVersion=$(MCAD_VERSION)' \
-X 'main.InstaScaleVersion=$(INSTASCALE_VERSION)' \
-X 'main.BuildDate=$(BUILD_DATE)' \
" \
-o bin/manager main.go

.PHONY: run
run: modules manifests fmt vet ## Run a controller from your host.
Expand Down
14 changes: 12 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ import (
)

var (
scheme = runtime.NewScheme()
setupLog = ctrl.Log.WithName("setup")
scheme = runtime.NewScheme()
setupLog = ctrl.Log.WithName("setup")
OperatorVersion = "UNKNOWN"
McadVersion = "UNKNOWN"
InstaScaleVersion = "UNKNOWN"
BuildDate = "UNKNOWN"
)

func init() {
Expand All @@ -85,6 +89,12 @@ func main() {
zapOptions.BindFlags(flag.CommandLine)

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&zapOptions)))
setupLog.Info("Build info",
"operatorVersion", OperatorVersion,
"mcadVersion", McadVersion,
"instaScaleVersion", InstaScaleVersion,
"date", BuildDate,
)

ctx := ctrl.SetupSignalHandler()

Expand Down