Skip to content

Commit 08c7efd

Browse files
authored
Merge pull request #19 from cytopia/release-0.9
Release 0.9
2 parents 5b50922 + 18a9384 commit 08c7efd

14 files changed

+168
-34
lines changed

.travis.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ sudo: required
99
###
1010
### Language
1111
###
12-
language: python
12+
language: minimal
1313

1414

1515
###
@@ -39,18 +39,24 @@ env:
3939
### Install requirements
4040
###
4141
install:
42-
# Get newer docker version
43-
- while ! sudo apt-get update; do sleep 1; done
44-
- while ! sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce; do sleep 1; done
45-
- docker version
42+
- retry() {
43+
for ((n=0; n<10; n++)); do
44+
echo "[${n}] ${*}";
45+
if eval "${*}"; then
46+
return 0;
47+
fi;
48+
done;
49+
return 1;
50+
}
4651

4752

4853
###
4954
### Check generation changes, build and test
5055
###
5156
before_script:
52-
- while ! make build TAG=${VERSION}; do sleep 1; done
53-
- while ! make test TAG=${VERSION}; do sleep 1; done
57+
- retry make lint
58+
- retry make build TAG=${VERSION}
59+
- retry make test TAG=${VERSION}
5460
- git diff --quiet || { echo "Build Changes"; git diff; git status; false; }
5561

5662

Dockerfile

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,62 @@
1-
FROM golang:stretch as builder
1+
FROM golang:alpine3.9 as builder
22

33
# Install dependencies
44
RUN set -x \
5-
&& DEBIAN_FRONTEND=noninteractive apt-get update -qq \
6-
&& DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests \
5+
&& apk add --no-cache \
6+
curl \
7+
gcc \
78
git \
8-
gox \
9+
make \
10+
musl-dev \
911
&& curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
1012

1113
# Get and build terraform-docs
12-
ARG VERSION
14+
ARG VERSION=latest
1315
RUN set -x \
1416
&& export GOPATH=/go \
1517
&& mkdir -p /go/src/github.com/segmentio \
1618
&& git clone https://github.com/segmentio/terraform-docs /go/src/github.com/segmentio/terraform-docs \
1719
&& cd /go/src/github.com/segmentio/terraform-docs \
18-
&& if [ ${VERSION} != "latest" ]; then \
20+
&& if [ "${VERSION}" != "latest" ]; then \
1921
git checkout v${VERSION}; \
2022
fi \
2123
# Build terraform-docs <= 0.3.0
2224
&& if [ "${VERSION}" = "0.3.0" ] || [ "${VERSION}" = "0.2.0" ] || [ "${VERSION}" = "0.1.1" ] || [ "${VERSION}" = "0.1.0" ]; then \
2325
go get github.com/hashicorp/hcl \
26+
&& go get github.com/mitchellh/gox \
2427
&& go get github.com/tj/docopt \
28+
&& sed -i'' 's/darwin//g' Makefile \
29+
&& sed -i'' 's/windows//g' Makefile \
2530
&& make \
26-
&& mkdir -p bin/linux-amd64 \
27-
&& mv dist/terraform-docs_linux_amd64 bin/linux-amd64/terraform-docs; \
31+
&& mv dist/terraform-docs_linux_amd64 /usr/local/bin/terraform-docs; \
2832
# Build terraform-docs > 0.3.0
2933
else \
3034
make deps \
3135
&& make test \
3236
&& make build-linux-amd64 \
33-
&& if [ ${VERSION} = "0.4.0" ]; then \
34-
mkdir -p bin/linux-amd64 \
35-
&& mv bin/terraform-docs-v${VERSION}-linux-amd64 bin/linux-amd64/terraform-docs; \
37+
&& if [ "${VERSION}" = "0.4.0" ]; then \
38+
mv bin/terraform-docs-v${VERSION}-linux-amd64 /usr/local/bin/terraform-docs; \
39+
else \
40+
mv bin/linux-amd64/terraform-docs /usr/local/bin/terraform-docs; \
3641
fi \
3742
fi \
38-
&& chmod +x bin/linux-amd64/terraform-docs
43+
&& chmod +x /usr/local/bin/terraform-docs
44+
45+
# Version pre-check
46+
RUN set -x \
47+
&& if [ "${VERSION}" != "latest" ]; then \
48+
terraform-docs --version | grep "${VERSION}"; \
49+
else \
50+
terraform-docs --version | grep -E "(terraform-docs[[:space:]])?(version[[:space:]])?dev"; \
51+
fi
52+
3953

