Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #46 from vshn/tooling
Browse files Browse the repository at this point in the history
Optimize tooling of kind
  • Loading branch information
ccremer committed Aug 9, 2022
2 parents 5bd9fe5 + b4ba183 commit 033a447
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 89 deletions.
16 changes: 8 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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/
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
11 changes: 8 additions & 3 deletions Makefile.vars.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
21 changes: 0 additions & 21 deletions kind/go.mod

This file was deleted.

36 changes: 0 additions & 36 deletions kind/go.sum

This file was deleted.

18 changes: 10 additions & 8 deletions kind/kind.mk
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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) \
Expand Down
11 changes: 0 additions & 11 deletions kind/tools.go

This file was deleted.

0 comments on commit 033a447

Please sign in to comment.