Skip to content

Commit

Permalink
Merge branch 'master' into 1.0-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
morgante committed Jan 15, 2019
2 parents 3738754 + 72f0e31 commit ab49539
Show file tree
Hide file tree
Showing 25 changed files with 257 additions and 425 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ terraform.tfstate.d/
credentials.json
.vscode/
env/
test/fixtures/shared/terraform.tfvars
1 change: 1 addition & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ platforms:

verifier:
name: terraform
color: false
systems:
- name: system
backend: local
Expand Down
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.5.3
65 changes: 26 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,10 @@
SHELL := /usr/bin/env bash

# Docker build config variables
BUILD_TERRAFORM_VERSION ?= 0.11.10
BUILD_CLOUD_SDK_VERSION ?= 216.0.0
BUILD_PROVIDER_GOOGLE_VERSION ?= 1.19.1
BUILD_PROVIDER_GSUITE_VERSION ?= 0.1.10
DOCKER_IMAGE_TERRAFORM := cftk/terraform
DOCKER_TAG_TERRAFORM ?= ${BUILD_TERRAFORM_VERSION}_${BUILD_CLOUD_SDK_VERSION}_${BUILD_PROVIDER_GOOGLE_VERSION}_${BUILD_PROVIDER_GSUITE_VERSION}
BUILD_RUBY_VERSION ?= 2.5.3
DOCKER_IMAGE_KITCHEN_TERRAFORM := cftk/kitchen_terraform
DOCKER_TAG_KITCHEN_TERRAFORM ?= ${BUILD_TERRAFORM_VERSION}_${BUILD_CLOUD_SDK_VERSION}_${BUILD_PROVIDER_GOOGLE_VERSION}_${BUILD_PROVIDER_GSUITE_VERSION}

CREDENTIALS_PATH ?= /cft/workdir/credentials.json
DOCKER_ORG := gcr.io/cloud-foundation-cicd
DOCKER_TAG_BASE_KITCHEN_TERRAFORM ?= 0.11.10_216.0.0_1.19.1_0.1.10
DOCKER_REPO_BASE_KITCHEN_TERRAFORM := ${DOCKER_ORG}/cft/kitchen-terraform:${DOCKER_TAG_BASE_KITCHEN_TERRAFORM}

all: check_shell check_python check_golang check_terraform check_docker check_base_files test_check_headers check_headers check_trailing_whitespace generate_docs ## Run all linters and update documentation

Expand All @@ -45,8 +39,8 @@ check_golang: ## Lint Go source files
@source test/make.sh && golang

.PHONY: check_terraform
check_terraform:
@source ## Lint Terraform source files
check_terraform: ## Lint Terraform source files
@source test/make.sh && check_terraform

.PHONY: check_docker
check_docker: ## Lint Dockerfiles
Expand Down Expand Up @@ -92,57 +86,50 @@ generate_docs: ## Update README documentation for Terraform variables and output
release-new-version:
@source helpers/release-new-version.sh

# Build Docker
.PHONY: docker_build_terraform
docker_build_terraform:
docker build -f build/docker/terraform/Dockerfile \
--build-arg BUILD_TERRAFORM_VERSION=${BUILD_TERRAFORM_VERSION} \
--build-arg BUILD_CLOUD_SDK_VERSION=${BUILD_CLOUD_SDK_VERSION} \
--build-arg BUILD_PROVIDER_GOOGLE_VERSION=${BUILD_PROVIDER_GOOGLE_VERSION} \
--build-arg BUILD_PROVIDER_GSUITE_VERSION=${BUILD_PROVIDER_GSUITE_VERSION} \
-t ${DOCKER_IMAGE_TERRAFORM}:${DOCKER_TAG_TERRAFORM} .

.PHONY: docker_build_kitchen_terraform
docker_build_kitchen_terraform:
docker build -f build/docker/kitchen_terraform/Dockerfile \
--build-arg BUILD_TERRAFORM_IMAGE="${DOCKER_IMAGE_TERRAFORM}:${DOCKER_TAG_TERRAFORM}" \
--build-arg BUILD_RUBY_VERSION="${BUILD_RUBY_VERSION}" \
-t ${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} .

# Run docker
.PHONY: docker_run
docker_run: ## Launch a shell within the Docker test environment
docker run --rm -it \
-v $(CURDIR):/cftk/workdir \
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash

.PHONY: docker_create
docker_create: ## Run `kitchen create` within the Docker test environment
docker run --rm -it \
-v $(CURDIR):/cftk/workdir \
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash -c "bundle exec kitchen create"

.PHONY: docker_converge
docker_converge: ## Run `kitchen converge` within the Docker test environment
docker run --rm -it \
-v $(CURDIR):/cftk/workdir \
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash -c "bundle exec kitchen converge && bundle exec kitchen converge"

