Skip to content

Commit

Permalink
Merge pull request #4 from orange-cloudfoundry/orange-terraform-custo
Browse files Browse the repository at this point in the history
Orange terraform custo
  • Loading branch information
o-orand authored Jan 10, 2018
2 parents f9a831f + 49f63d7 commit b64d987
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.3
2.3.1
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
[![Build Status](https://travis-ci.org/alphagov/paas-docker-cloudfoundry-tools.svg)](https://travis-ci.org/alphagov/paas-docker-cloudfoundry-tools)

Orange: [![Build Status](https://travis-ci.org/orange-cloudfoundry/paas-docker-cloudfoundry-tools.svg)](https://travis-ci.org/orange-cloudfoundry/paas-docker-cloudfoundry-tools)
AlphaGov: [![Build Status](https://travis-ci.org/alphagov/paas-docker-cloudfoundry-tools.svg)](https://travis-ci.org/alphagov/paas-docker-cloudfoundry-tools)

Orange specifics:
* spiff (only in this repo)
* terraform (overrides Alphagov)

--------------------

Contains Dockerfiles to build the Cloud foundry tools.

Expand Down
2 changes: 2 additions & 0 deletions spiff/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Orange: [![Build Status](https://travis-ci.org/orange-cloudfoundry/paas-docker-cloudfoundry-tools.svg)](https://travis-ci.org/orange-cloudfoundry/paas-docker-cloudfoundry-tools)

Installs [spiff](https://github.com/cloudfoundry-incubator/spiff).

It uses alpine linux image as base and deploys statically compiled spiff release which runs directly.
Expand Down
53 changes: 49 additions & 4 deletions terraform/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,58 @@
FROM alpine:3.4
FROM alpine:3.7

ENV PATH $PATH:/usr/local/bin
ENV TERRAFORM_VER 0.8.5
ENV TERRAFORM_SUM 4b4324e354c26257f0b830eacb0e7cc7e2ced017d78855f74cb9377f1abf1dd7
ENV TERRAFORM_SHARED_DIR /root/.terraform.d/plugins/linux_amd64
ENV TERRAFORM_VER 0.11.2
ENV TERRAFORM_SUM f728fa73ff2a4c4235a28de4019802531758c7c090b6ca4c024d48063ab8537b
ENV TERRAFORM_ZIP terraform_${TERRAFORM_VER}_linux_amd64.zip

RUN apk add --update openssl openssh-client ca-certificates && rm -rf /var/cache/apk/*

ENV PROVIDER_CLOUDFOUNDRY_VERSION 0.9.1
#ENV PROVIDER_CLOUDFOUNDRY_SUM TODO-xxx

ENV PROVIDER_CREDHUB_VERSION 0.10.0
#ENV PROVIDER_CREDHUB_SUM TODO-yyy


RUN mkdir -p ${TERRAFORM_SHARED_DIR}

RUN apk add --update openssl openssh-client ca-certificates wget && rm -rf /var/cache/apk/*


RUN set -ex \
&& wget https://releases.hashicorp.com/terraform/${TERRAFORM_VER}/${TERRAFORM_ZIP} -O /tmp/${TERRAFORM_ZIP} \
&& echo "${TERRAFORM_SUM} /tmp/${TERRAFORM_ZIP}" | sha256sum -c - \
&& unzip /tmp/${TERRAFORM_ZIP} -d /usr/local/bin \
&& rm /tmp/${TERRAFORM_ZIP}


# Terraform CF provider name is not version dependant
RUN set -ex \
&& export FILENAME="terraform-provider-cloudfoundry" \
&& export FILENAME_SUFFIX="_0.10_linux_amd64" \
&& export FULL_FILENAME="$FILENAME$FILENAME_SUFFIX" \
&& export URL="https://github.com/orange-cloudfoundry/terraform-provider-cloudfoundry/releases/download/v${PROVIDER_CLOUDFOUNDRY_VERSION}/${FULL_FILENAME}" \
&& export SUM=${PROVIDER_CLOUDFOUNDRY_SUM} \
&& wget ${URL} -O /tmp/${FULL_FILENAME} \
&& mv /tmp/${FULL_FILENAME} ${TERRAFORM_SHARED_DIR}/${FILENAME} \
&& chmod +x ${TERRAFORM_SHARED_DIR}/*
# && echo "${SUM} /tmp/${FILENAME}" | sha256sum -c - \

# Terraform Credhub provider name is not version dependant
RUN set -ex \
&& export FILENAME="terraform-provider-credhub" \
&& export FILENAME_SUFFIX="_0.10_linux_amd64" \
&& export FULL_FILENAME="$FILENAME$FILENAME_SUFFIX" \
&& export URL="https://github.com/orange-cloudfoundry/terraform-provider-credhub/releases/download/v${PROVIDER_CREDHUB_VERSION}/${FULL_FILENAME}" \
&& export SUM=${PROVIDER_CREDHUB_SUM} \
&& wget ${URL} -O /tmp/${FULL_FILENAME} \
&& mv /tmp/${FULL_FILENAME} ${TERRAFORM_SHARED_DIR}/${FILENAME} \
&& chmod +x ${TERRAFORM_SHARED_DIR}/*
# && echo "${SUM} /tmp/${FILENAME}" | sha256sum -c - \


ENV TF_DATA_DIR "/root/.terraform.d"
COPY plugin_cache.tf /tmp/
RUN cd /tmp && terraform init

ENV TF_INPUT 0
6 changes: 4 additions & 2 deletions terraform/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[![Build Status](https://travis-ci.org/alphagov/paas-docker-terraform.svg)](https://travis-ci.org/alphagov/paas-docker-terraform)
Orange: [![Build Status](https://travis-ci.org/orange-cloudfoundry/paas-docker-cloudfoundry-tools.svg)](https://travis-ci.org/orange-cloudfoundry/paas-docker-cloudfoundry-tools)
AlphaGov: [![Build Status](https://travis-ci.org/alphagov/paas-docker-cloudfoundry-tools.svg)](https://travis-ci.org/alphagov/paas-docker-cloudfoundry-tools)

# docker-terraform

This container allows you to run Terraform inside a Docker container.
This container allows you to run Terraform inside a Docker container with plugins already downloaded.

## How to run and build

Expand Down
9 changes: 9 additions & 0 deletions terraform/plugin_cache.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
provider "terraform" {version = "~> 1.0.2"}
provider "openstack" {version = "~> 1.1.0"}
provider "cloudflare" {version = "~> 0.1.0"}
provider "local" { version = "~> 1.0.0"}
provider "powerdns" {version = "~> 0.1.0"}

# Orange provider
provider "credhub" {}
provider "cloudfoundry" {}
50 changes: 44 additions & 6 deletions terraform/terraform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
describe "Terraform image" do
before(:all) {
set :docker_image, find_image_id('terraform:latest')
@terraform_version_output = command("terraform version").stdout
}

it "installs Alpine" do
Expand All @@ -16,9 +17,7 @@
end

it "has the expected Terraform version" do
expect(
command("terraform version").stdout
).to include("Terraform v0.8.5")
expect(@terraform_version_output).to include("Terraform v0.11.2")
end

it "installs SSH" do
Expand All @@ -27,9 +26,48 @@
).to include("OpenSSH")
end

it "should not have binary directory larger than 200M" do
it "has the plugins already downloaded" do
expect(
command("cd /tmp && terraform init").stdout.strip
).to_not include("Downloading")
end

it "disables interactive Terraform use" do
expect(
Integer(command("du -m /usr/local/bin").stdout.split.first)
).to be < 200
command("printenv TF_INPUT").stdout.strip
).to eq("0")
end

context "providers checks" do

it "has the cloudflare provider" do
expect(@terraform_version_output).to include("provider.cloudflare v0.1.0")
end

it "has the local provider" do
expect(@terraform_version_output).to include("provider.local v1.0.0")
end

it "has the openstack provider" do
expect(@terraform_version_output).to include("provider.openstack v1.1.0")
end

it "has the powerdns provider" do
expect(@terraform_version_output).to include("provider.powerdns v0.1.0")
end

it "has the credhub provider" do
expect(@terraform_version_output).to include("provider.credhub (unversioned)")
end

it "has the cloudfoundry provider" do
expect(@terraform_version_output).to include("provider.cloudfoundry (unversioned)")
end

it "has enough providers" do
expect(@terraform_version_output.scan('provider.').length).to eq(6)
end

end

end

0 comments on commit b64d987

Please sign in to comment.