kubectl-az/Makefile

94 строки
2.3 KiB
Makefile
Исходник Обычный вид История

2022-01-18 18:49:54 +03:00
GOHOSTOS ?= $(shell go env GOHOSTOS)
GOHOSTARCH ?= $(shell go env GOHOSTARCH)
TAG := `git describe --tags --always`
VERSION :=
2023-07-06 13:24:40 +03:00
AZURE_SUBSCRIPTION_ID ?= $(shell az account show --query id -o tsv)
AZURE_RESOURCE_GROUP ?=
AZURE_CLUSTER_NAME ?=
2022-01-18 18:49:54 +03:00
# Adds a '-dirty' suffix to version string if there are uncommitted changes
changes := $(shell git status --porcelain)
ifeq ($(changes),)
VERSION := $(TAG)
else
VERSION := $(TAG)-dirty
endif
2023-06-05 16:54:08 +03:00
LINTER_VERSION ?= v1.53.2
2023-04-20 12:16:57 +03:00
LDFLAGS := "-X github.com/Azure/kubectl-aks/cmd.version=$(VERSION) -extldflags '-static'"
2022-01-18 18:49:54 +03:00
2023-04-20 12:16:57 +03:00
.DEFAULT_GOAL := kubectl-aks
2022-01-18 18:49:54 +03:00
# Build
2023-04-20 12:16:57 +03:00
KUBECTL_AKS_TARGETS = \
kubectl-aks-linux-amd64 \
kubectl-aks-linux-arm64 \
kubectl-aks-darwin-amd64 \
kubectl-aks-darwin-arm64 \
kubectl-aks-windows-amd64
2022-01-18 18:49:54 +03:00
2023-04-20 12:16:57 +03:00
.PHONY: list-kubectl-aks-targets
list-kubectl-aks-targets:
@echo $(KUBECTL_AKS_TARGETS)
2022-01-18 18:49:54 +03:00
2023-04-20 12:16:57 +03:00
.PHONY: kubectl-aks-all
kubectl-aks-all: $(KUBECTL_AKS_TARGETS)
2022-01-18 18:49:54 +03:00
2023-04-20 12:16:57 +03:00
.PHONY: kubectl-aks
kubectl-aks: kubectl-aks-$(GOHOSTOS)-$(GOHOSTARCH)
mv kubectl-aks-$(GOHOSTOS)-$(GOHOSTARCH) kubectl-aks
2022-01-18 18:49:54 +03:00
# make does not allow implicit rules (with '%') to be phony so let's use
# the 'phony_explicit' dependency to make implicit rules inherit the phony
# attribute
.PHONY: phony_explicit
phony_explicit:
2023-04-20 12:16:57 +03:00
.PHONY: kubectl-aks-%
kubectl-aks-%: phony_explicit
2022-01-18 18:49:54 +03:00
export GO111MODULE=on CGO_ENABLED=0 && \
export GOOS=$(shell echo $* |cut -f1 -d-) GOARCH=$(shell echo $* |cut -f2 -d-) && \
go build -ldflags $(LDFLAGS) \
2023-04-20 12:16:57 +03:00
-o kubectl-aks-$${GOOS}-$${GOARCH} \
github.com/Azure/kubectl-aks
2022-01-18 18:49:54 +03:00
2023-06-05 16:54:08 +03:00
# Lint
.PHONY: lint
lint:
docker run --rm --env XDG_CACHE_HOME=/tmp/xdg_home_cache \
--env GOLANGCI_LINT_CACHE=/tmp/golangci_lint_cache \
--user $(shell id -u):$(shell id -g) -v $(shell pwd):/app -w /app \
golangci/golangci-lint:$(LINTER_VERSION) golangci-lint run
# Install
2022-01-18 18:49:54 +03:00
.PHONY: install
2023-04-20 12:16:57 +03:00
install: kubectl-aks
2022-01-18 18:49:54 +03:00
mkdir -p ~/.local/bin/
2023-04-20 12:16:57 +03:00
cp kubectl-aks ~/.local/bin/
2022-01-18 18:49:54 +03:00
# Run unit tests
.PHONY: unit-test
unit-test:
go test -v ./...
# Run integration tests
.PHONY: integration-test
2023-04-20 12:16:57 +03:00
integration-test: kubectl-aks
KUBECTL_AKS="$(shell pwd)/kubectl-aks" \
2023-07-06 13:24:40 +03:00
AZURE_SUBSCRIPTION_ID=$(AZURE_SUBSCRIPTION_ID) \
AZURE_RESOURCE_GROUP=$(AZURE_RESOURCE_GROUP) \
AZURE_CLUSTER_NAME=$(AZURE_CLUSTER_NAME) \
go test -v ./test/integration/... -integration
# Clean
2022-01-18 18:49:54 +03:00
.PHONY: clean
clean:
2023-04-20 12:16:57 +03:00
rm -f kubectl-aks
2022-01-18 18:49:54 +03:00
.PHONY: cleanall
cleanall: clean
2023-04-20 12:16:57 +03:00
rm -f $(KUBECTL_AKS_TARGETS)