Skip to content

Commit

Permalink
Merge pull request #15 from confusdcodr/patch
Browse files Browse the repository at this point in the history
Patch configuration errors
  • Loading branch information
confusdcodr authored Feb 24, 2020
2 parents e5f2cee + e1e5c7e commit 3f88e6e
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 210 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.0.8
current_version = 0.0.9
commit = True
message = Bumps version to {new_version}
tag = False
Expand Down
27 changes: 27 additions & 0 deletions .dependabot/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: 1

update_configs:

- package_manager: "terraform"
directory: "/"
update_schedule: "daily"

- package_manager: "terraform"
directory: "/tests/vault-py2"
update_schedule: "daily"

- package_manager: "terraform"
directory: "/tests/vault-py3"
update_schedule: "daily"

- package_manager: "go:modules"
directory: "/tests"
update_schedule: "daily"

- package_manager: "python"
directory: "/"
update_schedule: "live"

- package_manager: "docker"
directory: "/"
update_schedule: "daily"
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trim_trailing_whitespace = false

[*.py]
indent_style = space
indent_size = 2
indent_size = 4

[*.go]
indent_style = tab
Expand Down
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ vendor/
go.mod
go.sum


#Vagrant related files
.vagrant/
.pillar/

# tardigrade-ci
.tardigrade-ci
tardigrade-ci/

# eclint
.git/

pillar/
27 changes: 2 additions & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,8 @@ stages:
jobs:
include:
- stage: lint
name: EditorConfig Syntax Verification
install:
- npm install -g eclint
- eclint --version
script: eclint check
- stage: lint
name: Shell Script Syntax Verification
script: make sh/lint
- stage: lint
name: JSON Lint/Format Verification
script: make json/lint
- stage: lint
language: python
python: 3.6
name: Python Lint/Format Verification
install: pip install -r requirements/dev.txt
script: make python/lint
- stage: lint
name: Terraform Lint/Format Verification
install:
- make terraform/install
- make terraform-docs/install
script:
- make terraform/lint
- make docs/lint
name: Project Syntax Verification
script: make && make docker/run target=lint
- stage: deploy
if: branch = master AND type = push AND repo = plus3it/terraform-aws-vault
before_script:
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM plus3it/tardigrade-ci:0.0.8

WORKDIR /ci-harness
ENTRYPOINT ["make"]
138 changes: 2 additions & 136 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,137 +1,3 @@
ARCH ?= amd64
OS ?= $(shell uname -s | tr '[:upper:]' '[:lower:'])
CURL ?= curl --fail -sSL
XARGS ?= xargs -I {}
BIN_DIR ?= ${HOME}/bin
TMP ?= /tmp
FIND_EXCLUDES ?= -not \( -name .terraform -prune \) -not \( -name .terragrunt-cache -prune \)
SHELL := /bin/bash

PATH := $(BIN_DIR):${PATH}

MAKEFLAGS += --no-print-directory
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c

.PHONY: guard/% %/install %/lint

GITHUB_ACCESS_TOKEN ?= 4224d33b8569bec8473980bb1bdb982639426a92
# Macro to return the download url for a github release
# For latest release, use version=latest
# To pin a release, use version=tags/<tag>
# $(call parse_github_download_url,owner,repo,version,asset select query)
parse_github_download_url = $(CURL) https://api.github.com/repos/$(1)/$(2)/releases/$(3)?access_token=$(GITHUB_ACCESS_TOKEN) | jq --raw-output '.assets[] | select($(4)) | .browser_download_url'

# Macro to download a github binary release
# $(call download_github_release,file,owner,repo,version,asset select query)
download_github_release = $(CURL) -o $(1) $(shell $(call parse_github_download_url,$(2),$(3),$(4),$(5)))

# Macro to download a hashicorp archive release
# $(call download_hashicorp_release,file,app,version)
download_hashicorp_release = $(CURL) -o $(1) https://releases.hashicorp.com/$(2)/$(3)/$(2)_$(3)_$(OS)_$(ARCH).zip

guard/env/%:
@ _="$(or $($*),$(error Make/environment variable '$*' not present))"

guard/program/%:
@ which $* > /dev/null || $(MAKE) $*/install

$(BIN_DIR):
@ echo "[make]: Creating directory '$@'..."
mkdir -p $@

install/gh-release/%: guard/env/FILENAME guard/env/OWNER guard/env/REPO guard/env/VERSION guard/env/QUERY
install/gh-release/%:
@ echo "[$@]: Installing $*..."
$(call download_github_release,$(FILENAME),$(OWNER),$(REPO),$(VERSION),$(QUERY))
chmod +x $(FILENAME)
$* --version
@ echo "[$@]: Completed successfully!"

zip/install:
@ echo "[$@]: Installing $(@D)..."
apt-get install zip -y
@ echo "[$@]: Completed successfully!"

