diff --git a/Dockerfile b/Dockerfile index 539573ee..a30e213c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ARG DOCKER_REGISTRY ARG ALPINE_VERSION=3.15 -FROM ${DOCKER_REGISTRY:+$DOCKER_REGISTRY/}golang:1.17-alpine${ALPINE_VERSION} as go-builder +FROM ${DOCKER_REGISTRY:+$DOCKER_REGISTRY/}golang:1.18-alpine${ALPINE_VERSION} as go-builder ARG PROJECT_NAME=zookeeper-operator ARG REPO_PATH=github.com/pravega/$PROJECT_NAME diff --git a/Makefile b/Makefile index 9017f757..b1d37124 100644 --- a/Makefile +++ b/Makefile @@ -76,37 +76,25 @@ fmt: vet: go vet ./... -# find or download controller-gen -# download controller-gen if necessary -controller-gen: -ifeq (, $(shell which controller-gen)) - @{ \ - set -e ;\ - CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\ - cd $$CONTROLLER_GEN_TMP_DIR ;\ - go mod init tmp ;\ - go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.9.0 ;\ - rm -rf $$CONTROLLER_GEN_TMP_DIR ;\ - } -CONTROLLER_GEN=$(GOBIN)/controller-gen -else -CONTROLLER_GEN=$(shell which controller-gen) -endif - -kustomize: -ifeq (, $(shell which kustomize)) - @{ \ - set -e ;\ - KUSTOMIZE_GEN_TMP_DIR=$$(mktemp -d) ;\ - cd $$KUSTOMIZE_GEN_TMP_DIR ;\ - go mod init tmp ;\ - go install sigs.k8s.io/kustomize/kustomize/v3@v3.5.4 ;\ - rm -rf $$KUSTOMIZE_GEN_TMP_DIR ;\ - } -KUSTOMIZE=$(GOBIN)/kustomize -else -KUSTOMIZE=$(shell which kustomize) -endif +## Location to install dependencies to +LOCALBIN ?= $(shell pwd)/bin +$(LOCALBIN): + mkdir -p $(LOCALBIN) +## Tool Binaries +KUSTOMIZE ?= $(LOCALBIN)/kustomize +CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen +## Tool Versions +KUSTOMIZE_VERSION ?= v3.5.4 +CONTROLLER_TOOLS_VERSION ?= v0.9.0 +KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" +.PHONY: kustomize +kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. +$(KUSTOMIZE): $(LOCALBIN) + test -s $(LOCALBIN)/kustomize || { curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); } +.PHONY: controller-gen +controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. +$(CONTROLLER_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/controller-gen || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION) all: generate check build diff --git a/go.mod b/go.mod index 8ed331ba..1f60fd17 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/pravega/zookeeper-operator -go 1.17 +go 1.18 require ( github.com/ghodss/yaml v1.0.0