.PHONY: docker_verify
docker_verify: ## Run `kitchen verify` within the Docker test environment
docker run --rm -it \
-v $(CURDIR):/cftk/workdir \
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash -c "bundle exec kitchen verify"

.PHONY: docker_destroy
docker_destroy: ## Run `kitchen destroy` within the Docker test environment
docker run --rm -it \
-v $(CURDIR):/cftk/workdir \
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash -c "bundle exec kitchen destroy"

.PHONY: test_integration_docker
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,12 @@ test steps non-interactively.
#### Test configuration
Each test-kitchen instance is configured with a `terraform.tfvars` file in the
test fixture directory.
test fixture directory. For convenience, these are symlinked to a single shared file:
```sh
for instance in full minimal; do
cp "test/fixtures/$instance/terraform.tfvars.example" \
"test/fixtures/$instance/terraform.tfvars"
$EDITOR "test/fixtures/$instance/terraform.tfvars"
cp "test/fixtures/shared/terraform.tfvars.example" \
"test/fixtures/shared/terraform.tfvars"
$EDITOR "test/fixtures/shared/terraform.tfvars"
done
```

Expand Down
61 changes: 0 additions & 61 deletions build/docker/kitchen_terraform/Dockerfile

This file was deleted.

102 changes: 0 additions & 102 deletions build/docker/terraform/Dockerfile

This file was deleted.

8 changes: 4 additions & 4 deletions helpers/combine_docfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
import re
import sys

insert_separator_regex = '(.*?\[\^\]\:\ \(autogen_docs_start\))(.*?)(\n\[\^\]\:\ \(autogen_docs_end\).*?$)'
exclude_separator_regex = '(.*?)Copyright 20\d\d Google LLC.*?limitations under the License.(.*?)$'
insert_separator_regex = r'(.*?\[\^\]\:\ \(autogen_docs_start\))(.*?)(\n\[\^\]\:\ \(autogen_docs_end\).*?$)'
exclude_separator_regex = r'(.*?)Copyright 20\d\d Google LLC.*?limitations under the License.(.*?)$'

if len(sys.argv) != 3:
sys.exit(1)
print(sys.argv[1])
sys.exit(1)

input = open(sys.argv[1], "r").read()
replace_content = open(sys.argv[2], "r").read()

Expand Down
4 changes: 2 additions & 2 deletions helpers/init_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ EOF
# PLUGINS INSTALLATION #
# ####################################### #

sudo mkdir -p $TERRAFORM_PLUGINS_PATH
sudo mkdir -p "$TERRAFORM_PLUGINS_PATH"

# ####################################### #
# Install the terraform-provider-gsuite #
# ####################################### #

TERRAFORM_PROVIDER_GSUITE=https://github.com/DeviaVir/terraform-provider-gsuite/releases/download/v0.1.9/terraform-provider-gsuite_0.1.9_linux_amd64.tgz
curl -L $TERRAFORM_PROVIDER_GSUITE | sudo tar -C $TERRAFORM_PLUGINS_PATH -xz
curl -L $TERRAFORM_PROVIDER_GSUITE | sudo tar -C "$TERRAFORM_PLUGINS_PATH" -xz

# ####################################### #
# Google SDK Installation #
Expand Down
8 changes: 4 additions & 4 deletions helpers/release-new-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

if ! [ -z "$(git status --porcelain)" ]; then
if [ -n "$(git status --porcelain)" ]; then
echo -e "\nError, repository dirty, please commit or stash your changes.\n"
exit 1
fi
Expand All @@ -22,7 +22,7 @@ NEW_VERSION=$(grep '##' CHANGELOG.md | head -n 1 | cut -d' ' -f2)
NEW_RELEASE_NAME=v$NEW_VERSION
CURRENT_RELEASE_NAME=$(git describe --abbrev=0 --tags)

if [ $NEW_RELEASE_NAME == $CURRENT_RELEASE_NAME ]; then
if [ "$NEW_RELEASE_NAME" == "$CURRENT_RELEASE_NAME" ]; then
echo -e "\nLatest version already released.\n"
echo -e "If this is not so, make sure CHANGELOG.md is updated as necessary.\n"
exit 1
Expand All @@ -38,6 +38,6 @@ git checkout master && \

echo -e "Releasing $NEW_RELEASE_NAME...\n"

git tag -a $NEW_RELEASE_NAME -m $NEW_RELEASE_NAME && \
git tag -a "$NEW_RELEASE_NAME" -m "$NEW_RELEASE_NAME" && \
git push origin master --verbose && \
git push origin $NEW_RELEASE_NAME --verbose
git push origin "$NEW_RELEASE_NAME" --verbose
Loading

0 comments on commit ab49539

Please sign in to comment.