terraform/install: TERRAFORM_VERSION_LATEST := $(CURL) https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M '.current_version' | sed 's/^v//'
terraform/install: TERRAFORM_VERSION ?= $(shell $(TERRAFORM_VERSION_LATEST))
terraform/install: | $(BIN_DIR) guard/program/jq
@ echo "[$@]: Installing $(@D)..."
$(call download_hashicorp_release,$(@D).zip,$(@D),$(TERRAFORM_VERSION))
unzip $(@D).zip && rm -f $(@D).zip && chmod +x $(@D)
mv $(@D) "$(BIN_DIR)"
$(@D) --version
@ echo "[$@]: Completed successfully!"

terraform-docs/install: TFDOCS_VERSION ?= latest
terraform-docs/install: | $(BIN_DIR) guard/program/jq
@ $(MAKE) install/gh-release/$(@D) FILENAME="$(BIN_DIR)/$(@D)" OWNER=segmentio REPO=$(@D) VERSION=$(TFDOCS_VERSION) QUERY='.name | endswith("$(OS)-$(ARCH)")'

jq/install: JQ_VERSION ?= latest
jq/install: | $(BIN_DIR)
@ $(MAKE) install/gh-release/$(@D) FILENAME="$(BIN_DIR)/$(@D)" OWNER=stedolan REPO=$(@D) VERSION=$(JQ_VERSION) QUERY='.name | endswith("$(OS)64")'

shellcheck/install: SHELLCHECK_VERSION ?= latest
shellcheck/install: SHELLCHECK_URL ?= https://storage.googleapis.com/shellcheck/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz
shellcheck/install: $(BIN_DIR) guard/program/xz
$(CURL) $(SHELLCHECK_URL) | tar -xJv
mv $(@D)-*/$(@D) $(BIN_DIR)
rm -rf $(@D)-*
$(@D) --version

terraform/lint: | guard/program/terraform
@ echo "[$@]: Linting Terraform files..."
terraform fmt -check=true -diff=true
@ echo "[$@]: Terraform files PASSED lint test!"

sh/%: FIND_SH := find . $(FIND_EXCLUDES) -name '*.sh' -type f -print0
sh/lint: | guard/program/shellcheck
@ echo "[$@]: Linting shell scripts..."
$(FIND_SH) | $(XARGS) shellcheck {} -e SC2154,SC2086
@ echo "[$@]: Shell scripts PASSED lint test!"

json/%: FIND_JSON := find . $(FIND_EXCLUDES) -name '*.json' -type f
json/lint: | guard/program/jq
@ echo "[$@]: Linting JSON files..."
$(FIND_JSON) | $(XARGS) bash -c 'cmp {} <(jq --indent 4 -S . {}) || (echo "[{}]: Failed JSON Lint Test"; exit 1)'
@ echo "[$@]: JSON files PASSED lint test!"

json/format: | guard/program/jq
@ echo "[$@]: Formatting JSON files..."
$(FIND_JSON) | $(XARGS) bash -c 'echo "$$(jq --indent 4 -S . "{}")" > "{}"'
@ echo "[$@]: Successfully formatted JSON files!"

tfdocs-awk/install: $(BIN_DIR)
tfdocs-awk/install: ARCHIVE := https://github.com/plus3it/tfdocs-awk/archive/0.0.2.tar.gz
tfdocs-awk/install:
$(CURL) $(ARCHIVE) | tar -C $(BIN_DIR) --strip-components=1 --wildcards '*.sh' --wildcards '*.awk' -xzvf -

docs/generate: | tfdocs-awk/install guard/program/terraform-docs
@ echo "[$@]: Creating documentation files.."
@ bash -eu -o pipefail autodocs.sh -g
@ echo "[$@]: Documentation generated!"

docs/lint: | tfdocs-awk/install guard/program/terraform-docs
@ echo "[$@] Linting documentation files.."
@ bash -eu -o pipefail autodocs.sh -l
@ echo "[$@] Documentation linting complete!"

python/lint: | guard/program/black
@ echo "[$@]: Linting Python files..."
black --check .
@ echo "[$@]: Python files PASSED lint test!"

python/format: | guard/program/black
@ echo "[$@]: Formatting Python files..."
black .
@ echo "[$@]: Successfully formatted Python files!"


terratest/install: | guard/program/go
cd tests && go mod init terraform-aws-vault/tests
cd tests && go build ./...
cd tests && go mod tidy

terratest/test: | guard/program/go
cd tests && go test -count=1 -timeout 60m

test: terratest/test
-include $(shell curl -sSL -o .tardigrade-ci "https://raw.githubusercontent.com/plus3it/tardigrade-ci/master/bootstrap/Makefile.bootstrap"; echo .tardigrade-ci)
Empty file modified README.md
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion modules/iam/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ data "template_file" "instance_policy" {
}

data "aws_iam_policy_document" "instance_policy" {
source_json = data.template_file.instance_policy.rendered
source_json = data.template_file.instance_policy.rendered
override_json = var.override_json
}

Expand Down
4 changes: 2 additions & 2 deletions modules/iam/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ variable "role_name" {

variable "override_json" {
description = "Override the current policy document."
type = string
default = ""
type = string
default = ""
}

# ---------------------------------------------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 3f88e6e

Please sign in to comment.