-
Notifications
You must be signed in to change notification settings - Fork 469
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
terraform version upgrade and code reorg (#39)
terraform version upgrade and code reorg
- Loading branch information
Showing
21 changed files
with
331 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,40 @@ | ||
# Pull the base image with given version. | ||
ARG BUILD_TERRAFORM_VERSION=0.11.7 | ||
FROM microsoft/terraform-test:${BUILD_TERRAFORM_VERSION} | ||
ARG BUILD_TERRAFORM_VERSION="0.12.10" | ||
FROM mcr.microsoft.com/terraform-test:${BUILD_TERRAFORM_VERSION} | ||
|
||
ARG MODULE_NAME="terraform-azurerm-aks" | ||
|
||
# Set work directory | ||
RUN mkdir -p /go/src/${MODULE_NAME} | ||
RUN mkdir -p /go/bin | ||
# Declare default build configurations for terraform. | ||
ARG BUILD_ARM_SUBSCRIPTION_ID="" | ||
ARG BUILD_ARM_CLIENT_ID="" | ||
ARG BUILD_ARM_CLIENT_SECRET="" | ||
ARG BUILD_ARM_TENANT_ID="" | ||
ARG BUILD_ARM_TEST_LOCATION="WestEurope" | ||
ARG BUILD_ARM_TEST_LOCATION_ALT="WestUS" | ||
|
||
# Set environment variables for terraform runtime. | ||
ENV ARM_SUBSCRIPTION_ID=${BUILD_ARM_SUBSCRIPTION_ID} | ||
ENV ARM_CLIENT_ID=${BUILD_ARM_CLIENT_ID} | ||
ENV ARM_CLIENT_SECRET=${BUILD_ARM_CLIENT_SECRET} | ||
ENV ARM_TENANT_ID=${BUILD_ARM_TENANT_ID} | ||
ENV ARM_TEST_LOCATION=${BUILD_ARM_TEST_LOCATION} | ||
ENV ARM_TEST_LOCATION_ALT=${BUILD_ARM_TEST_LOCATION_ALT} | ||
|
||
# Set environment variables for variables used in AKS. | ||
ENV TF_VAR_client_id=${BUILD_ARM_CLIENT_ID} | ||
ENV TF_VAR_client_secret=${BUILD_ARM_CLIENT_SECRET} | ||
|
||
# Set work directory. | ||
RUN mkdir /go | ||
RUN mkdir /go/bin | ||
RUN mkdir /go/src | ||
RUN mkdir /go/src/${MODULE_NAME} | ||
COPY . /go/src/${MODULE_NAME} | ||
WORKDIR /go/src/${MODULE_NAME} | ||
|
||
# Install required go packages using dep ensure | ||
# Install dep. | ||
ENV GOPATH /go | ||
ENV PATH $GOPATH/bin:$PATH | ||
ENV PATH /usr/local/go/bin:$GOPATH/bin:$PATH | ||
RUN /bin/bash -c "curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh" | ||
|
||
COPY . /go/src/${MODULE_NAME} | ||
RUN chmod 744 test.sh | ||
RUN ["bundle", "install", "--gemfile", "./Gemfile"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
ruby "~> 2.3.0" | ||
|
||
source 'https://rubygems.org/' | ||
|
||
group :test do | ||
git 'https://github.com/Azure/terramodtest.git' do | ||
gem 'terramodtest', :tag => 'v0.3.0' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Official gems. | ||
require 'colorize' | ||
require 'rspec/core/rake_task' | ||
|
||
# Git repo gems. | ||
require 'bundler/setup' | ||
require 'terramodtest' | ||
|
||
namespace :presteps do | ||
task :ensure do | ||
puts "Using dep ensure to install required go packages.\n" | ||
success = system ("dep ensure") | ||
if not success | ||
raise "ERROR: Dep ensure failed!\n".red | ||
end | ||
end | ||
end | ||
|
||
namespace :static do | ||
task :style do | ||
style_tf | ||
end | ||
task :lint do | ||
success = system ("terraform init") | ||
if not success | ||
raise "ERROR: terraform init failed!\n".red | ||
end | ||
lint_tf | ||
end | ||
task :format do | ||
format_tf | ||
end | ||
end | ||
|
||
namespace :integration do | ||
task :test do | ||
success = system ("go test -v ./test/ -timeout 45m") | ||
if not success | ||
raise "ERROR: Go test failed!\n".red | ||
end | ||
end | ||
end | ||
|
||
task :prereqs => [ 'presteps:ensure' ] | ||
|
||
task :validate => [ 'static:style', 'static:lint' ] | ||
|
||
task :format => [ 'static:format' ] | ||
|
||
task :build => [ 'prereqs', 'validate' ] | ||
|
||
task :unit => [] | ||
|
||
task :e2e => [ 'integration:test' ] | ||
|
||
task :default => [ 'build' ] | ||
|
||
task :full => [ 'build', 'unit', 'e2e' ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
# Azure pipeline for Terraform AKS module | ||
|
||
pool: | ||
vmImage: 'Ubuntu 16.04' | ||
vmImage: 'ubuntu-latest' | ||
|
||
variables: | ||
imagename: terraform-azurerm-aks:$(build.buildId) | ||
image_name: terraform-azurerm-aks:$(build.buildId) | ||
terraform_version: 0.12.10 | ||
|
||
steps: | ||
- script: docker build -f Dockerfile -t $(imageName) . | ||
displayName: 'docker build' | ||
- script: docker build --build-arg BUILD_TERRAFORM_VERSION=${TERRAFORM_VERSION} -t ${IMAGE_NAME} . | ||
displayName: 'docker build' | ||
|
||
- script: docker run ${IMAGE_NAME} rake build | ||
displayName: 'validate' | ||
|
||
- script: docker run -e "ARM_SUBSCRIPTION_ID=$AZURE_SUBSCRIPTION_ID" -e "ARM_CLIENT_ID=$AZURE_CLIENT_ID" -e "ARM_CLIENT_SECRET=$AZURE_CLIENT_SECRET" -e "ARM_TENANT_ID=$AZURE_TENANT_ID" -e "ARM_TEST_LOCATION=WestUS2" -e "ARM_TEST_LOCATION_ALT=EastUS" --rm $(imageName) bash -c "./test.sh validate" | ||
displayName: 'docker run' | ||
- script: docker run $(IMAGE_NAME) rake full | ||
displayName: 'full build' | ||
condition: and(succeeded(),eq(variables['build.sourceBranch'], 'refs/heads/master')) |
Oops, something went wrong.