forked from coreos/tectonic-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
214 lines (179 loc) · 7.44 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
CLUSTER ?= demo
PLATFORM ?= aws
TMPDIR ?= /tmp
GOOS=$(shell uname -s | tr '[:upper:]' '[:lower:]')
GOARCH=amd64
TOP_DIR := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
BUILD_DIR = $(TOP_DIR)/build/$(CLUSTER)
PLUGIN_DIR = $(BUILD_DIR)/terraform.d/plugins/$(GOOS)_$(GOARCH)
INSTALLER_PATH = $(TOP_DIR)/installer/bin/$(shell uname | tr '[:upper:]' '[:lower:]')
INSTALLER_BIN = $(INSTALLER_PATH)/installer
TF_DOCS := $(shell which terraform-docs 2> /dev/null)
TF_EXAMPLES := $(shell which terraform-examples 2> /dev/null)
TF_CMD = terraform
TEST_COMMAND = /bin/bash -c "bundler exec rspec spec/${TEST}"
include ./makelib/*.mk
$(info Using build directory [${BUILD_DIR}])
.PHONY: all
all: $(INSTALLER_BIN) custom-providers
$(INSTALLER_BIN):
$(MAKE) build -C $(TOP_DIR)/installer
.PHONY: localconfig
localconfig:
mkdir -p $(BUILD_DIR)
cp examples/*$(subst /,-,$(PLATFORM)) $(BUILD_DIR)/terraform.tfvars
$(PLUGIN_DIR):
mkdir -p $(PLUGIN_DIR)
ln -s $(INSTALLER_PATH)/terraform-provider-* $(PLUGIN_DIR)
.PHONY: terraform-init
terraform-init: custom-providers $(PLUGIN_DIR)
ifneq ($(shell $(TF_CMD) version | grep -E "Terraform v0\.1[0-9]\.[0-9]+"), )
cd $(BUILD_DIR) && $(TF_CMD) init $(TF_INIT_OPTIONS) $(TOP_DIR)/platforms/$(PLATFORM)
else
cd $(BUILD_DIR) && $(TF_CMD) get $(TF_GET_OPTIONS) $(TOP_DIR)/platforms/$(PLATFORM)
endif
.PHONY: plan
plan: terraform-init
cd $(BUILD_DIR) && $(TF_CMD) plan $(TF_PLAN_OPTIONS) $(TOP_DIR)/platforms/$(PLATFORM)
.PHONY: apply
apply: terraform-init
cd $(BUILD_DIR) && $(TF_CMD) apply $(TF_APPLY_OPTIONS) -auto-approve $(TOP_DIR)/platforms/$(PLATFORM)
.PHONY: destroy
destroy: terraform-init
cd $(BUILD_DIR) && $(TF_CMD) destroy $(TF_DESTROY_OPTIONS) -force $(TOP_DIR)/platforms/$(PLATFORM)
define terraform-docs
$(if $(TF_DOCS),,$(error terraform-docs revision >= a8b59f8 is required (https://github.com/segmentio/terraform-docs)))
@echo '<!-- DO NOT EDIT. THIS FILE IS GENERATED BY THE MAKEFILE. -->' > $1
@echo '# Terraform variables' >> $1
@echo $2 >> $1
terraform-docs --no-required markdown $3 $4 $5 $6 >> $1
endef
define terraform-examples
$(if $(TF_EXAMPLES),,$(error terraform-examples is required. Execute "go get github.com/coreos/tectonic-installer/contrib/terraform-examples" to install it.))
terraform-examples $2 $3 $4 $5 > $1
endef
.PHONY: docs
docs:
$(call terraform-docs, Documentation/variables/config.md, \
'This document gives an overview of variables used in all platforms of the Tectonic SDK.', \
config.tf)
$(call terraform-docs, Documentation/variables/aws.md, \
'This document gives an overview of variables used in the AWS platform of the Tectonic SDK.', \
platforms/aws/variables.tf)
$(call terraform-docs, Documentation/variables/govcloud.md, \
'This document gives an overview of variables used in the GovCloud AWS platform of the Tectonic SDK.', \
platforms/govcloud/variables.tf)
$(call terraform-docs, Documentation/variables/azure.md, \
'This document gives an overview of variables used in the Azure platform of the Tectonic SDK.', \
platforms/azure/variables.tf)
$(call terraform-docs, Documentation/variables/openstack-neutron.md, \
'This document gives an overview of variables used in the Openstack/Neutron platform of the Tectonic SDK.', \
platforms/openstack/neutron/variables.tf)
$(call terraform-docs, Documentation/variables/metal.md, \
'This document gives an overview of variables used in the bare metal platform of the Tectonic SDK.', \
platforms/metal/variables.tf)
$(call terraform-docs, Documentation/variables/vmware.md, \
'This document gives an overview of variables used in the VMware platform of the Tectonic SDK.', \
platforms/vmware/variables.tf)
$(call terraform-docs, Documentation/variables/gcp.md, \
'This document gives an overview of variables used in the Google Cloud platform of the Tectonic SDK.', \
platforms/gcp/variables.tf)
.PHONY: examples
examples:
$(call terraform-examples, examples/terraform.tfvars.aws, \
config.tf, \
platforms/aws/variables.tf)
$(call terraform-examples, examples/terraform.tfvars.govcloud, \
config.tf, \
platforms/govcloud/variables.tf)
$(call terraform-examples, \
examples/terraform.tfvars.azure, \
config.tf, \
platforms/azure/variables.tf)
$(call terraform-examples, \
examples/terraform.tfvars.openstack-neutron, \
config.tf, \
platforms/openstack/neutron/variables.tf)
$(call terraform-examples, \
examples/terraform.tfvars.metal, \
config.tf, \
platforms/metal/variables.tf)
$(call terraform-examples, \
examples/terraform.tfvars.vmware, \
config.tf, \
platforms/vmware/variables.tf)
$(call terraform-examples, \
examples/terraform.tfvars.gcp, \
config.tf, \
platforms/gcp/variables.tf)
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
$(MAKE) clean -C $(TOP_DIR)/installer
rm -f $(TF_RC)
# This target is used by the GitHub PR checker to validate canonical syntax on all files.
#
.PHONY: structure-check
structure-check:
$(eval FMT_ERR := $(shell terraform fmt -list -write=false .))
@if [ "$(FMT_ERR)" != "" ]; then echo "misformatted files (run 'terraform fmt .' to fix):" $(FMT_ERR); exit 1; fi
@if $(MAKE) docs && ! git diff --exit-code; then echo "outdated docs (run 'make docs' to fix)"; exit 1; fi
@if $(MAKE) examples && ! git diff --exit-code; then echo "outdated examples (run 'make examples' to fix)"; exit 1; fi
SMOKE_SOURCES := $(shell find $(TOP_DIR)/tests/smoke -name '*.go')
bin/smoke: $(SMOKE_SOURCES)
@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go test ./tests/smoke/ -c -o bin/smoke
.PHONY: vendor-smoke
vendor-smoke: $(TOP_DIR)/tests/smoke/glide.yaml
@cd $(TOP_DIR)/tests/smoke && glide up -v
@cd $(TOP_DIR)/tests/smoke && glide-vc --use-lock-file --no-tests --only-code
.PHONY: e2e-docker-image
e2e-docker-image: images/kubernetes-e2e/Dockerfile
@export E2E_IMAGE="quay.io/coreos/kube-conformance:$$(grep 'ARG E2E_REF' $< | cut -d '=' -f2 | sed 's/+/_/')"; \
echo "Building E2E image $${E2E_IMAGE}"; \
docker build -t $${E2E_IMAGE} $(dir $<)
.PHONY: smoke-test-env-docker-image
smoke-test-env-docker-image:
docker build -t quay.io/coreos/tectonic-smoke-test-env -f images/tectonic-smoke-test-env/Dockerfile .
.PHONY: tests/smoke
tests/smoke: bin/smoke smoke-test-env-docker-image
docker run \
--rm \
-it \
-v "${CURDIR}":"${CURDIR}" \
-w "${CURDIR}/tests/rspec" \
-v "${TF_VAR_tectonic_license_path}":"${TF_VAR_tectonic_license_path}" \
-v "${TF_VAR_tectonic_pull_secret_path}":"${TF_VAR_tectonic_pull_secret_path}" \
-v "${HOME}/.ssh:/root/.ssh:ro" \
-v "/var/run/docker.sock:/var/run/docker.sock" \
-v "${TF_VAR_tectonic_azure_ssh_key}":"${TF_VAR_tectonic_azure_ssh_key}" \
-e CLUSTER \
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
-e ARM_CLIENT_ID \
-e ARM_CLIENT_SECRET \
-e ARM_ENVIRONMENT \
-e ARM_SUBSCRIPTION_ID \
-e ARM_TENANT_ID \
-e GOOGLE_APPLICATION_CREDENTIALS \
-e GOOGLE_CREDENTIALS \
-e GOOGLE_CLOUD_KEYFILE_JSON \
-e GCLOUD_KEYFILE_JSON \
-e GOOGLE_PROJECT \
-e TF_VAR_tectonic_gcp_ssh_key \
-e TF_VAR_tectonic_aws_region \
-e TF_VAR_tectonic_aws_ssh_key \
-e TF_VAR_tectonic_azure_location \
-e TF_VAR_tectonic_license_path \
-e TF_VAR_tectonic_pull_secret_path \
-e TF_VAR_tectonic_base_domain \
-e TF_VAR_tectonic_admin_email \
-e TF_VAR_tectonic_admin_password \
-e TECTONIC_TESTS_DONT_CLEAN_UP \
-e RUN_SMOKE_TESTS \
-e RUN_CONFORMANCE_TESTS \
-e KUBE_CONFORMANCE_IMAGE \
-e COMPONENT_TEST_IMAGES \
--cap-add NET_ADMIN \
--device /dev/net/tun \
quay.io/coreos/tectonic-smoke-test-env \
$(TEST_COMMAND)