Skip to content
Snippets Groups Projects
Commit a6bf725e authored by Nicholas Klick's avatar Nicholas Klick
Browse files

WIP

parent 2d821a55
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,6 @@ variables:
BUILD_IMAGE_NAME: "$CI_REGISTRY_IMAGE/branches/$CI_COMMIT_REF_SLUG-$TERRAFORM_VERSION:$CI_COMMIT_SHA"
RELEASE_IMAGE_NAME: "$CI_REGISTRY_IMAGE/releases/$TERRAFORM_VERSION"
TF_ADDRESS: "$CI_API_V4_URL/projects/$CI_PROJECT_ID/terraform/state/$CI_PIPELINE_IID-$STATE_NAME"
TFPLANTOOL_VERSION: "v0.1.1"
.versions:
parallel:
......@@ -17,14 +16,6 @@ variables:
TERRAFORM_BINARY_VERSION: "0.14.11"
TERRAFORM_VERSION: "0.14"
STATE_NAME: terraform014
- BASE_IMAGE: "alpine:3.13.1"
TERRAFORM_BINARY_VERSION: "0.13.7"
TERRAFORM_VERSION: "0.13"
STATE_NAME: terraform013
- BASE_IMAGE: "alpine:3.13.1"
TERRAFORM_BINARY_VERSION: "0.12.31"
TERRAFORM_VERSION: "0.12"
STATE_NAME: terraform012
stages:
- lint
......@@ -66,7 +57,7 @@ build:
- .versions
stage: build
script:
- docker image build --tag "$BUILD_IMAGE_NAME" --build-arg BASE_IMAGE=$BASE_IMAGE --build-arg TERRAFORM_BINARY_VERSION=$TERRAFORM_BINARY_VERSION --build-arg TFPLANTOOL_VERSION=$TFPLANTOOL_VERSION .
- docker image build --tag "$BUILD_IMAGE_NAME" --build-arg BASE_IMAGE=$BASE_IMAGE .
- docker image push "$BUILD_IMAGE_NAME"
.test:
......@@ -105,7 +96,6 @@ test-plan:
script:
- gitlab-terraform plan
- if [[ ! -f "plan.cache" ]]; then echo "expected to find a plan.cache file"; exit 1; fi
- tfplantool -f plan.cache backend get -k username
- gitlab-terraform plan-json
- if [[ ! -f "plan.json" ]]; then echo "expected to find a plan.json file"; exit 1; fi
- mv plan.cache $TERRAFORM_VERSION-plan.cache
......
ARG BASE_IMAGE
FROM golang:1.16 AS tfplantool
ARG TFPLANTOOL_VERSION
ARG TERRAFORM_BINARY_VERSION
WORKDIR /tfplantool
RUN git clone --branch $TFPLANTOOL_VERSION --depth 1 https://gitlab.com/mattkasa/tfplantool.git .
RUN sed -i -e "/github\.com\/hashicorp\/terraform/s/ v.*\$/ v$TERRAFORM_BINARY_VERSION/" go.mod
RUN go get -d -v ./...
RUN CGO_ENABLED=0 GOOS=linux go build -tags terraform_${TERRAFORM_BINARY_VERSION} -a -installsuffix cgo -o tfplantool .
FROM $BASE_IMAGE
ARG TERRAFORM_BINARY_VERSION
......@@ -28,8 +16,6 @@ RUN ( curl -sLo terraform.zip "https://releases.hashicorp.com/terraform/${TERRAF
WORKDIR /
COPY --from=tfplantool /tfplantool/tfplantool /usr/bin/tfplantool
COPY src/bin/gitlab-terraform.sh /usr/bin/gitlab-terraform
RUN chmod +x /usr/bin/gitlab-terraform
......
......@@ -51,9 +51,6 @@ export TF_HTTP_RETRY_WAIT_MIN="${TF_HTTP_RETRY_WAIT_MIN:-5}"
export TF_IN_AUTOMATION=true
apply() {
if ! terraform_is_at_least 0.13.2; then
tfplantool -f "${plan_cache}" backend set -k password -v "${TF_PASSWORD}"
fi
terraform "${@}" -input=false "${plan_cache}"
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment