-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
82 lines (62 loc) · 2.81 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
NAME=cnspec
BINARY=packer-plugin-${NAME}
COUNT?=1
TEST?=$(shell go list ./...)
HASHICORP_PACKER_PLUGIN_SDK_VERSION?=$(shell go list -m github.com/hashicorp/packer-plugin-sdk | cut -d " " -f2)
ifndef LATEST_VERSION_TAG
# echo "read LATEST_VERSION_TAG from git"
LATEST_VERSION_TAG=$(shell git describe --abbrev=0 --tags)
endif
ifndef MANIFEST_VERSION
# echo "read MANIFEST_VERSION from git"
MANIFEST_VERSION=$(shell git describe --abbrev=0 --tags)
endif
ifndef TAG
# echo "read TAG from git"
TAG=$(shell git log --pretty=format:'%h' -n 1)
endif
ifndef VERSION
# echo "read VERSION from git"
VERSION=${LATEST_VERSION_TAG}-$(shell git rev-list --count HEAD)
endif
ifndef CNSPEC_VERSION
CNSPEC_VERSION=$(shell go list -json -m go.mondoo.com/cnspec/v11 | jq -r ".Version")
endif
.PHONY: dev
build:
CGO_ENABLED=0 go build -o ${BINARY} -ldflags="-X go.mondoo.com/cnquery/v10.Version=${CNSPEC_VERSION} -X go.mondoo.com/packer-plugin-cnspec/provisioner/version.Version=${VERSION} -X go.mondoo.com/packer-plugin-cnspec/provisioner/version.Build=${TAG}"
dev: build
@mkdir -p ~/.packer.d/plugins/
@mv ${BINARY} ~/.packer.d/plugins/${BINARY}
.PHONY: dev/linux
dev/linux: build
@mkdir -p ~/.packer.d/plugins/github.com/mondoohq/cnspec/
@mv ${BINARY} ~/.packer.d/plugins/github.com/mondoohq/cnspec/${BINARY}_${VERSION}_x5.0_linux_amd64
@cat ~/.packer.d/plugins/github.com/mondoohq/cnspec/packer-plugin-cnspec_${VERSION}_x5.0_linux_amd64 | sha256sum -z --tag | cut -d"=" -f2 | tr -d " " > ~/.packer.d/plugins/github.com/mondoohq/cnspec/packer-plugin-cnspec_${VERSION}_x5.0_linux_amd64_SHA256SUM
.PHONY: dev/macos
dev/macos: build
@mkdir -p ~/.packer.d/plugins/github.com/mondoohq/cnspec/
@mv ${BINARY} ~/.packer.d/plugins/github.com/mondoohq/cnspec/${BINARY}_v${VERSION}_macos_amd64
@cat ~/.packer.d/plugins/github.com/mondoohq/cnspec/packer-plugin-cnspec_v${VERSION}_macos_amd64 | shasum --tag | cut -d"=" -f2 | tr -d " " > ~/.packer.d/plugins/github.com/mondoohq/cnspec/packer-plugin-cnspec_v${VERSION}_macos_amd64_SHA256SUM
test:
@go test -race -count $(COUNT) $(TEST) -timeout=3m
test/golanglint:
@golangci-lint run
install-packer-sdc: ## Install packer software development command
@go install github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc@${HASHICORP_PACKER_PLUGIN_SDK_VERSION}
plugin-check: install-packer-sdc build
@packer-sdc plugin-check ${BINARY}
testacc: dev
@PACKER_ACC=1 go test -count $(COUNT) -v $(TEST) -timeout=120m
generate: install-packer-sdc
@go generate ./...
@rm -rf .docs
@packer-sdc renderdocs -src "docs" -partials docs-partials/ -dst ".docs/"
@./.web-docs/scripts/compile-to-webdocs.sh "." ".docs" ".web-docs" "mondoohq"
@rm -rf ".docs"
# Copywrite Check Tool: https://github.com/hashicorp/copywrite
license: license/headers/check
license/headers/check:
copywrite headers --plan
license/headers/apply:
copywrite headers