зеркало из https://github.com/Azure/terramodtest.git
add terraform init
This commit is contained in:
Родитель
21c5f56913
Коммит
4ae3539a3a
|
@ -1,12 +1,12 @@
|
|||
*.gem
|
||||
*.rbc
|
||||
/.config
|
||||
/coverage/
|
||||
/InstalledFiles
|
||||
/pkg/
|
||||
/spec/reports/
|
||||
/spec/examples.txt
|
||||
/test/tmp/
|
||||
/test/version_tmp/
|
||||
/tmp/
|
||||
|
||||
*.gem
|
||||
*.rbc
|
||||
/.config
|
||||
/coverage/
|
||||
/InstalledFiles
|
||||
/pkg/
|
||||
/spec/reports/
|
||||
/spec/examples.txt
|
||||
/test/tmp/
|
||||
/test/version_tmp/
|
||||
/tmp/
|
||||
|
||||
|
|
42
LICENSE
42
LICENSE
|
@ -1,21 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
||||
|
|
18
README.md
18
README.md
|
@ -1,9 +1,9 @@
|
|||
# Azure Terraform Module Test Utilities
|
||||
Test utilities for azure terraform module developer to write tests more easily.
|
||||
|
||||
# Terraform 0.12 support
|
||||
This module provides terraform 0.12 support alongside 0.11.
|
||||
|
||||
# Contributing
|
||||
|
||||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
||||
# Azure Terraform Module Test Utilities
|
||||
Test utilities for azure terraform module developer to write tests more easily.
|
||||
|
||||
# Terraform 0.12 support
|
||||
This module provides terraform 0.12 support alongside 0.11.
|
||||
|
||||
# Contributing
|
||||
|
||||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
require 'validate/file_utils.rb'
|
||||
require 'validate/static_utils.rb'
|
||||
require 'validate/file_utils.rb'
|
||||
require 'validate/static_utils.rb'
|
||||
require 'validate/test_kitchen.rb'
|
|
@ -1,15 +1,15 @@
|
|||
require 'fileutils'
|
||||
|
||||
def clean_up_kitchen
|
||||
if File.exists? '.kitchen'
|
||||
print "INFO: Cleaning up the .kitchen folder...\n"
|
||||
FileUtils.rm_rf('.kitchen')
|
||||
end
|
||||
end
|
||||
|
||||
def clean_up_terraform
|
||||
if File.exists? '.terraform'
|
||||
print "INFO: Cleaning up the .terraform folder...\n"
|
||||
FileUtils.rm_rf('.terraform')
|
||||
end
|
||||
end
|
||||
require 'fileutils'
|
||||
|
||||
def clean_up_kitchen
|
||||
if File.exists? '.kitchen'
|
||||
print "INFO: Cleaning up the .kitchen folder...\n"
|
||||
FileUtils.rm_rf('.kitchen')
|
||||
end
|
||||
end
|
||||
|
||||
def clean_up_terraform
|
||||
if File.exists? '.terraform'
|
||||
print "INFO: Cleaning up the .terraform folder...\n"
|
||||
FileUtils.rm_rf('.terraform')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,10 @@ def lint_tf
|
|||
if ENV['TERRAFORM_VERSION'].nil? || ENV['TERRAFORM_VERSION'].start_with?("0.11.")
|
||||
message = `terraform validate -check-variables=false 2>&1`
|
||||
elsif ENV['TERRAFORM_VERSION'].start_with?("0.12.")
|
||||
success = system ("terraform init")
|
||||
if not success
|
||||
raise "ERROR: terraform init failed!\n".red
|
||||
end
|
||||
message = `terraform validate >/dev/null`
|
||||
end
|
||||
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
require 'colorize'
|
||||
require 'fileutils'
|
||||
|
||||
def kitchen_converge
|
||||
success = system("kitchen converge")
|
||||
if not success
|
||||
raise "ERROR: Test kitchen converge failed!\n".red
|
||||
end
|
||||
end
|
||||
|
||||
def kitchen_verify
|
||||
success = system("kitchen verify")
|
||||
if not success
|
||||
raise "ERROR: Test kitchen verify failed!\n".red
|
||||
end
|
||||
end
|
||||
|
||||
def kitchen_test
|
||||
success = system("kitchen test")
|
||||
if not success
|
||||
raise "ERROR: Test kitchen test failed!\n".red
|
||||
end
|
||||
end
|
||||
|
||||
def kitchen_destroy
|
||||
success = system("kitchen destroy")
|
||||
if not success
|
||||
raise "ERROR: Test kitchen destroy failed!\n".red
|
||||
end
|
||||
end
|
||||
require 'colorize'
|
||||
require 'fileutils'
|
||||
|
||||
def kitchen_converge
|
||||
success = system("kitchen converge")
|
||||
if not success
|
||||
raise "ERROR: Test kitchen converge failed!\n".red
|
||||
end
|
||||
end
|
||||
|
||||
def kitchen_verify
|
||||
success = system("kitchen verify")
|
||||
if not success
|
||||
raise "ERROR: Test kitchen verify failed!\n".red
|
||||
end
|
||||
end
|
||||
|
||||
def kitchen_test
|
||||
success = system("kitchen test")
|
||||
if not success
|
||||
raise "ERROR: Test kitchen test failed!\n".red
|
||||
end
|
||||
end
|
||||
|
||||
def kitchen_destroy
|
||||
success = system("kitchen destroy")
|
||||
if not success
|
||||
raise "ERROR: Test kitchen destroy failed!\n".red
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
version = "0.3.0"
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.name = "terramodtest"
|
||||
s.version = version
|
||||
s.summary = "Test utilities for terraform modules."
|
||||
s.description = "Provide test utilities for terraform module developer."
|
||||
|
||||
s.required_ruby_version = ">= 2.3.0"
|
||||
|
||||
s.license = "MIT"
|
||||
|
||||
s.author = "Su Shi"
|
||||
|
||||
s.files = Dir["lib/**/*"]
|
||||
s.require_path = "lib"
|
||||
s.requirements << "none"
|
||||
|
||||
s.metadata = {
|
||||
"source_code_uri" => "https://github.com/Azure/terramodtest/tree/v#{version}/validate"
|
||||
}
|
||||
|
||||
s.add_dependency "colorize", "~> 0.8.0"
|
||||
end
|
||||
version = "0.3.0"
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.name = "terramodtest"
|
||||
s.version = version
|
||||
s.summary = "Test utilities for terraform modules."
|
||||
s.description = "Provide test utilities for terraform module developer."
|
||||
|
||||
s.required_ruby_version = ">= 2.3.0"
|
||||
|
||||
s.license = "MIT"
|
||||
|
||||
s.author = "Su Shi"
|
||||
|
||||
s.files = Dir["lib/**/*"]
|
||||
s.require_path = "lib"
|
||||
s.requirements << "none"
|
||||
|
||||
s.metadata = {
|
||||
"source_code_uri" => "https://github.com/Azure/terramodtest/tree/v#{version}/validate"
|
||||
}
|
||||
|
||||
s.add_dependency "colorize", "~> 0.8.0"
|
||||
end
|
||||
|
|
|
@ -1,95 +1,95 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Check if OS is supported.
|
||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||
TERRAFORM_OS_ARCH=linux_amd64
|
||||
GOLANG_OS_ARCH=linux-amd64
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
TERRAFORM_OS_ARCH=darwin_amd64
|
||||
GOLANG_OS_ARCH=darwin-amd64
|
||||
else
|
||||
echo "Unsupported Operating System: $OSTYPE" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Version, OS and Arch for Terraform.
|
||||
TERRAFORM_VERSION="0.11.7"
|
||||
# Version for Ruby SDK.
|
||||
RUBY_VERSION="2.3.3"
|
||||
RUBY_INSTALLED_VERSION_REGEX="^(ruby) ([0-9].[0-9].[0-9]p[0-9]+)"
|
||||
RBENV_INSTALLED_VERSION_REGEX="^(rbenv) ([0-9].[0-9].[0-9])"
|
||||
# Versions for gem packages.
|
||||
GEM_BUNDLER_VERSION="1.16.0"
|
||||
GEM_COLORIZE_VERSION="0.8.1"
|
||||
GEM_KITCHEN_TERRAFORM_VERSION="3.0.0"
|
||||
GEM_TEST_KITCHEN_VERSION="1.16.0"
|
||||
GEM_RAKE_VERSION="12.3.0"
|
||||
GEM_RSPEC_VERSION="3.7.0"
|
||||
# Version for Golang.
|
||||
GOLANG_VERSION="1.10.3"
|
||||
|
||||
# Install rbenv & ruby-build.
|
||||
if type rbenv &> /dev/null; then
|
||||
echo "rbenv was previously installed."
|
||||
else
|
||||
# Clean up legacy .rbenv
|
||||
if [[ -d "$HOME/.rbenv" ]]; then
|
||||
echo "Clean up legacy ~/.rbenv."
|
||||
rm -rf "$HOME/.rbenv"
|
||||
fi
|
||||
|
||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||
# rbenv.
|
||||
apt-get update && \
|
||||
apt-get install autoconf bison build-essential libssl-dev libyaml-dev \
|
||||
libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 \
|
||||
libgdbm-dev unzip
|
||||
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
|
||||
export PATH="$HOME/.rbenv/bin:$PATH"
|
||||
# ruby-build.
|
||||
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
|
||||
else # darwin*
|
||||
# rbenv & ruby-build.
|
||||
brew update && \
|
||||
brew install rbenv ruby-build
|
||||
fi
|
||||
fi
|
||||
|
||||
# Initialize rbenv.
|
||||
eval "$(rbenv init -)"
|
||||
|
||||
# Install Ruby SDK.
|
||||
# TODO: skip unneccessary install.
|
||||
rbenv install ${RUBY_VERSION} && rbenv global ${RUBY_VERSION}
|
||||
|
||||
# Install Terraform runtime.
|
||||
curl -Os https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_${TERRAFORM_OS_ARCH}.zip && \
|
||||
curl -Os https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_SHA256SUMS && \
|
||||
curl -s https://keybase.io/hashicorp/pgp_keys.asc | gpg --import && \
|
||||
curl -Os https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_SHA256SUMS.sig && \
|
||||
gpg --verify terraform_${TERRAFORM_VERSION}_SHA256SUMS.sig terraform_${TERRAFORM_VERSION}_SHA256SUMS && \
|
||||
shasum -a 256 -c terraform_${TERRAFORM_VERSION}_SHA256SUMS 2>&1 | grep "${TERRAFORM_VERSION}_${TERRAFORM_OS_ARCH}.zip:\sOK" && \
|
||||
unzip -o terraform_${TERRAFORM_VERSION}_${TERRAFORM_OS_ARCH}.zip -d /usr/local/bin
|
||||
# Cleanup downloaded files.
|
||||
rm terraform_${TERRAFORM_VERSION}_${TERRAFORM_OS_ARCH}.zip
|
||||
rm terraform_${TERRAFORM_VERSION}_SHA256SUMS
|
||||
rm terraform_${TERRAFORM_VERSION}_SHA256SUMS.sig
|
||||
|
||||
# Install Go SDK.
|
||||
curl -Os https://storage.googleapis.com/golang/go${GOLANG_VERSION}.${GOLANG_OS_ARCH}.tar.gz >/dev/null 2>&1 && \
|
||||
tar -zxvf go${GOLANG_VERSION}.${GOLANG_OS_ARCH}.tar.gz -C /usr/local/ >/dev/null
|
||||
|
||||
# Install Gem packages.
|
||||
gem update --system && \
|
||||
gem install bundler --no-document --version=${GEM_BUNDLER_VERSION} --user-install && \
|
||||
gem install colorize --no-document --version=${GEM_COLORIZE} --user-install && \
|
||||
gem install rake --no-document --version=${GEM_RAKE_VERSION} --user-install && \
|
||||
gem install rspec --no-document --version=${GEM_RSPEC_VERSION} --user-install
|
||||
|
||||
# Refresh Go environment.
|
||||
export GOPATH="$HOME/go"
|
||||
export PATH="/usr/local/go/bin:$GOPATH/bin:$PATH"
|
||||
|
||||
# Install Go dep.
|
||||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Check if OS is supported.
|
||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||
TERRAFORM_OS_ARCH=linux_amd64
|
||||
GOLANG_OS_ARCH=linux-amd64
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
TERRAFORM_OS_ARCH=darwin_amd64
|
||||
GOLANG_OS_ARCH=darwin-amd64
|
||||
else
|
||||
echo "Unsupported Operating System: $OSTYPE" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Version, OS and Arch for Terraform.
|
||||
TERRAFORM_VERSION="0.11.7"
|
||||
# Version for Ruby SDK.
|
||||
RUBY_VERSION="2.3.3"
|
||||
RUBY_INSTALLED_VERSION_REGEX="^(ruby) ([0-9].[0-9].[0-9]p[0-9]+)"
|
||||
RBENV_INSTALLED_VERSION_REGEX="^(rbenv) ([0-9].[0-9].[0-9])"
|
||||
# Versions for gem packages.
|
||||
GEM_BUNDLER_VERSION="1.16.0"
|
||||
GEM_COLORIZE_VERSION="0.8.1"
|
||||
GEM_KITCHEN_TERRAFORM_VERSION="3.0.0"
|
||||
GEM_TEST_KITCHEN_VERSION="1.16.0"
|
||||
GEM_RAKE_VERSION="12.3.0"
|
||||
GEM_RSPEC_VERSION="3.7.0"
|
||||
# Version for Golang.
|
||||
GOLANG_VERSION="1.10.3"
|
||||
|
||||
# Install rbenv & ruby-build.
|
||||
if type rbenv &> /dev/null; then
|
||||
echo "rbenv was previously installed."
|
||||
else
|
||||
# Clean up legacy .rbenv
|
||||
if [[ -d "$HOME/.rbenv" ]]; then
|
||||
echo "Clean up legacy ~/.rbenv."
|
||||
rm -rf "$HOME/.rbenv"
|
||||
fi
|
||||
|
||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||
# rbenv.
|
||||
apt-get update && \
|
||||
apt-get install autoconf bison build-essential libssl-dev libyaml-dev \
|
||||
libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 \
|
||||
libgdbm-dev unzip
|
||||
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
|
||||
export PATH="$HOME/.rbenv/bin:$PATH"
|
||||
# ruby-build.
|
||||
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
|
||||
else # darwin*
|
||||
# rbenv & ruby-build.
|
||||
brew update && \
|
||||
brew install rbenv ruby-build
|
||||
fi
|
||||
fi
|
||||
|
||||
# Initialize rbenv.
|
||||
eval "$(rbenv init -)"
|
||||
|
||||
# Install Ruby SDK.
|
||||
# TODO: skip unneccessary install.
|
||||
rbenv install ${RUBY_VERSION} && rbenv global ${RUBY_VERSION}
|
||||
|
||||
# Install Terraform runtime.
|
||||
curl -Os https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_${TERRAFORM_OS_ARCH}.zip && \
|
||||
curl -Os https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_SHA256SUMS && \
|
||||
curl -s https://keybase.io/hashicorp/pgp_keys.asc | gpg --import && \
|
||||
curl -Os https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_SHA256SUMS.sig && \
|
||||
gpg --verify terraform_${TERRAFORM_VERSION}_SHA256SUMS.sig terraform_${TERRAFORM_VERSION}_SHA256SUMS && \
|
||||
shasum -a 256 -c terraform_${TERRAFORM_VERSION}_SHA256SUMS 2>&1 | grep "${TERRAFORM_VERSION}_${TERRAFORM_OS_ARCH}.zip:\sOK" && \
|
||||
unzip -o terraform_${TERRAFORM_VERSION}_${TERRAFORM_OS_ARCH}.zip -d /usr/local/bin
|
||||
# Cleanup downloaded files.
|
||||
rm terraform_${TERRAFORM_VERSION}_${TERRAFORM_OS_ARCH}.zip
|
||||
rm terraform_${TERRAFORM_VERSION}_SHA256SUMS
|
||||
rm terraform_${TERRAFORM_VERSION}_SHA256SUMS.sig
|
||||
|
||||
# Install Go SDK.
|
||||
curl -Os https://storage.googleapis.com/golang/go${GOLANG_VERSION}.${GOLANG_OS_ARCH}.tar.gz >/dev/null 2>&1 && \
|
||||
tar -zxvf go${GOLANG_VERSION}.${GOLANG_OS_ARCH}.tar.gz -C /usr/local/ >/dev/null
|
||||
|
||||
# Install Gem packages.
|
||||
gem update --system && \
|
||||
gem install bundler --no-document --version=${GEM_BUNDLER_VERSION} --user-install && \
|
||||
gem install colorize --no-document --version=${GEM_COLORIZE} --user-install && \
|
||||
gem install rake --no-document --version=${GEM_RAKE_VERSION} --user-install && \
|
||||
gem install rspec --no-document --version=${GEM_RSPEC_VERSION} --user-install
|
||||
|
||||
# Refresh Go environment.
|
||||
export GOPATH="$HOME/go"
|
||||
export PATH="/usr/local/go/bin:$GOPATH/bin:$PATH"
|
||||
|
||||
# Install Go dep.
|
||||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
||||
|
|
Загрузка…
Ссылка в новой задаче