| 1 |
# Copyright 2022 The Kubernetes Authors. |
| 2 |
# SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
GOOS = $(shell go env GOOS) |
| 5 |
GOARCH = $(shell go env GOARCH) |
| 6 |
MYGOBIN = $(shell go env GOBIN) |
| 7 |
ifeq ($(MYGOBIN),) |
| 8 |
MYGOBIN = $(shell go env GOPATH)/bin |
| 9 |
endif |
| 10 |
export PATH := $(MYGOBIN):$(PATH) |
| 11 |
|
| 12 |
REPO_ROOT=$(shell git rev-parse --show-toplevel) |
| 13 |
|
| 14 |
# determines whether to run tests that only behave locally; can be overridden by override variable |
| 15 |
export IS_LOCAL = false |
| 16 |
|
| 17 |
.PHONY: install-out-of-tree-tools |
| 18 |
install-out-of-tree-tools: \ |
| 19 |
$(MYGOBIN)/goimports \ |
| 20 |
$(MYGOBIN)/golangci-lint \ |
| 21 |
$(MYGOBIN)/helmV3 \ |
| 22 |
$(MYGOBIN)/mdrip \ |
| 23 |
$(MYGOBIN)/stringer |
| 24 |
|
| 25 |
.PHONY: uninstall-out-of-tree-tools |
| 26 |
uninstall-out-of-tree-tools: |
| 27 |
rm -f $(MYGOBIN)/goimports |
| 28 |
rm -f $(MYGOBIN)/golangci-lint |
| 29 |
rm -f $(MYGOBIN)/helmV3 |
| 30 |
rm -f $(MYGOBIN)/mdrip |
| 31 |
rm -f $(MYGOBIN)/stringer |
| 32 |
|
| 33 |
.PHONY: $(MYGOBIN)/golangci-lint |
| 34 |
$(MYGOBIN)/golangci-lint: |
| 35 |
cd $(REPO_ROOT)/hack && go install github.com/golangci/golangci-lint/cmd/golangci-lint |
| 36 |
|
| 37 |
.PHONY: $(MYGOBIN)/mdrip |
| 38 |
$(MYGOBIN)/mdrip: |
| 39 |
cd $(REPO_ROOT)/hack && go install github.com/monopole/mdrip |
| 40 |
|
| 41 |
.PHONY: $(MYGOBIN)/stringer |
| 42 |
$(MYGOBIN)/stringer: |
| 43 |
cd $(REPO_ROOT)/hack && go install golang.org/x/tools/cmd/stringer |
| 44 |
|
| 45 |
.PHONY: $(MYGOBIN)/goimports |
| 46 |
$(MYGOBIN)/goimports: |
| 47 |
cd $(REPO_ROOT)/hack && go install golang.org/x/tools/cmd/goimports |
| 48 |
|
| 49 |
.PHONY: $(MYGOBIN)/mdtogo |
| 50 |
$(MYGOBIN)/mdtogo: |
| 51 |
cd $(REPO_ROOT)/hack && go install sigs.k8s.io/kustomize/cmd/mdtogo |
| 52 |
|
| 53 |
.PHONY: $(MYGOBIN)/addlicense |
| 54 |
$(MYGOBIN)/addlicense: |
| 55 |
cd $(REPO_ROOT)/hack && go install github.com/google/addlicense |
| 56 |
|
| 57 |
.PHONY: $(MYGOBIN)/kind |
| 58 |
$(MYGOBIN)/kind: |
| 59 |
cd $(REPO_ROOT)/hack && go install sigs.k8s.io/kind |
| 60 |
|
| 61 |
.PHONY: $(MYGOBIN)/controller-gen |
| 62 |
$(MYGOBIN)/controller-gen: |
| 63 |
cd $(REPO_ROOT)/hack && go install sigs.k8s.io/controller-tools/cmd/controller-gen |
| 64 |
|
| 65 |
.PHONY: $(MYGOBIN)/embedmd |
| 66 |
$(MYGOBIN)/embedmd: |
| 67 |
cd $(REPO_ROOT)/hack && go install github.com/campoy/embedmd |
| 68 |
|
| 69 |
.PHONY: $(MYGOBIN)/go-bindata |
| 70 |
$(MYGOBIN)/go-bindata: |
| 71 |
cd $(REPO_ROOT)/hack && go install github.com/go-bindata/go-bindata/v3/go-bindata |
| 72 |
|
| 73 |
.PHONY: $(MYGOBIN)/go-apidiff |
| 74 |
$(MYGOBIN)/go-apidiff: |
| 75 |
cd $(REPO_ROOT)/hack && go install github.com/joelanford/go-apidiff |
| 76 |
|
| 77 |
.PHONY: $(MYGOBIN)/gh |
| 78 |
$(MYGOBIN)/gh: |
| 79 |
cd $(REPO_ROOT)/hack && go install github.com/cli/cli/cmd/gh |
| 80 |
|
| 81 |
.PHONY: $(MYGOBIN)/kubeval |
| 82 |
$(MYGOBIN)/kubeval: |
| 83 |
cd $(REPO_ROOT)/hack && go install github.com/instrumenta/kubeval |
| 84 |
|
| 85 |
# Helm V3 differs from helm V2; downloading it to provide coverage for the |
| 86 |
# chart inflator plugin under helm v3. |
| 87 |
.PHONY: $(MYGOBIN)/helmV3 |
| 88 |
$(MYGOBIN)/helmV3: |
| 89 |
( \ |
| 90 |
set -e; \ |
| 91 |
d=$(shell mktemp -d); cd $$d; \ |
| 92 |
tgzFile=helm-v3.10.2-$(GOOS)-$(GOARCH).tar.gz; \ |
| 93 |
wget https://get.helm.sh/$$tgzFile; \ |
| 94 |
tar -xvzf $$tgzFile; \ |
| 95 |
mv $(GOOS)-$(GOARCH)/helm $(MYGOBIN)/helmV3; \ |
| 96 |
rm -rf $$d \ |
| 97 |
) |