-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
58 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,65 @@ | ||
.PHONY: all init docs lint format help | ||
SHELL=/bin/bash | ||
|
||
all: format lint docs | ||
# to see all colors, run | ||
# bash -c 'for c in {0..255}; do tput setaf $c; tput setaf $c | cat -v; echo =$c; done' | ||
# the first 15 entries are the 8-bit colors | ||
|
||
docs: | ||
terraform-docs markdown . \ | ||
--sort-by required \ | ||
--output-file README.md \ | ||
--output-mode insert | ||
# define standard colors | ||
ifneq (,$(findstring xterm,${TERM})) | ||
BLACK := $(shell tput -Txterm setaf 0) | ||
RED := $(shell tput -Txterm setaf 1) | ||
GREEN := $(shell tput -Txterm setaf 2) | ||
YELLOW := $(shell tput -Txterm setaf 3) | ||
LIGHTPURPLE := $(shell tput -Txterm setaf 4) | ||
PURPLE := $(shell tput -Txterm setaf 5) | ||
BLUE := $(shell tput -Txterm setaf 6) | ||
WHITE := $(shell tput -Txterm setaf 7) | ||
RESET := $(shell tput -Txterm sgr0) | ||
else | ||
BLACK := "" | ||
RED := "" | ||
GREEN := "" | ||
YELLOW := "" | ||
LIGHTPURPLE := "" | ||
PURPLE := "" | ||
BLUE := "" | ||
WHITE := "" | ||
RESET := "" | ||
endif | ||
|
||
format: | ||
terraform fmt --recursive | ||
# HELP | ||
# This will output the help for each task | ||
# thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html | ||
.DEFAULT_GOAL := help | ||
|
||
init: | ||
.PHONY: help | ||
help: ## This help | ||
@echo "Usage:" | ||
@echo "" | ||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " $(GREEN)%-20s$(RESET) %s\n", $$1, $$2}' $(MAKEFILE_LIST) | ||
@echo "" | ||
|
||
.PHONY: build | ||
build: install lint validate docs ## Build module | ||
|
||
.PHONY: install | ||
install: ## Setup development environment | ||
tflint --init | ||
terraform init -upgrade | ||
|
||
lint: | ||
terraform fmt --check | ||
.PHONY: lint | ||
lint: ## Lint Terraform files | ||
terraform fmt --recursive | ||
tflint --format compact --module | ||
|
||
help: | ||
@echo "Usage:" | ||
@echo " make Format, lint and generate document" | ||
@echo " make init Install tflint plugins" | ||
@echo " make format Format all *.tf files" | ||
@echo " make lint Lint check" | ||
@echo " make docs Generating document (README.md)" | ||
.PHONY: validate | ||
validate: ## Validate Terraform files | ||
terraform fmt --check | ||
terraform validate | ||
|
||
.PHONY: docs | ||
docs: ## Generate README.md | ||
terraform-docs markdown . \ | ||
--sort-by required \ | ||
--output-file README.md \ | ||
--output-mode insert |