Skip to content

Commit

Permalink
disable location mesh
Browse files Browse the repository at this point in the history
  • Loading branch information
mjudeikis committed Nov 25, 2024
1 parent 472398c commit 646dbea
Showing 1 changed file with 106 additions and 82 deletions.
188 changes: 106 additions & 82 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export GO111MODULE=on
.PHONY: push container clean container-name container-latest push-latest fmt lint test unit gomodtidy generate crds codegen manifest manfest-latest manifest-annotate manifest manfest-latest manifest-annotate release e2e
.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

OS ?= $(shell go env GOOS)
ARCH ?= $(shell go env GOARCH)
Expand Down Expand Up @@ -27,10 +27,10 @@ ifneq ($(TAG),)
endif
DIRTY := $(shell test -z "$$(git diff --shortstat 2>/dev/null)" || echo -dirty)
VERSION := $(VERSION)$(DIRTY)
LD_FLAGS := -buildvcs=false -ldflags '-X $(PKG)/pkg/version.Version=$(VERSION)'
SRC := $(shell find . -type f -name '*.go')
GO_FILES ?= $$(find . -name '*.go')
GO_PKGS ?= $$(go list ./...)
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")

CONTROLLER_GEN_BINARY := bin/controller-gen
CLIENT_GEN_BINARY := bin/client-gen
Expand All @@ -45,68 +45,9 @@ KUBECTL_BINARY := $(shell pwd)/bin/kubectl
BASH_UNIT := $(shell pwd)/bin/bash_unit
BASH_UNIT_FLAGS :=

BUILD_IMAGE ?= golang:1.23.0
BUILD_IMAGE ?= golang:1.19.0
BASE_IMAGE ?= alpine:3.20

GO_INSTALL = ./hack/go-install.sh
TOOLS_DIR=hack/tools
ROOT_DIR=$(abspath .)
TOOLS_GOBIN_DIR := $(abspath $(TOOLS_DIR))
GOBIN_DIR=$(abspath ./bin)
PATH := $(GOBIN_DIR):$(TOOLS_GOBIN_DIR):$(PATH)

# Detect the path used for the install target
ifeq (,$(shell go env GOBIN))
INSTALL_GOBIN=$(shell go env GOPATH)/bin
else
INSTALL_GOBIN=$(shell go env GOBIN)
endif

CONTROLLER_GEN_VER := v0.16.1
CONTROLLER_GEN_BIN := controller-gen
CONTROLLER_GEN := $(TOOLS_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER)
export CONTROLLER_GEN # so hack scripts can use it

YAML_PATCH_VER ?= v0.0.11
YAML_PATCH_BIN := yaml-patch
YAML_PATCH := $(TOOLS_DIR)/$(YAML_PATCH_BIN)-$(YAML_PATCH_VER)
export YAML_PATCH # so hack scripts can use it

OPENSHIFT_GOIMPORTS_VER := c72f1dc2e3aacfa00aece3391d938c9bc734e791
OPENSHIFT_GOIMPORTS_BIN := openshift-goimports
OPENSHIFT_GOIMPORTS := $(TOOLS_DIR)/$(OPENSHIFT_GOIMPORTS_BIN)-$(OPENSHIFT_GOIMPORTS_VER)
export OPENSHIFT_GOIMPORTS # so hack scripts can use i

$(CONTROLLER_GEN):
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) sigs.k8s.io/controller-tools/cmd/controller-gen $(CONTROLLER_GEN_BIN) $(CONTROLLER_GEN_VER)

$(YAML_PATCH):
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/pivotal-cf/yaml-patch/cmd/yaml-patch $(YAML_PATCH_BIN) $(YAML_PATCH_VER)

$(OPENSHIFT_GOIMPORTS):
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/openshift-eng/openshift-goimports $(OPENSHIFT_GOIMPORTS_BIN) $(OPENSHIFT_GOIMPORTS_VER)

crds: $(CONTROLLER_GEN) $(YAML_PATCH) $(OPENSHIFT_GOIMPORTS) ## Generate crds
./hack/update-codegen-crds.sh
.PHONY: crds

tools: $(CONTROLLER_GEN) $(YAML_PATCH) ## Install tools
.PHONY: tool

codegen: crds ## Generate all
go mod download
./hack/update-codegen-clients.sh
$(MAKE) imports
.PHONY: codegen

.PHONY: imports
imports: $(OPENSHIFT_GOIMPORTS)
$(OPENSHIFT_GOIMPORTS) -m github.com/squat/kilo


tools: $(CONTROLLER_GEN) $(YAML_PATCH) $(OPENSHIFT_GOIMPORTS) ## Install tools
.PHONY: tools

build: $(BINS)

build-%:
Expand Down Expand Up @@ -134,7 +75,73 @@ all-container-latest: $(addprefix container-latest-, $(ALL_ARCH))

all-push-latest: $(addprefix push-latest-, $(ALL_ARCH))

generate: codegen crds
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/... \
output:crd:stdout > $@

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
rm -r pkg/k8s/clientset || true
mv $(PKG)/pkg/k8s/clientset pkg/k8s
rm -r github.com || true
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) \
--output-file-base zz_generated.deepcopy
mv $(PKG)/$@ $@ || true
rm -r github.com || true
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
rm -r pkg/k8s/informers || true
mv $(PKG)/pkg/k8s/informers pkg/k8s
rm -r github.com || true
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
rm -r pkg/k8s/listers || true
mv $(PKG)/pkg/k8s/listers pkg/k8s
rm -r github.com || true
go fmt ./pkg/k8s/listers/...

