-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
89 lines (73 loc) · 2.2 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
TEST?=$$(go list ./... | grep -v 'vendor')
HOSTNAME=registry.terraform.io
NAMESPACE=redhat-developer
NAME=rhoas
BINARY=terraform-provider-rhoas
VERSION ?= 0.4
ifeq ($(OS),Windows_NT)
OS_ARCH ?=windows_amd64
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OS_ARCH ?=linux
endif
ifeq ($(UNAME_S),Darwin)
OS_ARCH ?=darwin
endif
UNAME_P := $(shell uname -p)
ifeq ($(UNAME_P),x86_64)
OS_ARCH := $(OS_ARCH)_amd64
endif
ifneq ($(filter arm%,$(UNAME_P)),)
OS_ARCH := $(OS_ARCH)_arm64
endif
endif
default: install
.PHONY: build
build:
go build -o ${BINARY}
.PHONY: docs
docs:
go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@latest
tfplugindocs
.PHONY: release
release:
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64
GOOS=linux GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_linux_386
GOOS=linux GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_linux_amd64
GOOS=linux GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_linux_arm
GOOS=windows GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_windows_386
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64
.PHONY: install
install: build
mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
.PHONY: format
format:
@go mod tidy
@gofmt -s -w `find . -type f -name '*.go'`
.PHONY: test
test:
go test -i $(TEST) || exit 1
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
.PHONY: testacc
testacc:
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
.PHONY: lint-lang
lint-lang: ## Lint i18n files
ifndef I18N_LINTER_DEF # check if the linter is installed, install it if not
go install github.com/redhat-developer/app-services-go-linter/cmd/app-services-go-linter@latest
endif
app-services-go-linter -path ./rhoas/localize/locales ./...
.PHONY: lint
lint:
golangci-lint run
.PHONY: clean
clean:
@rm -f .terraform.lock.hcl
@rm -f .terraform.tfstate.lock.info
@rm -f terraform.tfstate
@rm -f terraform.tfstate.backup
.PHONY: generate-doc
generate-doc:
go generate ./...