2019-05-03 11:03:39 +00:00
|
|
|
export GO111MODULE=on
|
2021-06-14 07:08:46 +00:00
|
|
|
.PHONY: push container clean container-name container-latest push-latest fmt lint test unit vendor header generate crd client deepcopy informer lister manifest manfest-latest manifest-annotate manifest manfest-latest manifest-annotate release gen-docs e2e
|
2019-01-18 01:50:10 +00:00
|
|
|
|
2020-11-13 17:36:07 +00:00
|
|
|
OS ?= $(shell go env GOOS)
|
|
|
|
ARCH ?= $(shell go env GOARCH)
|
2019-05-16 17:07:58 +00:00
|
|
|
ALL_ARCH := amd64 arm arm64
|
2020-01-08 16:10:06 +00:00
|
|
|
DOCKER_ARCH := "amd64" "arm v7" "arm64 v8"
|
2020-11-13 17:36:07 +00:00
|
|
|
ifeq ($(OS),linux)
|
|
|
|
BINS := bin/$(OS)/$(ARCH)/kg bin/$(OS)/$(ARCH)/kgctl
|
|
|
|
else
|
|
|
|
BINS := bin/$(OS)/$(ARCH)/kgctl
|
|
|
|
endif
|
2021-06-14 10:56:20 +00:00
|
|
|
RELEASE_BINS := $(addprefix bin/release/kgctl-, $(addprefix linux-, $(ALL_ARCH)) darwin-amd64 darwin-arm64 windows-amd64)
|
2019-01-18 01:50:10 +00:00
|
|
|
PROJECT := kilo
|
|
|
|
PKG := github.com/squat/$(PROJECT)
|
|
|
|
REGISTRY ?= index.docker.io
|
|
|
|
IMAGE ?= squat/$(PROJECT)
|
2021-05-11 14:17:25 +00:00
|
|
|
FULLY_QUALIFIED_IMAGE := $(REGISTRY)/$(IMAGE)
|
2019-01-18 01:50:10 +00:00
|
|
|
|
|
|
|
TAG := $(shell git describe --abbrev=0 --tags HEAD 2>/dev/null)
|
|
|
|
COMMIT := $(shell git rev-parse HEAD)
|
|
|
|
VERSION := $(COMMIT)
|
|
|
|
ifneq ($(TAG),)
|
|
|
|
ifeq ($(COMMIT), $(shell git rev-list -n1 $(TAG)))
|
|
|
|
VERSION := $(TAG)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
DIRTY := $(shell test -z "$$(git diff --shortstat 2>/dev/null)" || echo -dirty)
|
|
|
|
VERSION := $(VERSION)$(DIRTY)
|
|
|
|
LD_FLAGS := -ldflags '-X $(PKG)/pkg/version.Version=$(VERSION)'
|
|
|
|
SRC := $(shell find . -type f -name '*.go' -not -path "./vendor/*")
|
|
|
|
GO_FILES ?= $$(find . -name '*.go' -not -path './vendor/*')
|
|
|
|
GO_PKGS ?= $$(go list ./... | grep -v "$(PKG)/vendor")
|
|
|
|
|
2021-06-14 07:08:46 +00:00
|
|
|
CONTROLLER_GEN_BINARY := bin/controller-gen
|
2019-05-16 22:23:51 +00:00
|
|
|
CLIENT_GEN_BINARY := bin/client-gen
|
2021-05-17 07:55:45 +00:00
|
|
|
DOCS_GEN_BINARY := bin/docs-gen
|
2019-05-16 22:23:51 +00:00
|
|
|
DEEPCOPY_GEN_BINARY := bin/deepcopy-gen
|
|
|
|
INFORMER_GEN_BINARY := bin/informer-gen
|
|
|
|
LISTER_GEN_BINARY := bin/lister-gen
|
2022-05-19 17:45:43 +00:00
|
|
|
STATICCHECK_BINARY := bin/staticcheck
|
2020-09-23 08:54:19 +00:00
|
|
|
EMBEDMD_BINARY := bin/embedmd
|
2021-05-20 08:38:11 +00:00
|
|
|
KIND_BINARY := $(shell pwd)/bin/kind
|
|
|
|
KUBECTL_BINARY := $(shell pwd)/bin/kubectl
|
|
|
|
BASH_UNIT := $(shell pwd)/bin/bash_unit
|
2021-07-06 18:45:53 +00:00
|
|
|
BASH_UNIT_FLAGS :=
|
2019-05-03 10:53:40 +00:00
|
|
|
|
2022-05-19 17:45:43 +00:00
|
|
|
BUILD_IMAGE ?= golang:1.18.0
|
2022-04-21 19:20:09 +00:00
|
|
|
BASE_IMAGE ?= alpine:3.15
|
2019-01-18 01:50:10 +00:00
|
|
|
|
|
|
|
build: $(BINS)
|
|
|
|
|
2019-05-16 17:07:58 +00:00
|
|
|
build-%:
|
2020-11-13 17:36:07 +00:00
|
|
|
@$(MAKE) --no-print-directory OS=$(word 1,$(subst -, ,$*)) ARCH=$(word 2,$(subst -, ,$*)) build
|
2019-05-16 17:07:58 +00:00
|
|
|
|
|
|
|
container-latest-%:
|
|
|
|
@$(MAKE) --no-print-directory ARCH=$* container-latest
|
|
|
|
|
|
|
|
container-%:
|
|
|
|
@$(MAKE) --no-print-directory ARCH=$* container
|
|
|
|
|
|
|
|
push-latest-%:
|
|
|
|
@$(MAKE) --no-print-directory ARCH=$* push-latest
|
|
|
|
|
|
|
|
push-%:
|
|
|
|
@$(MAKE) --no-print-directory ARCH=$* push
|
|
|
|
|
2020-11-23 10:16:35 +00:00
|
|
|
all-build: $(addprefix build-$(OS)-, $(ALL_ARCH))
|
2019-05-16 17:07:58 +00:00
|
|
|
|
|
|
|
all-container: $(addprefix container-, $(ALL_ARCH))
|
|
|
|
|
|
|
|
all-push: $(addprefix push-, $(ALL_ARCH))
|
|
|
|
|
|
|
|
all-container-latest: $(addprefix container-latest-, $(ALL_ARCH))
|
|
|
|
|
|
|
|
all-push-latest: $(addprefix push-latest-, $(ALL_ARCH))
|
|
|
|
|
2021-06-14 07:08:46 +00:00
|
|
|
generate: client deepcopy informer lister crd
|
|
|
|
|
|
|
|
crd: manifests/crds.yaml
|
|
|
|
manifests/crds.yaml: pkg/k8s/apis/kilo/v1alpha1/types.go $(CONTROLLER_GEN_BINARY)
|
|
|
|
$(CONTROLLER_GEN_BINARY) crd \
|
|
|
|
paths=./pkg/k8s/apis/kilo/... \
|
2022-04-23 09:35:10 +00:00
|
|
|
output:crd:stdout > $@
|
2019-05-03 10:53:40 +00:00
|
|
|
|
|
|
|
client: pkg/k8s/clientset/versioned/typed/kilo/v1alpha1/peer.go
|
|
|
|
pkg/k8s/clientset/versioned/typed/kilo/v1alpha1/peer.go: .header pkg/k8s/apis/kilo/v1alpha1/types.go $(CLIENT_GEN_BINARY)
|
|
|
|
$(CLIENT_GEN_BINARY) \
|
|
|
|
--clientset-name versioned \
|
|
|
|
--input-base "" \
|
|
|
|
--input $(PKG)/pkg/k8s/apis/kilo/v1alpha1 \
|
|
|
|
--output-base $(CURDIR) \
|
|
|
|
--output-package $(PKG)/pkg/k8s/clientset \
|
|
|
|
--go-header-file=.header \
|
|
|
|
--logtostderr
|
2019-05-16 22:23:51 +00:00
|
|
|
rm -r pkg/k8s/clientset || true
|
2019-05-03 10:53:40 +00:00
|
|
|
mv $(PKG)/pkg/k8s/clientset pkg/k8s
|
2019-05-16 22:23:51 +00:00
|
|
|
rm -r github.com || true
|
2019-05-03 10:53:40 +00:00
|
|
|
go fmt ./pkg/k8s/clientset/...
|
|
|
|
|
|
|
|
deepcopy: pkg/k8s/apis/kilo/v1alpha1/zz_generated.deepcopy.go
|
|
|
|
pkg/k8s/apis/kilo/v1alpha1/zz_generated.deepcopy.go: .header pkg/k8s/apis/kilo/v1alpha1/types.go $(DEEPCOPY_GEN_BINARY)
|
|
|
|
$(DEEPCOPY_GEN_BINARY) \
|
|
|
|
--input-dirs ./$(@D) \
|
|
|
|
--go-header-file=.header \
|
|
|
|
--logtostderr \
|
|
|
|
--output-base $(CURDIR) \
|
2019-05-03 11:03:39 +00:00
|
|
|
--output-file-base zz_generated.deepcopy
|
|
|
|
mv $(PKG)/$@ $@ || true
|
|
|
|
rm -r github.com || true
|
2019-05-03 10:53:40 +00:00
|
|
|
go fmt $@
|
|
|
|
|
|
|
|
informer: pkg/k8s/informers/kilo/v1alpha1/peer.go
|
|
|
|
pkg/k8s/informers/kilo/v1alpha1/peer.go: .header pkg/k8s/apis/kilo/v1alpha1/types.go $(INFORMER_GEN_BINARY)
|
|
|
|
$(INFORMER_GEN_BINARY) \
|
|
|
|
--input-dirs $(PKG)/pkg/k8s/apis/kilo/v1alpha1 \
|
|
|
|
--go-header-file=.header \
|
|
|
|
--logtostderr \
|
|
|
|
--versioned-clientset-package $(PKG)/pkg/k8s/clientset/versioned \
|
|
|
|
--listers-package $(PKG)/pkg/k8s/listers \
|
|
|
|
--output-base $(CURDIR) \
|
|
|
|
--output-package $(PKG)/pkg/k8s/informers \
|
|
|
|
--single-directory
|
2019-05-16 22:23:51 +00:00
|
|
|
rm -r pkg/k8s/informers || true
|
2019-05-03 10:53:40 +00:00
|
|
|
mv $(PKG)/pkg/k8s/informers pkg/k8s
|
2019-05-16 22:23:51 +00:00
|
|
|
rm -r github.com || true
|
2019-05-03 10:53:40 +00:00
|
|
|
go fmt ./pkg/k8s/informers/...
|
|
|
|
|
|
|
|
lister: pkg/k8s/listers/kilo/v1alpha1/peer.go
|
|
|
|
pkg/k8s/listers/kilo/v1alpha1/peer.go: .header pkg/k8s/apis/kilo/v1alpha1/types.go $(LISTER_GEN_BINARY)
|
|
|
|
$(LISTER_GEN_BINARY) \
|
|
|
|
--input-dirs $(PKG)/pkg/k8s/apis/kilo/v1alpha1 \
|
|
|
|
--go-header-file=.header \
|
|
|
|
--logtostderr \
|
|
|
|
--output-base $(CURDIR) \
|
|
|
|
--output-package $(PKG)/pkg/k8s/listers
|
2019-05-16 22:23:51 +00:00
|
|
|
rm -r pkg/k8s/listers || true
|
2019-05-03 10:53:40 +00:00
|
|
|
mv $(PKG)/pkg/k8s/listers pkg/k8s
|
2019-05-16 22:23:51 +00:00
|
|
|
rm -r github.com || true
|
2019-05-03 10:53:40 +00:00
|
|
|
go fmt ./pkg/k8s/listers/...
|
|
|
|
|
2022-04-20 14:11:07 +00:00
|
|
|
gen-docs: generate docs/api.md docs/kg.md
|
2021-05-17 07:55:45 +00:00
|
|
|
docs/api.md: pkg/k8s/apis/kilo/v1alpha1/types.go $(DOCS_GEN_BINARY)
|
|
|
|
$(DOCS_GEN_BINARY) $< > $@
|
|
|
|
|
2019-01-18 01:50:10 +00:00
|
|
|
$(BINS): $(SRC) go.mod
|
2020-11-23 09:18:08 +00:00
|
|
|
@mkdir -p bin/$(word 2,$(subst /, ,$@))/$(word 3,$(subst /, ,$@))
|
2019-01-18 01:50:10 +00:00
|
|
|
@echo "building: $@"
|
|
|
|
@docker run --rm \
|
|
|
|
-u $$(id -u):$$(id -g) \
|
|
|
|
-v $$(pwd):/$(PROJECT) \
|
|
|
|
-w /$(PROJECT) \
|
|
|
|
$(BUILD_IMAGE) \
|
|
|
|
/bin/sh -c " \
|
2020-11-23 09:18:08 +00:00
|
|
|
GOARCH=$(word 3,$(subst /, ,$@)) \
|
|
|
|
GOOS=$(word 2,$(subst /, ,$@)) \
|
2019-03-20 23:27:40 +00:00
|
|
|
GOCACHE=/$(PROJECT)/.cache \
|
2019-01-18 01:50:10 +00:00
|
|
|
CGO_ENABLED=0 \
|
|
|
|
go build -mod=vendor -o $@ \
|
|
|
|
$(LD_FLAGS) \
|
|
|
|
./cmd/$(@F)/... \
|
|
|
|
"
|
|
|
|
|
|
|
|
fmt:
|
|
|
|
@echo $(GO_PKGS)
|
|
|
|
gofmt -w -s $(GO_FILES)
|
|
|
|
|
2022-05-19 17:45:43 +00:00
|
|
|
lint: header $(STATICCHECK_BINARY)
|
2019-01-18 01:50:10 +00:00
|
|
|
@echo 'go vet $(GO_PKGS)'
|
2019-02-06 16:26:44 +00:00
|
|
|
@vet_res=$$(GO111MODULE=on go vet -mod=vendor $(GO_PKGS) 2>&1); if [ -n "$$vet_res" ]; then \
|
2019-01-18 01:50:10 +00:00
|
|
|
echo ""; \
|
|
|
|
echo "Go vet found issues. Please check the reported issues"; \
|
|
|
|
echo "and fix them if necessary before submitting the code for review:"; \
|
|
|
|
echo "$$vet_res"; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
2022-05-19 17:45:43 +00:00
|
|
|
@echo '$(STATICCHECK_BINARY) $(GO_PKGS)'
|
|
|
|
@lint_res=$$($(STATICCHECK_BINARY) $(GO_PKGS)); if [ -n "$$lint_res" ]; then \
|
2019-01-18 01:50:10 +00:00
|
|
|
echo ""; \
|
2022-05-19 17:45:43 +00:00
|
|
|
echo "Staticcheck found style issues. Please check the reported issues"; \
|
2019-01-18 01:50:10 +00:00
|
|
|
echo "and fix them if necessary before submitting the code for review:"; \
|
|
|
|
echo "$$lint_res"; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
@echo 'gofmt -d -s $(GO_FILES)'
|
|
|
|
@fmt_res=$$(gofmt -d -s $(GO_FILES)); if [ -n "$$fmt_res" ]; then \
|
|
|
|
echo ""; \
|
|
|
|
echo "Gofmt found style issues. Please check the reported issues"; \
|
|
|
|
echo "and fix them if necessary before submitting the code for review:"; \
|
|
|
|
echo "$$fmt_res"; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
unit:
|
2019-02-06 16:26:44 +00:00
|
|
|
go test -mod=vendor --race ./...
|
2019-01-18 01:50:10 +00:00
|
|
|
|
2021-05-20 08:38:11 +00:00
|
|
|
test: lint unit e2e
|
|
|
|
|
|
|
|
$(KIND_BINARY):
|
2021-07-05 17:16:30 +00:00
|
|
|
curl -Lo $@ https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-$(ARCH)
|
2021-05-20 08:38:11 +00:00
|
|
|
chmod +x $@
|
|
|
|
|
|
|
|
$(KUBECTL_BINARY):
|
|
|
|
curl -Lo $@ https://dl.k8s.io/release/v1.21.0/bin/linux/$(ARCH)/kubectl
|
|
|
|
chmod +x $@
|
|
|
|
|
|
|
|
$(BASH_UNIT):
|
2021-06-15 10:54:27 +00:00
|
|
|
curl -Lo $@ https://raw.githubusercontent.com/pgrange/bash_unit/v1.7.2/bash_unit
|
2021-05-20 08:38:11 +00:00
|
|
|
chmod +x $@
|
|
|
|
|
2021-06-15 18:38:21 +00:00
|
|
|
e2e: container $(KIND_BINARY) $(KUBECTL_BINARY) $(BASH_UNIT) bin/$(OS)/$(ARCH)/kgctl
|
2022-04-08 11:42:13 +00:00
|
|
|
KILO_IMAGE=$(IMAGE):$(ARCH)-$(VERSION) KIND_BINARY=$(KIND_BINARY) KUBECTL_BINARY=$(KUBECTL_BINARY) KGCTL_BINARY=$(shell pwd)/bin/$(OS)/$(ARCH)/kgctl $(BASH_UNIT) $(BASH_UNIT_FLAGS) ./e2e/setup.sh ./e2e/full-mesh.sh ./e2e/location-mesh.sh ./e2e/multi-cluster.sh ./e2e/handlers.sh ./e2e/kgctl.sh ./e2e/teardown.sh
|
2019-01-18 01:50:10 +00:00
|
|
|
|
|
|
|
header: .header
|
2020-01-07 14:07:34 +00:00
|
|
|
@HEADER=$$(cat .header); \
|
2019-05-03 10:53:40 +00:00
|
|
|
HEADER_LEN=$$(wc -l .header | awk '{print $$1}'); \
|
2019-01-18 01:50:10 +00:00
|
|
|
FILES=; \
|
|
|
|
for f in $(GO_FILES); do \
|
2019-05-03 10:53:40 +00:00
|
|
|
for i in 0 1 2 3 4 5; do \
|
2021-01-30 20:26:46 +00:00
|
|
|
FILE=$$(t=$$(mktemp) && tail -n +$$i $$f > $$t && head -n $$HEADER_LEN $$t | sed "s/[0-9]\{4\}/YEAR/"); \
|
2019-05-03 10:53:40 +00:00
|
|
|
[ "$$FILE" = "$$HEADER" ] && continue 2; \
|
|
|
|
done; \
|
|
|
|
FILES="$$FILES$$f "; \
|
2019-01-18 01:50:10 +00:00
|
|
|
done; \
|
|
|
|
if [ -n "$$FILES" ]; then \
|
|
|
|
printf 'the following files are missing the license header: %s\n' "$$FILES"; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
|
2020-11-13 17:36:07 +00:00
|
|
|
tmp/help.txt: bin/$(OS)/$(ARCH)/kg
|
2020-09-23 08:54:19 +00:00
|
|
|
mkdir -p tmp
|
2020-11-13 17:36:07 +00:00
|
|
|
bin//$(OS)/$(ARCH)/kg --help 2>&1 | head -n -1 > $@
|
2020-09-23 08:54:19 +00:00
|
|
|
|
|
|
|
docs/kg.md: $(EMBEDMD_BINARY) tmp/help.txt
|
|
|
|
$(EMBEDMD_BINARY) -w $@
|
|
|
|
|
2020-03-09 22:17:32 +00:00
|
|
|
website/docs/README.md: README.md
|
|
|
|
rm -rf website/static/img/graphs
|
2020-03-09 23:36:18 +00:00
|
|
|
find docs -type f -name '*.md' | xargs -I{} sh -c 'cat $(@D)/$$(basename {} .md) > website/{}'
|
|
|
|
find docs -type f -name '*.md' | xargs -I{} sh -c 'cat {} >> website/{}'
|
|
|
|
cat $(@D)/$$(basename $@ .md) > $@
|
|
|
|
cat README.md >> $@
|
2020-03-09 22:17:32 +00:00
|
|
|
cp -r docs/graphs website/static/img/
|
|
|
|
sed -i 's/\.\/docs\///g' $@
|
2021-10-20 20:25:05 +00:00
|
|
|
find $(@D) -type f -name '*.md' | xargs -I{} sed -i 's/\.\/\(.\+\.\(svg\|png\)\)/\/img\/\1/g' {}
|
2020-03-09 22:17:32 +00:00
|
|
|
sed -i 's/graphs\//\/img\/graphs\//g' $@
|
2021-05-21 12:23:10 +00:00
|
|
|
# The next line is a workaround until mdx, docusaurus' markdown parser, can parse links with preceding brackets.
|
|
|
|
sed -i 's/\[\]\(\[.*\](.*)\)/\[\]\1/g' website/docs/api.md
|
2020-03-09 22:17:32 +00:00
|
|
|
|
2021-05-17 07:55:45 +00:00
|
|
|
website/build/index.html: website/docs/README.md docs/api.md
|
2020-03-09 22:17:32 +00:00
|
|
|
yarn --cwd website install
|
|
|
|
yarn --cwd website build
|
|
|
|
|
2019-05-16 17:07:58 +00:00
|
|
|
container: .container-$(ARCH)-$(VERSION) container-name
|
2020-11-13 17:36:07 +00:00
|
|
|
.container-$(ARCH)-$(VERSION): bin/linux/$(ARCH)/kg Dockerfile
|
2019-05-16 17:07:58 +00:00
|
|
|
@i=0; for a in $(ALL_ARCH); do [ "$$a" = $(ARCH) ] && break; i=$$((i+1)); done; \
|
2020-01-08 16:10:06 +00:00
|
|
|
ia=""; iv=""; \
|
|
|
|
j=0; for a in $(DOCKER_ARCH); do \
|
|
|
|
[ "$$i" -eq "$$j" ] && ia=$$(echo "$$a" | awk '{print $$1}') && iv=$$(echo "$$a" | awk '{print $$2}') && break; j=$$((j+1)); \
|
|
|
|
done; \
|
|
|
|
SHA=$$(docker manifest inspect $(BASE_IMAGE) | jq '.manifests[] | select(.platform.architecture == "'$$ia'") | if .platform | has("variant") then select(.platform.variant == "'$$iv'") else . end | .digest' -r); \
|
|
|
|
docker build -t $(IMAGE):$(ARCH)-$(VERSION) --build-arg FROM=$(BASE_IMAGE)@$$SHA --build-arg GOARCH=$(ARCH) .
|
2019-05-16 17:07:58 +00:00
|
|
|
@docker images -q $(IMAGE):$(ARCH)-$(VERSION) > $@
|
2019-01-18 01:50:10 +00:00
|
|
|
|
2019-05-16 17:07:58 +00:00
|
|
|
container-latest: .container-$(ARCH)-$(VERSION)
|
2021-05-11 14:17:25 +00:00
|
|
|
@docker tag $(IMAGE):$(ARCH)-$(VERSION) $(FULLY_QUALIFIED_IMAGE):$(ARCH)-latest
|
2019-05-16 17:07:58 +00:00
|
|
|
@echo "container: $(IMAGE):$(ARCH)-latest"
|
2019-01-18 01:50:10 +00:00
|
|
|
|
|
|
|
container-name:
|
2019-05-16 17:07:58 +00:00
|
|
|
@echo "container: $(IMAGE):$(ARCH)-$(VERSION)"
|
|
|
|
|
|
|
|
manifest: .manifest-$(VERSION) manifest-name
|
|
|
|
.manifest-$(VERSION): Dockerfile $(addprefix push-, $(ALL_ARCH))
|
2021-04-15 19:12:10 +00:00
|
|
|
@docker manifest create --amend $(FULLY_QUALIFIED_IMAGE):$(VERSION) $(addsuffix -$(VERSION), $(addprefix $(FULLY_QUALIFIED_IMAGE):, $(ALL_ARCH)))
|
2019-09-19 22:56:25 +00:00
|
|
|
@$(MAKE) --no-print-directory manifest-annotate-$(VERSION)
|
2021-04-15 19:12:10 +00:00
|
|
|
@docker manifest push $(FULLY_QUALIFIED_IMAGE):$(VERSION) > $@
|
2019-05-16 17:07:58 +00:00
|
|
|
|
2019-09-19 22:56:25 +00:00
|
|
|
manifest-latest: Dockerfile $(addprefix push-latest-, $(ALL_ARCH))
|
2021-04-15 19:12:10 +00:00
|
|
|
@docker manifest rm $(FULLY_QUALIFIED_IMAGE):latest || echo no old manifest
|
|
|
|
@docker manifest create --amend $(FULLY_QUALIFIED_IMAGE):latest $(addsuffix -latest, $(addprefix $(FULLY_QUALIFIED_IMAGE):, $(ALL_ARCH)))
|
2019-09-19 22:56:25 +00:00
|
|
|
@$(MAKE) --no-print-directory manifest-annotate-latest
|
2021-04-15 19:12:10 +00:00
|
|
|
@docker manifest push $(FULLY_QUALIFIED_IMAGE):latest
|
2019-05-16 17:07:58 +00:00
|
|
|
@echo "manifest: $(IMAGE):latest"
|
|
|
|
|
2019-09-19 22:56:25 +00:00
|
|
|
manifest-annotate: manifest-annotate-$(VERSION)
|
|
|
|
|
|
|
|
manifest-annotate-%:
|
2019-05-16 17:07:58 +00:00
|
|
|
@i=0; \
|
|
|
|
for a in $(ALL_ARCH); do \
|
|
|
|
annotate=; \
|
|
|
|
j=0; for da in $(DOCKER_ARCH); do \
|
|
|
|
if [ "$$j" -eq "$$i" ] && [ -n "$$da" ]; then \
|
2021-04-15 19:12:10 +00:00
|
|
|
annotate="docker manifest annotate $(FULLY_QUALIFIED_IMAGE):$* $(FULLY_QUALIFIED_IMAGE):$$a-$* --os linux --arch"; \
|
2019-05-16 17:07:58 +00:00
|
|
|
k=0; for ea in $$da; do \
|
|
|
|
[ "$$k" = 0 ] && annotate="$$annotate $$ea"; \
|
|
|
|
[ "$$k" != 0 ] && annotate="$$annotate --variant $$ea"; \
|
|
|
|
k=$$((k+1)); \
|
|
|
|
done; \
|
|
|
|
$$annotate; \
|
|
|
|
fi; \
|
|
|
|
j=$$((j+1)); \
|
|
|
|
done; \
|
|
|
|
i=$$((i+1)); \
|
|
|
|
done
|
|
|
|
|
|
|
|
manifest-name:
|
2021-04-15 19:12:10 +00:00
|
|
|
@echo "manifest: $(IMAGE):$(VERSION)"
|
2019-05-16 17:07:58 +00:00
|
|
|
|
|
|
|
push: .push-$(ARCH)-$(VERSION) push-name
|
|
|
|
.push-$(ARCH)-$(VERSION): .container-$(ARCH)-$(VERSION)
|
2021-05-11 14:17:25 +00:00
|
|
|
ifneq ($(REGISTRY),index.docker.io)
|
|
|
|
@docker tag $(IMAGE):$(ARCH)-$(VERSION) $(FULLY_QUALIFIED_IMAGE):$(ARCH)-$(VERSION)
|
2021-04-15 19:12:10 +00:00
|
|
|
endif
|
2021-05-11 14:17:25 +00:00
|
|
|
@docker push $(FULLY_QUALIFIED_IMAGE):$(ARCH)-$(VERSION)
|
2019-05-16 17:07:58 +00:00
|
|
|
@docker images -q $(IMAGE):$(ARCH)-$(VERSION) > $@
|
2019-01-18 01:50:10 +00:00
|
|
|
|
|
|
|
push-latest: container-latest
|
2021-05-11 14:17:25 +00:00
|
|
|
@docker push $(FULLY_QUALIFIED_IMAGE):$(ARCH)-latest
|
2019-05-16 17:07:58 +00:00
|
|
|
@echo "pushed: $(IMAGE):$(ARCH)-latest"
|
2019-01-18 01:50:10 +00:00
|
|
|
|
|
|
|
push-name:
|
2019-05-16 17:07:58 +00:00
|
|
|
@echo "pushed: $(IMAGE):$(ARCH)-$(VERSION)"
|
2019-01-18 01:50:10 +00:00
|
|
|
|
2021-02-13 16:11:56 +00:00
|
|
|
release: $(RELEASE_BINS)
|
|
|
|
$(RELEASE_BINS):
|
|
|
|
@make OS=$(word 2,$(subst -, ,$(@F))) ARCH=$(word 3,$(subst -, ,$(@F)))
|
|
|
|
mkdir -p $(@D)
|
|
|
|
cp bin/$(word 2,$(subst -, ,$(@F)))/$(word 3,$(subst -, ,$(@F)))/kgctl $@
|
|
|
|
|
2019-01-18 01:50:10 +00:00
|
|
|
clean: container-clean bin-clean
|
2020-01-08 17:05:27 +00:00
|
|
|
rm -rf .cache
|
2019-01-18 01:50:10 +00:00
|
|
|
|
|
|
|
container-clean:
|
2020-01-08 17:05:27 +00:00
|
|
|
rm -rf .container-* .manifest-* .push-*
|
2019-01-18 01:50:10 +00:00
|
|
|
|
|
|
|
bin-clean:
|
|
|
|
rm -rf bin
|
|
|
|
|
|
|
|
vendor:
|
|
|
|
go mod tidy
|
|
|
|
go mod vendor
|
2019-05-03 10:53:40 +00:00
|
|
|
|
2021-06-14 07:08:46 +00:00
|
|
|
$(CONTROLLER_GEN_BINARY):
|
|
|
|
go build -mod=vendor -o $@ sigs.k8s.io/controller-tools/cmd/controller-gen
|
|
|
|
|
2019-05-03 10:53:40 +00:00
|
|
|
$(CLIENT_GEN_BINARY):
|
2019-05-16 22:23:51 +00:00
|
|
|
go build -mod=vendor -o $@ k8s.io/code-generator/cmd/client-gen
|
2019-05-03 10:53:40 +00:00
|
|
|
|
|
|
|
$(DEEPCOPY_GEN_BINARY):
|
2019-05-16 22:23:51 +00:00
|
|
|
go build -mod=vendor -o $@ k8s.io/code-generator/cmd/deepcopy-gen
|
2019-05-03 10:53:40 +00:00
|
|
|
|
|
|
|
$(INFORMER_GEN_BINARY):
|
2019-05-16 22:23:51 +00:00
|
|
|
go build -mod=vendor -o $@ k8s.io/code-generator/cmd/informer-gen
|
2019-05-03 10:53:40 +00:00
|
|
|
|
|
|
|
$(LISTER_GEN_BINARY):
|
2019-05-16 22:23:51 +00:00
|
|
|
go build -mod=vendor -o $@ k8s.io/code-generator/cmd/lister-gen
|
2019-05-03 10:53:40 +00:00
|
|
|
|
2021-05-20 10:45:02 +00:00
|
|
|
$(DOCS_GEN_BINARY): cmd/docs-gen/main.go
|
|
|
|
go build -mod=vendor -o $@ ./cmd/docs-gen
|
2021-05-17 07:55:45 +00:00
|
|
|
|
2022-05-19 17:45:43 +00:00
|
|
|
$(STATICCHECK_BINARY):
|
|
|
|
go build -mod=vendor -o $@ honnef.co/go/tools/cmd/staticcheck
|
2020-09-23 08:54:19 +00:00
|
|
|
|
|
|
|
$(EMBEDMD_BINARY):
|
|
|
|
go build -mod=vendor -o $@ github.com/campoy/embedmd
|