More makefile cleanup

This commit is contained in:
Katrina Verey
2022-04-04 16:43:43 -04:00
parent 0fa010c7e7
commit 46875b6ac4
12 changed files with 74 additions and 103 deletions

View File

@@ -26,8 +26,6 @@ jobs:
- name: Lint
run: make lint
env:
KUSTOMIZE_DOCKER_E2E: false # don't need to do e2e tests for linting
- name: Verify boilerplate
run: make check-license

View File

@@ -5,7 +5,7 @@ endif
export PATH := $(MYGOBIN):$(PATH)
# only set this if not already set, so importing makefiles can override it
export KUSTOMIZE_ROOT ?= $(shell pwd | sed -E 's|(.*\/kustomize).*|\1|')
export KUSTOMIZE_ROOT ?= $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\1|')
include $(KUSTOMIZE_ROOT)/Makefile-tools.mk
.PHONY: lint test fix fmt tidy vet
@@ -13,7 +13,7 @@ include $(KUSTOMIZE_ROOT)/Makefile-tools.mk
lint: $(MYGOBIN)/golangci-lint
$(MYGOBIN)/golangci-lint \
-c $$KUSTOMIZE_ROOT/.golangci.yml \
--path-prefix $(shell pwd | sed 's|.*kustomize/||') \
--path-prefix $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\2|') \
run ./...
test:

View File

@@ -1,7 +1,7 @@
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
.PHONY: generate license fix vet fmt test build tidy
.PHONY: generate fix vet fmt test build tidy
include ../../../../../../Makefile-modules.mk

View File