gen-docs: generate docs/api.md docs/kg.md
docs/api.md: pkg/k8s/apis/kilo/v1alpha1/types.go $(DOCS_GEN_BINARY)
$(DOCS_GEN_BINARY) $< > $@

$(BINS): $(SRC) go.mod
@mkdir -p bin/$(word 2,$(subst /, ,$@))/$(word 3,$(subst /, ,$@))
Expand All @@ -149,7 +156,7 @@ $(BINS): $(SRC) go.mod
GOOS=$(word 2,$(subst /, ,$@)) \
GOCACHE=/$(PROJECT)/.cache \
CGO_ENABLED=0 \
go build -o $@ \
go build -mod=vendor -o $@ \
$(LD_FLAGS) \
./cmd/$(@F)/... \
"
Expand All @@ -158,9 +165,9 @@ fmt:
@echo $(GO_PKGS)
gofmt -w -s $(GO_FILES)

lint: $(STATICCHECK_BINARY)
lint: header $(STATICCHECK_BINARY)
@echo 'go vet $(GO_PKGS)'
@vet_res=$$(GO111MODULE=on go vet $(GO_PKGS) 2>&1); if [ -n "$$vet_res" ]; then \
@vet_res=$$(GO111MODULE=on go vet -mod=vendor $(GO_PKGS) 2>&1); if [ -n "$$vet_res" ]; then \
echo ""; \
echo "Go vet found issues. Please check the reported issues"; \
echo "and fix them if necessary before submitting the code for review:"; \
Expand All @@ -185,7 +192,7 @@ lint: $(STATICCHECK_BINARY)
fi

unit:
go test --race ./...
go test -mod=vendor --race ./...

test: lint unit e2e

Expand All @@ -194,15 +201,31 @@ $(KIND_BINARY):
chmod +x $@

$(KUBECTL_BINARY):
curl -Lo $@ https://dl.k8s.io/release/v1.31.0/bin/linux/$(ARCH)/kubectl
curl -Lo $@ https://dl.k8s.io/release/v1.21.0/bin/linux/$(ARCH)/kubectl
chmod +x $@

$(BASH_UNIT):
curl -Lo $@ https://raw.githubusercontent.com/pgrange/bash_unit/v2.3.1/bash_unit
curl -Lo $@ https://raw.githubusercontent.com/pgrange/bash_unit/v1.7.2/bash_unit
chmod +x $@

e2e: container $(KIND_BINARY) $(KUBECTL_BINARY) $(BASH_UNIT) bin/$(OS)/$(ARCH)/kgctl
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/location-mesh.sh ./e2e/multi-cluster.sh ./e2e/handlers.sh ./e2e/kgctl.sh ./e2e/teardown.sh
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/multi-cluster.sh ./e2e/handlers.sh ./e2e/kgctl.sh ./e2e/teardown.sh

header: .header
@HEADER=$$(cat .header); \
HEADER_LEN=$$(wc -l .header | awk '{print $$1}'); \
FILES=; \
for f in $(GO_FILES); do \
for i in 0 1 2 3 4 5; do \
FILE=$$(t=$$(mktemp) && tail -n +$$i $$f > $$t && head -n $$HEADER_LEN $$t | sed "s/[0-9]\{4\}/YEAR/"); \
[ "$$FILE" = "$$HEADER" ] && continue 2; \
done; \
FILES="$$FILES$$f "; \
done; \
if [ -n "$$FILES" ]; then \
printf 'the following files are missing the license header: %s\n' "$$FILES"; \
exit 1; \
fi

tmp/help.txt: bin/$(OS)/$(ARCH)/kg
mkdir -p tmp
Expand Down Expand Up @@ -313,29 +336,30 @@ container-clean:
bin-clean:
rm -rf bin

gomodtidy:
vendor:
go mod tidy
go mod vendor

$(CONTROLLER_GEN_BINARY):
go build -o $@ sigs.k8s.io/controller-tools/cmd/controller-gen
go build -mod=vendor -o $@ sigs.k8s.io/controller-tools/cmd/controller-gen

$(CLIENT_GEN_BINARY):
go build -o $@ k8s.io/code-generator/cmd/client-gen
go build -mod=vendor -o $@ k8s.io/code-generator/cmd/client-gen

$(DEEPCOPY_GEN_BINARY):
go build -o $@ k8s.io/code-generator/cmd/deepcopy-gen
go build -mod=vendor -o $@ k8s.io/code-generator/cmd/deepcopy-gen

$(INFORMER_GEN_BINARY):
go build -o $@ k8s.io/code-generator/cmd/informer-gen
go build -mod=vendor -o $@ k8s.io/code-generator/cmd/informer-gen

$(LISTER_GEN_BINARY):
go build -o $@ k8s.io/code-generator/cmd/lister-gen
go build -mod=vendor -o $@ k8s.io/code-generator/cmd/lister-gen

$(DOCS_GEN_BINARY): cmd/docs-gen/main.go
go build -o $@ ./cmd/docs-gen
go build -mod=vendor -o $@ ./cmd/docs-gen

$(STATICCHECK_BINARY):
go build -o $@ honnef.co/go/tools/cmd/staticcheck
go build -mod=vendor -o $@ honnef.co/go/tools/cmd/staticcheck

$(EMBEDMD_BINARY):
go build -o $@ github.com/campoy/embedmd
go build -mod=vendor -o $@ github.com/campoy/embedmd

0 comments on commit 646dbea

Please sign in to comment.