4054
# Use a clean tiny image to store artifacts in
41-
FROM alpine:3.9
55+
FROM alpine:3.8
4256
LABEL \
4357
maintainer="cytopia <cytopia@everythingcli.org>" \
4458
repo="https://github.com/cytopia/docker-terraform-docs"
45-
COPY --from=builder /go/src/github.com/segmentio/terraform-docs/bin/linux-amd64/terraform-docs /usr/local/bin/terraform-docs
59+
COPY --from=builder /usr/local/bin/terraform-docs /usr/local/bin/terraform-docs
4660
COPY ./data/docker-entrypoint.sh /docker-entrypoint.sh
4761
COPY ./data/terraform-docs.awk /terraform-docs.awk
4862

Makefile

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ifneq (,)
22
.error This Makefile requires GNU Make.
33
endif
44

5-
.PHONY: build rebuild lint test _test_version _test_run tag pull login push enter
5+
.PHONY: build rebuild lint test _test-version _test-run-one _test-run-two tag pull login push enter
66

77
CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
88

@@ -26,10 +26,11 @@ lint:
2626
@docker run --rm -v $(CURRENT_DIR):/data cytopia/file-lint file-utf8-bom --text --ignore '.git/,.github/,tests/' --path .
2727

2828
test:
29-
@$(MAKE) --no-print-directory _test_version
30-
@$(MAKE) --no-print-directory _test_run
29+
@$(MAKE) --no-print-directory _test-version
30+
@$(MAKE) --no-print-directory _test-run-one
31+
@$(MAKE) --no-print-directory _test-run-two
3132

32-
_test_version:
33+
_test-version:
3334
@echo "------------------------------------------------------------"
3435
@echo "- Testing correct version"
3536
@echo "------------------------------------------------------------"
@@ -42,8 +43,8 @@ _test_version:
4243
| head -1 \
4344
| sed 's/.*v//g' \
4445
)"; \
45-
echo "Testing for latest: $${LATEST}"; \
46-
if ! docker run --rm $(IMAGE) | grep -E "^v?$${LATEST}$$"; then \
46+
echo "Testing for latest: dev"; \
47+
if ! docker run --rm $(IMAGE) | grep -E "^(terraform-docs[[:space:]])?(version[[:space:]])?dev"; then \
4748
echo "Failed"; \
4849
exit 1; \
4950
fi; \
@@ -56,9 +57,30 @@ _test_version:
5657
fi; \
5758
echo "Success"; \
5859

