This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Makefile
87 lines (73 loc) · 2.09 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
#
# Copyright (c) 2021 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Disable CGO so that we always generate static binaries:
export CGO_ENABLED=0
ifeq ($(shell go env GOOS),windows)
BINARY=terraform-provider-ocm.exe
else
BINARY=terraform-provider-ocm
endif
# Import path of the project:
import_path:=github.com/openshift-online/terraform-provider-ocm
# Version of the project:
version:=$(shell git describe --abbrev=0 | sed 's/^v//')
commit:=$(shell git rev-parse --short HEAD)
# Set the linker flags so that the version will be included in the binaries:
ldflags:=\
-X $(import_path)/build.Version=$(version) \
-X $(import_path)/build.Commit=$(commit) \
$(NULL)
.PHONY: build
build:
go build -ldflags="$(ldflags)" -o ${BINARY}
.PHONY: install
install: build
platform=$$(terraform version -json | jq -r .platform); \
extension=""; \
if [[ "$${platform}" =~ ^windows_.*$$ ]]; then \
extension=".exe"; \
fi; \
dir=".terraform.d/plugins/localhost/openshift-online/ocm/$(version)/$${platform}"; \
file="terraform-provider-ocm$${extension}"; \
mkdir -p "$${dir}"; \
mv ${BINARY} "$${dir}/$${file}"
.PHONY: subsystem-test
subsystem-test: install
ginkgo run \
--succinct \
-ldflags="$(ldflags)" \
-r \
--focus-file subsystem/.*
.PHONY: unit-test
unit-test:
ginkgo run \
--succinct \
-ldflags="$(ldflags)" \
-r \
--focus-file provider/.*
.PHONY: test tests
test tests: unit-test subsystem-test
.PHONY: fmt_go
fmt_go:
gofmt -s -l -w $$(find . -name '*.go')
.PHONY: fmt_tf
fmt_tf:
terraform fmt -recursive examples
.PHONY: fmt
fmt: fmt_go fmt_tf
.PHONY: clean
clean:
rm -rf .terraform.d