From b4ba1835fd6f68f6c329ec2a0ac618a132be07d6 Mon Sep 17 00:00:00 2001 From: ccremer Date: Mon, 8 Aug 2022 17:01:31 +0200 Subject: [PATCH] Optimize tooling of kind --- .gitignore | 16 ++++++++-------- Makefile | 4 ++-- Makefile.vars.mk | 11 ++++++++--- kind/go.mod | 21 --------------------- kind/go.sum | 36 ------------------------------------ kind/kind.mk | 18 ++++++++++-------- kind/tools.go | 11 ----------- 7 files changed, 28 insertions(+), 89 deletions(-) delete mode 100644 kind/go.mod delete mode 100644 kind/go.sum delete mode 100644 kind/tools.go diff --git a/.gitignore b/.gitignore index 9d01f35..0ff3b72 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,16 @@ # Goreleaser -dist/ -.github/release-notes.md +/dist/ +/.github/release-notes.md # Build # TODO: Adjust binary file name -go-bootstrap +/go-bootstrap *.out # Docs -.cache/ -.public/ -node_modules/ +/.cache/ +/.public/ +/node_modules/ -# kind -.kind/ +# work +/.work/ diff --git a/Makefile b/Makefile index b07a4c4..6c69fd7 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,6 @@ generate: ## Generate additional code and artifacts @go generate ./... .PHONY: clean -clean: ## Cleans local build artifacts - rm -rf docs/node_modules $(docs_out_dir) dist .cache +clean: kind-clean ## Cleans local build artifacts docker rmi $(CONTAINER_IMG) || true + rm -rf docs/node_modules $(docs_out_dir) dist .cache $(WORK_DIR) diff --git a/Makefile.vars.mk b/Makefile.vars.mk index 6f09abe..94158ce 100644 --- a/Makefile.vars.mk +++ b/Makefile.vars.mk @@ -5,15 +5,20 @@ PROJECT_ROOT_DIR = . PROJECT_NAME ?= go-bootstrap PROJECT_OWNER ?= vshn +WORK_DIR = $(PWD)/.work + ## BUILD:go BIN_FILENAME ?= $(PROJECT_NAME) +go_bin ?= $(WORK_DIR)/bin +$(go_bin): + @mkdir -p $@ ## BUILD:docker DOCKER_CMD ?= docker IMG_TAG ?= latest # Image URL to use all building/pushing image targets -CONTAINER_IMG ?= local.dev/$(PROJECT_OWNER)/$(PROJECT_NAME):$(IMG_TAG) +CONTAINER_IMG ?= ghcr.io/$(PROJECT_OWNER)/$(PROJECT_NAME):$(IMG_TAG) ## KIND:setup @@ -22,5 +27,5 @@ CONTAINER_IMG ?= local.dev/$(PROJECT_OWNER)/$(PROJECT_NAME):$(IMG_TAG) KIND_NODE_VERSION ?= v1.24.0 KIND_IMAGE ?= docker.io/kindest/node:$(KIND_NODE_VERSION) KIND ?= go run sigs.k8s.io/kind -KIND_KUBECONFIG ?= $(kind_dir)/kind-kubeconfig-$(KIND_NODE_VERSION) -KIND_CLUSTER ?= $(PROJECT_NAME)-$(KIND_NODE_VERSION) +KIND_KUBECONFIG ?= $(kind_dir)/kind-kubeconfig +KIND_CLUSTER ?= $(PROJECT_NAME) diff --git a/kind/go.mod b/kind/go.mod deleted file mode 100644 index 60eeff6..0000000 --- a/kind/go.mod +++ /dev/null @@ -1,21 +0,0 @@ -module kind - -go 1.18 - -require sigs.k8s.io/kind v0.14.0 - -require ( - github.com/BurntSushi/toml v1.0.0 // indirect - github.com/alessio/shellescape v1.4.1 // indirect - github.com/evanphx/json-patch/v5 v5.6.0 // indirect - github.com/inconshreveable/mousetrap v1.0.0 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect - github.com/pelletier/go-toml v1.9.4 // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/spf13/cobra v1.4.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect - golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect - sigs.k8s.io/yaml v1.3.0 // indirect -) diff --git a/kind/go.sum b/kind/go.sum deleted file mode 100644 index faa59fa..0000000 --- a/kind/go.sum +++ /dev/null @@ -1,36 +0,0 @@ -github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU= -github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= -github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0= -github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= -github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= -github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= -github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM= -github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q= -github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -sigs.k8s.io/kind v0.14.0 h1:cNmI3jGBvp7UegEGbC5we8plDtCUmaNRL+bod7JoSCE= -sigs.k8s.io/kind v0.14.0/go.mod h1:UrFRPHG+2a5j0Q7qiR4gtJ4rEyn8TuMQwuOPf+m4oHg= -sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/kind/kind.mk b/kind/kind.mk index 70303b2..f849565 100644 --- a/kind/kind.mk +++ b/kind/kind.mk @@ -1,13 +1,15 @@ -kind_dir ?= $(PWD)/.kind -kind_bin = $(kind_dir)/kind +kind_dir ?= $(WORK_DIR)/kind +kind_bin = $(go_bin)/kind # Prepare kind binary -# We need to set the Go arch since the binary is meant for the user's OS. $(kind_bin): export GOOS = $(shell go env GOOS) $(kind_bin): export GOARCH = $(shell go env GOARCH) -$(kind_bin): - @mkdir -p $(kind_dir) - cd kind && go build -o $@ sigs.k8s.io/kind +$(kind_bin): export GOBIN = $(go_bin) +$(kind_bin): | $(go_bin) + go install sigs.k8s.io/kind@latest + +$(kind_dir): + @mkdir -p $@ .PHONY: kind kind: export KUBECONFIG = $(KIND_KUBECONFIG) @@ -33,10 +35,10 @@ kind-load-image: kind-setup build-docker ## Load the container image onto kind c kind-clean: export KUBECONFIG = $(KIND_KUBECONFIG) kind-clean: ## Removes the kind Cluster @$(kind_bin) delete cluster --name $(KIND_CLUSTER) || true - @rm -rf $(kind_dir) + @rm -rf $(kind_dir) $(kind_bin) $(KIND_KUBECONFIG): export KUBECONFIG = $(KIND_KUBECONFIG) -$(KIND_KUBECONFIG): $(kind_bin) +$(KIND_KUBECONFIG): $(kind_bin) | $(kind_dir) $(kind_bin) create cluster \ --name $(KIND_CLUSTER) \ --image $(KIND_IMAGE) \ diff --git a/kind/tools.go b/kind/tools.go deleted file mode 100644 index 36a1c99..0000000 --- a/kind/tools.go +++ /dev/null @@ -1,11 +0,0 @@ -//go:build tools -// +build tools - -// Package tools is a place to put any tooling dependencies as imports. -// Go modules will be forced to download and install them. -package tools - -import ( - // To have kind updated via Renovate. - _ "sigs.k8s.io/kind" -)