2017-07-26 08:16:18 +03:00
|
|
|
TARGETS = darwin/amd64 linux/amd64 windows/amd64
|
|
|
|
DIST_DIRS = find * -type d -exec
|
|
|
|
|
2016-10-24 20:32:22 +03:00
|
|
|
.NOTPARALLEL:
|
|
|
|
|
2019-08-27 01:55:18 +03:00
|
|
|
.PHONY: bootstrap build test test_fmt validate-copyright-headers fmt lint ci
|
2017-01-10 23:29:27 +03:00
|
|
|
|
2017-08-17 21:56:33 +03:00
|
|
|
ifdef DEBUG
|
2019-11-05 05:33:33 +03:00
|
|
|
GOFLAGS := -gcflags="-N -l" -mod=vendor
|
2017-08-17 21:56:33 +03:00
|
|
|
else
|
2019-11-05 05:33:33 +03:00
|
|
|
GOFLAGS := -mod=vendor
|
2017-08-17 21:56:33 +03:00
|
|
|
endif
|
|
|
|
|
2017-07-26 08:16:18 +03:00
|
|
|
# go option
|
2017-09-22 02:36:47 +03:00
|
|
|
GO ?= go
|
|
|
|
TAGS :=
|
|
|
|
LDFLAGS :=
|
|
|
|
BINDIR := $(CURDIR)/bin
|
2019-01-04 03:42:10 +03:00
|
|
|
PROJECT := aks-engine
|
2017-09-22 02:36:47 +03:00
|
|
|
VERSION ?= $(shell git rev-parse HEAD)
|
|
|
|
VERSION_SHORT ?= $(shell git rev-parse --short HEAD)
|
|
|
|
GITTAG := $(shell git describe --exact-match --tags $(shell git log -n1 --pretty='%h') 2> /dev/null)
|
2022-09-28 02:51:35 +03:00
|
|
|
GOPATH ?= $(shell $(GO) env GOPATH)
|
2020-02-05 20:27:55 +03:00
|
|
|
GOBIN ?= $(shell $(GO) env GOPATH)/bin
|
|
|
|
TOOLSBIN := $(CURDIR)/hack/tools/bin
|
|
|
|
AIKey ?= c92d8284-b550-4b06-b7ba-e80fd7178faa
|
2017-09-22 02:36:47 +03:00
|
|
|
ifeq ($(GITTAG),)
|
|
|
|
GITTAG := $(VERSION_SHORT)
|
|
|
|
endif
|
2017-03-21 08:55:10 +03:00
|
|
|
|
2023-02-28 20:22:29 +03:00
|
|
|
DEV_ENV_IMAGE := mcr.microsoft.com/oss/azcu/go-dev:v1.36.1
|
2019-11-04 21:42:45 +03:00
|
|
|
DEV_ENV_WORK_DIR := /aks-engine
|
|
|
|
DEV_ENV_OPTS := --rm -v $(GOPATH)/pkg/mod:/go/pkg/mod -v $(CURDIR):$(DEV_ENV_WORK_DIR) -w $(DEV_ENV_WORK_DIR) $(DEV_ENV_VARS)
|
2019-05-09 02:41:43 +03:00
|
|
|
DEV_ENV_CMD := docker run $(DEV_ENV_OPTS) $(DEV_ENV_IMAGE)
|
|
|
|
DEV_ENV_CMD_IT := docker run -it $(DEV_ENV_OPTS) $(DEV_ENV_IMAGE)
|
|
|
|
DEV_CMD_RUN := docker run $(DEV_ENV_OPTS)
|
2017-09-18 23:30:50 +03:00
|
|
|
ifdef DEBUG
|
2019-05-09 02:41:43 +03:00
|
|
|
LDFLAGS := -X main.version=$(VERSION)
|
2017-09-18 23:30:50 +03:00
|
|
|
else
|
2020-02-05 20:27:55 +03:00
|
|
|
LDFLAGS := -s -X main.version=$(VERSION) -X github.com/Azure/$(PROJECT)/pkg/telemetry.AKSEngineAppInsightsKey=$(AIKey)
|
2017-09-18 23:30:50 +03:00
|
|
|
endif
|
2017-08-16 23:19:41 +03:00
|
|
|
BINARY_DEST_DIR ?= bin
|
|
|
|
|
2019-01-04 03:42:10 +03:00
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
EXTENSION = .exe
|
|
|
|
SHELL = cmd.exe
|
|
|
|
CHECK = where.exe
|
|
|
|
else
|
|
|
|
EXTENSION =
|
|
|
|
SHELL = bash
|
|
|
|
CHECK = which
|
|
|
|
endif
|
|
|
|
|
2019-11-04 22:52:14 +03:00
|
|
|
# Active module mode, as we use go modules to manage dependencies
|
|
|
|
export GO111MODULE=on
|
|
|
|
|
2019-12-03 04:00:45 +03:00
|
|
|
# Add the tools bin to the front of the path
|
|
|
|
export PATH := $(TOOLSBIN):$(PATH)
|
|
|
|
|
2017-05-10 01:50:19 +03:00
|
|
|
all: build
|
|
|
|
|
2017-10-30 20:11:04 +03:00
|
|
|
.PHONY: dev
|
|
|
|
dev:
|
|
|
|
$(DEV_ENV_CMD_IT) bash
|
|
|
|
|
2018-08-31 00:20:22 +03:00
|
|
|
.PHONY: validate-dependencies
|
|
|
|
validate-dependencies: bootstrap
|
2019-05-10 01:13:40 +03:00
|
|
|
@./scripts/validate-dependencies.sh
|
2018-08-31 00:20:22 +03:00
|
|
|
|
2018-12-03 22:19:18 +03:00
|
|
|
.PHONY: validate-copyright-headers
|
|
|
|
validate-copyright-headers:
|
2019-05-10 01:13:40 +03:00
|
|
|
@./scripts/validate-copyright-header.sh
|
2018-12-03 22:19:18 +03:00
|
|
|
|
2019-05-10 01:13:40 +03:00
|
|
|
.PHONY: validate-go
|
|
|
|
validate-go:
|
|
|
|
@./scripts/validate-go.sh
|
|
|
|
|
|
|
|
.PHONY: validate-shell
|
|
|
|
validate-shell:
|
|
|
|
@./scripts/validate-shell.sh
|
2019-01-07 22:27:24 +03:00
|
|
|
|
2017-07-28 20:55:34 +03:00
|
|
|
.PHONY: generate
|
2017-08-18 06:01:01 +03:00
|
|
|
generate: bootstrap
|
2019-12-03 04:00:45 +03:00
|
|
|
@echo "$$(go-bindata --version)"
|
2019-11-04 21:42:45 +03:00
|
|
|
go generate $(GOFLAGS) -v ./... > /dev/null 2>&1
|
2017-07-26 08:16:18 +03:00
|
|
|
|
2017-10-31 23:15:19 +03:00
|
|
|
.PHONY: generate-azure-constants
|
2021-06-29 02:49:09 +03:00
|
|
|
generate-azure-constants: build-binary
|
|
|
|
$(BINARY_DEST_DIR)/aks-engine get-locations -o code --client-id=$(AZURE_CLIENT_ID) --client-secret=$(AZURE_CLIENT_SECRET) --subscription-id=$(AZURE_SUBSCRIPTION_ID) \
|
2020-04-07 04:00:50 +03:00
|
|
|
> pkg/helpers/azure_locations.go
|
2021-06-29 02:49:09 +03:00
|
|
|
$(BINARY_DEST_DIR)/aks-engine get-skus -o code --client-id=$(AZURE_CLIENT_ID) --client-secret=$(AZURE_CLIENT_SECRET) --subscription-id=$(AZURE_SUBSCRIPTION_ID) \
|
2020-04-07 04:00:50 +03:00
|
|
|
> pkg/helpers/azure_skus_const.go
|
2017-10-31 23:15:19 +03:00
|
|
|
|
2017-07-26 08:16:18 +03:00
|
|
|
.PHONY: build
|
2019-11-04 21:42:45 +03:00
|
|
|
build: generate go-build
|
|
|
|
|
|
|
|
.PHONY: go-build
|
|
|
|
go-build:
|
2019-11-05 05:33:33 +03:00
|
|
|
$(GO) build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o $(BINDIR)/$(PROJECT)$(EXTENSION) $(REPO_PATH)
|
2019-11-04 21:42:45 +03:00
|
|
|
|
|
|
|
.PHONY: tidy
|
|
|
|
tidy:
|
|
|
|
$(GO) mod tidy
|
2020-05-27 20:25:30 +03:00
|
|
|
make -C ./test/e2e tidy
|
2019-11-04 21:42:45 +03:00
|
|
|
|
|
|
|
.PHONY: vendor
|
|
|
|
vendor: tidy
|
|
|
|
$(GO) mod vendor
|
2017-07-26 08:16:18 +03:00
|
|
|
|
2017-08-24 02:09:58 +03:00
|
|
|
build-binary: generate
|
2019-05-09 02:41:43 +03:00
|
|
|
go build $(GOFLAGS) -v -ldflags "$(LDFLAGS)" -o $(BINARY_DEST_DIR)/aks-engine .
|
2017-08-16 23:19:41 +03:00
|
|
|
|
2017-07-26 08:16:18 +03:00
|
|
|
# usage: make clean build-cross dist VERSION=v0.4.0
|
|
|
|
.PHONY: build-cross
|
2017-09-22 02:36:47 +03:00
|
|
|
build-cross: build
|
2017-07-26 08:16:18 +03:00
|
|
|
build-cross: LDFLAGS += -extldflags "-static"
|
|
|
|
build-cross:
|
2019-05-09 02:41:43 +03:00
|
|
|
CGO_ENABLED=0 gox -output="_dist/aks-engine-$(GITTAG)-{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)'
|
2017-07-26 08:16:18 +03:00
|
|
|
|
|
|
|
.PHONY: dist
|
2021-07-09 00:30:25 +03:00
|
|
|
dist: build-cross
|
2017-07-26 08:16:18 +03:00
|
|
|
( \
|
|
|
|
cd _dist && \
|
|
|
|
$(DIST_DIRS) cp ../LICENSE {} \; && \
|
|
|
|
$(DIST_DIRS) cp ../README.md {} \; && \
|
|
|
|
$(DIST_DIRS) tar -zcf {}.tar.gz {} \; && \
|
|
|
|
$(DIST_DIRS) zip -r {}.zip {} \; \
|
|
|
|
)
|
2019-03-11 21:33:20 +03:00
|
|
|
|
2017-07-26 08:16:18 +03:00
|
|
|
.PHONY: checksum
|
|
|
|
checksum:
|
|
|
|
for f in _dist/*.{gz,zip} ; do \
|
|
|
|
shasum -a 256 "$${f}" | awk '{print $$1}' > "$${f}.sha256" ; \
|
|
|
|
done
|
|
|
|
|
2019-03-11 18:47:21 +03:00
|
|
|
.PHONY: build-container
|
|
|
|
build-container:
|
|
|
|
docker build --no-cache --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
|
2019-05-09 02:41:43 +03:00
|
|
|
--build-arg AKSENGINE_VERSION="$(VERSION)" -t microsoft/aks-engine:$(VERSION) \
|
2019-03-11 18:47:21 +03:00
|
|
|
--file ./releases/Dockerfile.linux ./releases || \
|
|
|
|
echo 'This target works only for published releases. For example, "VERSION=0.32.0 make build-container".'
|
|
|
|
|
2017-07-26 08:16:18 +03:00
|
|
|
.PHONY: clean
|
2019-12-03 04:00:45 +03:00
|
|
|
clean: tools-clean
|
2019-05-13 21:25:41 +03:00
|
|
|
@rm -rf $(BINDIR) ./_dist ./pkg/helpers/unit_tests
|
2016-10-24 20:32:22 +03:00
|
|
|
|
2017-08-04 20:02:43 +03:00
|
|
|
GIT_BASEDIR = $(shell git rev-parse --show-toplevel 2>/dev/null)
|
|
|
|
ifneq ($(GIT_BASEDIR),)
|
2019-05-09 02:41:43 +03:00
|
|
|
LDFLAGS += -X github.com/Azure/aks-engine/pkg/test.JUnitOutDir=$(GIT_BASEDIR)/test/junit
|
2017-08-04 20:02:43 +03:00
|
|
|
endif
|
|
|
|
|
2019-07-11 18:17:23 +03:00
|
|
|
ginkgoBuild: generate
|
2019-11-06 03:44:38 +03:00
|
|
|
make -C ./test/e2e ginkgo-build
|
2019-07-11 18:17:23 +03:00
|
|
|
|
2021-06-30 01:04:57 +03:00
|
|
|
test: generate
|
2020-02-05 20:27:55 +03:00
|
|
|
ginkgo -mod=vendor -skipPackage test/e2e -failFast -r -v -tags=fast -ldflags '$(LDFLAGS)' .
|
2016-10-24 20:32:22 +03:00
|
|
|
|
2017-05-30 03:26:06 +03:00
|
|
|
.PHONY: test-style
|
2022-11-02 21:47:44 +03:00
|
|
|
test-style: validate-go validate-copyright-headers
|
2017-03-09 02:04:50 +03:00
|
|
|
|
2019-02-15 03:32:07 +03:00
|
|
|
.PHONY: ensure-generated
|
|
|
|
ensure-generated:
|
2019-02-08 23:24:17 +03:00
|
|
|
@echo "==> Checking generated files <=="
|
2019-02-15 03:32:07 +03:00
|
|
|
@scripts/ensure-generated.sh
|
2019-02-08 23:24:17 +03:00
|
|
|
|
2017-08-02 03:38:29 +03:00
|
|
|
.PHONY: test-e2e
|
|
|
|
test-e2e:
|
|
|
|
@test/e2e.sh
|
|
|
|
|
2019-01-04 03:42:10 +03:00
|
|
|
HAS_GIT := $(shell $(CHECK) git)
|
2017-07-26 08:16:18 +03:00
|
|
|
|
|
|
|
.PHONY: bootstrap
|
2019-11-05 05:33:33 +03:00
|
|
|
bootstrap: tools-install
|
2017-07-26 08:16:18 +03:00
|
|
|
ifndef HAS_GIT
|
|
|
|
$(error You must install Git)
|
2017-08-02 03:38:29 +03:00
|
|
|
endif
|
2019-11-05 05:33:33 +03:00
|
|
|
|
2019-12-03 04:00:45 +03:00
|
|
|
.PHONY: tools-reload
|
|
|
|
tools-reload:
|
|
|
|
make -C hack/tools reload
|
|
|
|
|
2019-11-05 05:33:33 +03:00
|
|
|
.PHONY: tools-install
|
|
|
|
tools-install:
|
|
|
|
make -C hack/tools/
|
2017-08-04 20:02:43 +03:00
|
|
|
|
2019-12-03 04:00:45 +03:00
|
|
|
.PHONY: tools-clean
|
|
|
|
tools-clean:
|
|
|
|
make -C hack/tools/ clean
|
|
|
|
|
2017-07-26 08:16:18 +03:00
|
|
|
include versioning.mk
|
2017-08-29 04:41:24 +03:00
|
|
|
include test.mk
|
2018-09-12 19:34:30 +03:00
|
|
|
include packer.mk
|