59-
_test_run:
60+
_test-run-one:
6061
@echo "------------------------------------------------------------"
61-
@echo "- Testing terraform-docs"
62+
@echo "- Testing terraform-docs (1/2)"
63+
@echo "------------------------------------------------------------"
64+
@echo '<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->' > tests/basic/TEST-$(TAG).md
65+
@echo >> tests/basic/TEST-$(TAG).md
66+
@echo '<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->' >> tests/basic/TEST-$(TAG).md
67+
@if ! docker run --rm -v $(CURRENT_DIR)/tests/basic:/data $(IMAGE) terraform-docs-replace md TEST-$(TAG).md; then \
68+
echo "Failed"; \
69+
exit 1; \
70+
fi; \
71+
if ! grep '## Inputs' tests/basic/TEST-$(TAG).md; then \
72+
echo "Failed"; \
73+
exit 1; \
74+
fi; \
75+
if ! grep 'test description' tests/basic/TEST-$(TAG).md; then \
76+
echo "Failed"; \
77+
exit 1; \
78+
fi; \
79+
echo "Success";
80+
81+
_test-run-two:
82+
@echo "------------------------------------------------------------"
83+
@echo "- Testing terraform-docs (2/2)"
6284
@echo "------------------------------------------------------------"
6385
$(eval TFDOC_ARG_SORT = $(shell \
6486
if [ "$(TAG)" = "latest" ] || [ "$(TAG)" = "0.6.0" ] || [ "$(TAG)" = "0.5.0" ]; then \
@@ -70,10 +92,12 @@ _test_run:
7092
echo "--with-aggregate-type-defaults"; \
7193
fi; \
7294
))
95+
@# ---- Test Terraform < 0.12 ----
7396
@if ! docker run --rm -v $(CURRENT_DIR)/tests/default:/data $(IMAGE) terraform-docs-replace $(TFDOC_ARG_SORT) $(TFDOC_ARG_AGGREGATE) md TEST-$(TAG).md; then \
7497
echo "Failed"; \
7598
exit 1; \
7699
fi
100+
@# ---- Test Terraform >= 0.12 ----
77101
@if ! docker run --rm -v $(CURRENT_DIR)/tests/0.12:/data $(IMAGE) terraform-docs-replace-012 $(TFDOC_ARG_SORT) $(TFDOC_ARG_AGGREGATE) md TEST-$(TAG).md; then \
78102
echo "Failed"; \
79103
exit 1; \

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@
1717
> [eslint](https://github.com/cytopia/docker-eslint) ****
1818
> [file-lint](https://github.com/cytopia/docker-file-lint) ****
1919
> [gofmt](https://github.com/cytopia/docker-gofmt) ****
20+
> [goimports](https://github.com/cytopia/docker-goimports) ****
2021
> [golint](https://github.com/cytopia/docker-golint) ****
2122
> [jsonlint](https://github.com/cytopia/docker-jsonlint) ****
23+
> [phpcbf](https://github.com/cytopia/docker-phpcbf) ****
2224
> [phpcs](https://github.com/cytopia/docker-phpcs) ****
25+
> [php-cs-fixer](https://github.com/cytopia/docker-php-cs-fixer) ****
2326
> [pycodestyle](https://github.com/cytopia/docker-pycodestyle) ****
2427
> [pylint](https://github.com/cytopia/docker-pylint) ****
2528
> [terraform-docs](https://github.com/cytopia/docker-terraform-docs) ****
2629
> [terragrunt](https://github.com/cytopia/docker-terragrunt) ****
30+
> [terragrunt-fmt](https://github.com/cytopia/docker-terragrunt-fmt) ****
2731
> [yamllint](https://github.com/cytopia/docker-yamllint)
2832
2933

@@ -314,9 +318,9 @@ output is always up-to-date and will fail otherwise (due to git changes):
314318
```yml
315319
---
316320
sudo: required
321+
language: minimal
317322
services:
318323
- docker
319-
before_install: true
320324
install: true
321325
script:
322326
- make gen
@@ -344,20 +348,26 @@ linter below for reproducible local or remote CI tests:
344348
|--------------|------|-------------|
345349
| [awesome-ci](https://github.com/cytopia/awesome-ci) | Basic | Tools for git, file and static source code analysis |
346350
| [file-lint](https://github.com/cytopia/docker-file-lint) | Basic | Baisc source code analysis |
347-
| [jsonlint](https://github.com/cytopia/docker-jsonlint) | Basic | Lint JSON files |
351+
| [jsonlint](https://github.com/cytopia/docker-jsonlint) | Basic | Lint JSON files **<sup>[1]</sup>** |
348352
| [yamllint](https://github.com/cytopia/docker-yamllint) | Basic | Lint Yaml files |
349353
| [ansible](https://github.com/cytopia/docker-ansible) | Ansible | Multiple versoins of Ansible |
350354
| [ansible-lint](https://github.com/cytopia/docker-ansible-lint) | Ansible | Lint Ansible |
351-
| [gofmt](https://github.com/cytopia/docker-gofmt) | Go | Format Go source code |
355+
| [gofmt](https://github.com/cytopia/docker-gofmt) | Go | Format Go source code **<sup>[1]</sup>** |
356+
| [goimports](https://github.com/cytopia/docker-goimports) | Go | Format Go source code **<sup>[1]</sup>** |
352357
| [golint](https://github.com/cytopia/docker-golint) | Go | Lint Go code |
353358
| [eslint](https://github.com/cytopia/docker-eslint) | Javascript | Lint Javascript code |
354359
| [checkmake](https://github.com/cytopia/docker-checkmake) | Make | Lint Makefiles |
355-
| [phpcs](https://github.com/cytopia/docker-phpcs) | PHP | PHPCodeSniffer and Code Beautifier and Fixer |
360+
| [phpcbf](https://github.com/cytopia/docker-phpcbf) | PHP | PHP Code Beautifier and Fixer |
361+
| [phpcs](https://github.com/cytopia/docker-phpcs) | PHP | PHP Code Sniffer |
362+
| [php-cs-fixer](https://github.com/cytopia/docker-php-cs-fixer) | PHP | PHP Coding Standards Fixer |
356363
| [black](https://github.com/cytopia/docker-black) | Python | The uncompromising Python code formatter |
357364
| [pycodestyle](https://github.com/cytopia/docker-pycodestyle) | Python | Python style guide checker |
358365
| [pylint](https://github.com/cytopia/docker-pylint) | Python | Python source code, bug and quality checker |
359-
| [terraform-docs](https://github.com/cytopia/docker-terraform-docs) | Terraform | Terraform doc generator (TF 0.12 ready) |
366+
| [terraform-docs](https://github.com/cytopia/docker-terraform-docs) | Terraform | Terraform doc generator (TF 0.12 ready) **<sup>[1]</sup>** |
360367
| [terragrunt](https://github.com/cytopia/docker-terragrunt) | Terraform | Terragrunt and Terraform |
368+
| [terragrunt-fmt](https://github.com/cytopia/docker-terragrunt-fmt) | Terraform | `terraform fmt` for Terragrunt files **<sup>[1]</sup>** |
369+
370+
> **<sup>[1]</sup>** Uses a shell wrapper to add **enhanced functionality** not available by original project.
361371
362372
363373
### Makefiles

tests/basic/TEST-0.1.0.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2+
3+
## Inputs
4+
5+
| Name | Description | Default | Required |
6+
|------|-------------|:-----:|:-----:|
7+
| test | test description | - | yes |
8+
9+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

tests/basic/TEST-0.1.1.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2+
3+
## Inputs
4+
5+
| Name | Description | Type | Default | Required |
6+
|------|-------------|:----:|:-----:|:-----:|
7+
| test | test description | string | - | yes |
8+
9+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

tests/basic/TEST-0.2.0.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2+
3+
## Inputs
4+
5+
| Name | Description | Type | Default | Required |
6+
|------|-------------|:----:|:-----:|:-----:|
7+
| test | test description | string | - | yes |
8+
9+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

tests/basic/TEST-0.3.0.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2+
3+
## Inputs
4+
5+
| Name | Description | Type | Default | Required |
6+
|------|-------------|:----:|:-----:|:-----:|
7+
| test | test description | string | - | yes |
8+
9+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

tests/basic/TEST-0.4.0.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2+
3+
## Inputs
4+
5+
| Name | Description | Type | Default | Required |
6+
|------|-------------|:----:|:-----:|:-----:|
7+
| test | test description | string | - | yes |
8+
9+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

tests/basic/TEST-0.4.5.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2+
## Inputs
3+
4+
| Name | Description | Type | Default | Required |
5+
|------|-------------|:----:|:-----:|:-----:|
6+
| test | test description | string | - | yes |
7+
8+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

tests/basic/TEST-0.5.0.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2+
## Inputs
3+
4+
| Name | Description | Type | Default | Required |
5+
|------|-------------|:----:|:-----:|:-----:|
6+
| test | test description | string | - | yes |
7+
8+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

tests/basic/TEST-0.6.0.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2+
## Inputs
3+
4+
| Name | Description | Type | Default | Required |
5+
|------|-------------|:----:|:-----:|:-----:|
6+
| test | test description | string | n/a | yes |
7+
8+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

tests/basic/TEST-latest.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2+
## Inputs
3+
4+
| Name | Description | Type | Default | Required |
5+
|------|-------------|:----:|:-----:|:-----:|
6+
| test | test description | string | n/a | yes |
7+
8+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

tests/basic/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
variable "test" {
2+
description = "test description"
3+
}

0 commit comments

Comments
 (0)