@@ -1,17 +1,15 @@
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
.PHONY: generate license fix vet fmt test build tidy image
.PHONY: generate fix vet fmt test build tidy image
GOBIN = $(shell go env GOBIN)
ifeq ($(GOBIN),)
GOBIN = $(shell go env GOPATH)/bin
endif
export KUSTOMIZE_ROOT ?= $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\1|')
include $(KUSTOMIZE_ROOT)/Makefile-tools.mk
build:
(cd image && go build -v -o $(GOBIN)/config-function .)
all: generate license build fix vet fmt test lint tidy
all: generate build fix vet fmt test lint tidy
fix:
(cd image && go fix ./...)
@@ -19,20 +17,17 @@ fix:
fmt:
(cd image && go fmt ./...)
generate:
(which $(GOBIN)/mdtogo || go get sigs.k8s.io/kustomize/cmd/mdtogo)
(cd image && GOBIN=$(GOBIN) go generate ./...)
license:
(which $(GOBIN)/addlicense || go get github.com/google/addlicense)
$(GOBIN)/addlicense -y 2022 -c "The Kubernetes Authors." -f LICENSE_TEMPLATE .
generate: $(MYGOBIN)/mdtogo
(cd image && GOBIN=$(MYGOBIN) go generate ./...)
tidy:
(cd image && go mod tidy)
lint:
(which $(GOBIN)/golangci-lint || go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.19.1)
(cd image && $(GOBIN)/golangci-lint run ./...)
lint: $(MYGOBIN)/golangci-lint
(cd image && $(MYGOBIN)/golangci-lint \
-c $$KUSTOMIZE_ROOT/.golangci.yml \
--path-prefix $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\2|') \
run ./...)
test:
(cd image && go test -cover ./...)

View File

@@ -1,17 +1,15 @@
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
.PHONY: generate license fix vet fmt test build tidy image
.PHONY: generate fix vet fmt test build tidy image
GOBIN = $(shell go env GOBIN)
ifeq ($(GOBIN),)
GOBIN = $(shell go env GOPATH)/bin
endif
export KUSTOMIZE_ROOT ?= $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\1|')
include $(KUSTOMIZE_ROOT)/Makefile-tools.mk
build:
(cd image && go build -v -o $(GOBIN)/config-function .)
(cd image && go build -v -o $(MYGOBIN)/config-function .)
all: generate license build fix vet fmt test lint tidy
all: generate build fix vet fmt test lint tidy
fix:
(cd image && go fix ./...)
@@ -19,20 +17,17 @@ fix:
fmt:
(cd image && go fmt ./...)
generate:
(which $(GOBIN)/mdtogo || go get sigs.k8s.io/kustomize/cmd/mdtogo)
(cd image && GOBIN=$(GOBIN) go generate ./...)
license:
(which $(GOBIN)/addlicense || go get github.com/google/addlicense)
$(GOBIN)/addlicense -y 2022 -c "The Kubernetes Authors." -f LICENSE_TEMPLATE .
generate: $(MYGOBIN)/mdtogo
(cd image && GOBIN=$(MYGOBIN) go generate ./...)
tidy:
(cd image && go mod tidy)
lint:
(which $(GOBIN)/golangci-lint || go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.19.1)
(cd image && $(GOBIN)/golangci-lint run ./...)
lint: $(MYGOBIN)/golangci-lint
(cd image && $(MYGOBIN)/golangci-lint \
-c $$KUSTOMIZE_ROOT/.golangci.yml \
--path-prefix $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\2|') \
run ./...)
test:
(cd image && go test -cover ./...)

View File

@@ -1,17 +1,15 @@
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
.PHONY: generate license fix vet fmt test build tidy image
.PHONY: generate fix vet fmt test build tidy image
GOBIN = $(shell go env GOBIN)
ifeq ($(GOBIN),)
GOBIN = $(shell go env GOPATH)/bin
endif
export KUSTOMIZE_ROOT ?= $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\1|')
include $(KUSTOMIZE_ROOT)/Makefile-tools.mk
build:
(cd image && go build -v -o $(GOBIN)/config-function .)
all: generate license build fix vet fmt test lint tidy
all: generate build fix vet fmt test lint tidy
fix:
(cd image && go fix ./...)
@@ -19,20 +17,17 @@ fix:
fmt:
(cd image && go fmt ./...)
generate:
(which $(GOBIN)/mdtogo || go get sigs.k8s.io/kustomize/cmd/mdtogo)
(cd image && GOBIN=$(GOBIN) go generate ./...)
license:
(which $(GOBIN)/addlicense || go get github.com/google/addlicense)
$(GOBIN)/addlicense -y 2022 -c "The Kubernetes Authors." -f LICENSE_TEMPLATE .
generate: $(MYGOBIN)/mdtogo
(cd image && GOBIN=$(MYGOBIN) go generate ./...)
tidy:
(cd image && go mod tidy)
lint:
(which $(GOBIN)/golangci-lint || go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.19.1)
(cd image && $(GOBIN)/golangci-lint run ./...)
lint: $(MYGOBIN)/golangci-lint
(cd image && $(MYGOBIN)/golangci-lint \
-c $$KUSTOMIZE_ROOT/.golangci.yml \
--path-prefix $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\2|') \
run ./...)
test:
(cd image && go test -cover ./...)

View File

@@ -1,18 +1,10 @@
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
.PHONY: license image
.PHONY: image
GOBIN = $(shell go env GOBIN)
ifeq ($(GOBIN),)
GOBIN = $(shell go env GOPATH)/bin
endif
license:
(which $(GOBIN)/addlicense || go get github.com/google/addlicense)
$(GOBIN)/addlicense -y 2022 -c "The Kubernetes Authors." -f LICENSE_TEMPLATE .
all: license
all:
true
image:
docker build image -t gcr.io/kustomize-functions/example-cockroachdb:v0.1.0

View File

@@ -1,17 +1,15 @@
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
.PHONY: generate license fix vet fmt test build tidy image
.PHONY: generate fix vet fmt test build tidy image
GOBIN = $(shell go env GOBIN)
ifeq ($(GOBIN),)
GOBIN = $(shell go env GOPATH)/bin
endif
export KUSTOMIZE_ROOT ?= $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\1|')
include $(KUSTOMIZE_ROOT)/Makefile-tools.mk
build:
(cd image && go build -v -o $(GOBIN)/config-function .)
all: generate license build fix vet fmt test lint tidy
all: generate build fix vet fmt test lint tidy
fix:
(cd image && go fix ./...)
@@ -19,20 +17,17 @@ fix:
fmt:
(cd image && go fmt ./...)
generate:
(which $(GOBIN)/mdtogo || go get sigs.k8s.io/kustomize/cmd/mdtogo)
(cd image && GOBIN=$(GOBIN) go generate ./...)
license:
(which $(GOBIN)/addlicense || go get github.com/google/addlicense)
$(GOBIN)/addlicense -y 2022 -c "The Kubernetes Authors." -f LICENSE_TEMPLATE .
generate: $(MYGOBIN)/mdtogo
(cd image && GOBIN=$(MYGOBIN) go generate ./...)
tidy:
(cd image && go mod tidy)
lint:
(which $(GOBIN)/golangci-lint || go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.19.1)
(cd image && $(GOBIN)/golangci-lint run ./...)
lint: $(MYGOBIN)/golangci-lint
(cd image && $(MYGOBIN)/golangci-lint \
-c $$KUSTOMIZE_ROOT/.golangci.yml \
--path-prefix $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\2|') \
run ./...)
test:
(cd image && go test -cover ./...)

View File

@@ -1,17 +1,15 @@
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
.PHONY: generate license fix vet fmt test build tidy image
.PHONY: generate fix vet fmt test build tidy image
GOBIN = $(shell go env GOBIN)
ifeq ($(GOBIN),)
GOBIN = $(shell go env GOPATH)/bin
endif
export KUSTOMIZE_ROOT ?= $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\1|')
include $(KUSTOMIZE_ROOT)/Makefile-tools.mk
build:
(cd image && go build -v -o $(GOBIN)/config-function .)
all: generate license build fix vet fmt test lint tidy
all: generate build fix vet fmt test lint tidy
fix:
(cd image && go fix ./...)
@@ -19,20 +17,17 @@ fix:
fmt:
(cd image && go fmt ./...)
generate:
(which $(GOBIN)/mdtogo || go get sigs.k8s.io/kustomize/cmd/mdtogo)
(cd image && GOBIN=$(GOBIN) go generate ./...)
license:
(which $(GOBIN)/addlicense || go get github.com/google/addlicense)
$(GOBIN)/addlicense -y 2022 -c "The Kubernetes Authors." -f LICENSE_TEMPLATE .
generate: $(MYGOBIN)/mdtogo
(cd image && GOBIN=$(MYGOBIN) go generate ./...)
tidy:
(cd image && go mod tidy)
lint:
(which $(GOBIN)/golangci-lint || go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.19.1)
(cd image && $(GOBIN)/golangci-lint run ./...)
lint: $(MYGOBIN)/golangci-lint
(cd image && $(MYGOBIN)/golangci-lint \
-c $$KUSTOMIZE_ROOT/.golangci.yml \
--path-prefix $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\2|') \
run ./...)
test:
(cd image && go test -cover ./...)

View File

@@ -34,11 +34,13 @@ args=(
)
if [[ $mode == "check" ]]; then
args+=(-check)
if ! addlicense "${args[@]}" . ; then
set +x
echo -e "\n------------------------------------------------------------------------"
echo "Error: license missing in one or more files. Run \`$0 run\` to update them."
exit 1
fi
exit 0
fi
if ! addlicense "${args[@]}" . ; then
set +x
echo -e "\n------------------------------------------------------------------------"
echo "Error: license missing in one or more files. Run \`$0 run\` to update them."
exit 1
fi
addlicense "${args[@]}" .

View File

@@ -1,5 +1,7 @@
# Copyright 2022 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
include ./../../../../Makefile-modules.mk
lint:
echo "Skipping lint for broken module someteam.example.com/v1/validator"

View File

@@ -1,5 +1,7 @@
# Copyright 2022 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
include ./../../../../Makefile-modules.mk
lint:
echo "Skipping lint for broken module untested/v1/gogetter"