Skip to content

Commit

Permalink
Add support for Terraform 0.15 (#452)
Browse files Browse the repository at this point in the history
* Allow Terraform 0.15.0 - 1.0.0

* Format with rufo

* Redesign for InitFactory

* Normalize init arguments

* Add PostZeroFifteenZero to InitFactory

* Extract Command::Version from VerifyVersion

* Redesign to use InitFactory

* Add attributes-post-0-15-0 suite

* Add pre/post 0.15 validate commands

* Use ValidateFactory in Converge

* Add post 0.15 backend-ssh suite

* Add post 0.15 plug-ins suite

* Add variables-post-0-15-0 suite

* Add workspaces-post-0-15-0 suite

* Add GHA job for Terraform 0.15

* Update TF install for ruby_2_7_tf15

* Rename config attr to complete_config

* Replace path.cwd with path.module

* Fix key file pathname

* Fix Windows workspaces task name

* Output absolute paths

* Refactor Converge#initialize

* Refactor Create#call

* Refactor Destroy#call

* Refactor Converge#call

* Remove obsolete options from Init#initialize

* Prepare for 5.8.0 release
  • Loading branch information
aaron-lane authored May 19, 2021
1 parent 3a5d19f commit 6e07f5b
Show file tree
Hide file tree
Showing 76 changed files with 1,537 additions and 537 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ SHASUM3=ca9fe963f261236b3f3308f8b4979cdd95dd68281b00c1c18a6d17db07519ac8

PLUGIN_DIR='test/terraform/11/PlugIns/PlugInDirectory'
MAJOR_VERSION=$(echo $TERRAFORM_VERSION|sed 's/0\.\([0-9][0-9]*\)\.[0-9][0-9]*$/\1/')
if [ "$MAJOR_VERSION" -ge 13 ]; then
if [ "$MAJOR_VERSION" -ge 15 ]; then
PLUGIN_DIR="test/terraform/post-0-15-0/PlugIns/PlugInDirectory/registry.terraform.io/hashicorp/local/1.4.0/linux_amd64"
elif [ "$MAJOR_VERSION" -ge 13 ]; then
PLUGIN_DIR="${PLUGIN_DIR}/registry.terraform.io/hashicorp/local/1.4.0/linux_amd64"
fi
mkdir -p "$PLUGIN_DIR"
Expand Down
4 changes: 3 additions & 1 deletion .github/actions/install-tf-macos/install-tf-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ SHASUM3=7ef13da7e8ae7129fae8a9c72845d52d4586db496359228ed435aeab2f44aea8

PLUGIN_DIR='test/terraform/11/PlugIns/PlugInDirectory'
MAJOR_VERSION=$(echo $TERRAFORM_VERSION|sed 's/0\.\([0-9][0-9]*\)\.[0-9][0-9]*$/\1/')
if [ "$MAJOR_VERSION" -ge 13 ]; then
if [ "$MAJOR_VERSION" -ge 15 ]; then
PLUGIN_DIR="test/terraform/post-0-15-0/PlugIns/PlugInDirectory/registry.terraform.io/hashicorp/local/1.4.0/linux_amd64"
elif [ "$MAJOR_VERSION" -ge 13 ]; then
PLUGIN_DIR="${PLUGIN_DIR}/registry.terraform.io/hashicorp/local/1.4.0/darwin_amd64"
fi
mkdir -p "$PLUGIN_DIR"
Expand Down
5 changes: 4 additions & 1 deletion .github/actions/install-tf-win/install-tf-win.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ $PLUGIN_DIR_END='PlugInDirectory'
# MAJOR_VERSION=$(echo $TERRAFORM_VERSION|sed 's/0\.\([0-9][0-9]*\)\.[0-9][0-9]*$/\1/')
$MAJOR_VERSION=$(Select-String -Input $ENV:TERRAFORM_VERSION "0\.([0-9]+)\.[0-9]+" |
ForEach-Object { $_.Matches[0].Groups[1].Value })
if ("$MAJOR_VERSION" -ge 13) {
if ("$MAJOR_VERSION" -ge 15) {
$PLUGIN_DIR_PARENT="test/terraform/post-0-15-0/PlugIns/${PLUGIN_DIR_END}/registry.terraform.io/hashicorp/local/1.4.0/"
$PLUGIN_DIR_END="windows_amd64"
} elseif ("$MAJOR_VERSION" -ge 13) {
$PLUGIN_DIR_PARENT="${PLUGIN_DIR_PARENT}/${PLUGIN_DIR_END}/registry.terraform.io/hashicorp/local/1.4.0/"
$PLUGIN_DIR_END="windows_amd64"
}
Expand Down
45 changes: 40 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
./$GEMFILE_DIR/bin/rake test:kitchen:attributes-linux
./$GEMFILE_DIR/bin/rake test:kitchen:plug-ins-11-linux
./$GEMFILE_DIR/bin/rake test:kitchen:variables-linux
./$GEMFILE_DIR/bin/rake test:kitchen:workspaces-linux
./$GEMFILE_DIR/bin/rake test:kitchen:workspaces-pre-0-15-0-linux
# this test does not run under ruby 2.7
# chmod 400 test/terraform/backend-ssh/id_ed25519
# ./$GEMFILE_DIR/bin/rake test:kitchen:backend-ssh-linux
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
./$GEMFILE_DIR/bin/rake test:kitchen:attributes-osx
./$GEMFILE_DIR/bin/rake test:kitchen:plug-ins-11-osx
./$GEMFILE_DIR/bin/rake test:kitchen:variables-osx
./$GEMFILE_DIR/bin/rake test:kitchen:workspaces-osx
./$GEMFILE_DIR/bin/rake test:kitchen:workspaces-pre-0-15-0-osx
test_macos_ruby_2_7_tf13:
Expand Down Expand Up @@ -149,7 +149,7 @@ jobs:
./$GEMFILE_DIR/bin/rake test:kitchen:attributes-osx
./$GEMFILE_DIR/bin/rake test:kitchen:plug-ins-11-osx
./$GEMFILE_DIR/bin/rake test:kitchen:variables-osx
./$GEMFILE_DIR/bin/rake test:kitchen:workspaces-osx
./$GEMFILE_DIR/bin/rake test:kitchen:workspaces-pre-0-15-0-osx
test_macos_ruby_2_7_tf14:
name: MacOS Ruby 2.7 TF14
Expand Down Expand Up @@ -177,7 +177,42 @@ jobs:
./$GEMFILE_DIR/bin/rake test:kitchen:attributes-osx
./$GEMFILE_DIR/bin/rake test:kitchen:plug-ins-11-osx
./$GEMFILE_DIR/bin/rake test:kitchen:variables-osx
./$GEMFILE_DIR/bin/rake test:kitchen:workspaces-osx
./$GEMFILE_DIR/bin/rake test:kitchen:workspaces-pre-0-15-0-osx
test_ubun_ruby_2_7_tf15:
name: Ubuntu Ruby 2.7 TF15
runs-on: ubuntu-latest
env:
GEMFILE_DIR: .
RUBY_VERSION: 2.7.x
TERRAFORM_VERSION: 0.15.2

steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Set up Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
- name: Setup bundler
uses: ./.github/actions/setup-bundler-for-testing
- name: Install TF
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 0.15.2
terraform_wrapper: false
- name: Install TF Extras
uses: ./.github/actions/install-tf-extras-linux
- name: Build
run: |
bundle install
chmod 400 test/terraform/post-0-15-0/backend-ssh/id_ed25519
./$GEMFILE_DIR/bin/rake test:kitchen:attributes-post-0-15-0-linux
./$GEMFILE_DIR/bin/rake test:kitchen:attributes-post-0-15-0-linux
./$GEMFILE_DIR/bin/rake test:kitchen:backend-ssh-post-0-15-0-linux
./$GEMFILE_DIR/bin/rake test:kitchen:plug-ins-post-0-15-0-linux
./$GEMFILE_DIR/bin/rake test:kitchen:variables-post-0-15-0-linux
./$GEMFILE_DIR/bin/rake test:kitchen:workspaces-post-0-15-0-linux
test_windows_ruby_2_7:
name: Windows Ruby 2.7
Expand Down Expand Up @@ -209,7 +244,7 @@ jobs:
ruby $rake_path test:kitchen:attributes-windows
ruby $rake_path test:kitchen:plug-ins-11-windows
ruby $rake_path test:kitchen:variables-windows
ruby $rake_path test:kitchen:workspaces-windows
ruby $rake_path test:kitchen:workspaces-pre-0-15-0-windows
echo 'done!'
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased][unreleased]

## [5.8.0] - 2021-05-18

### Added

- Support for Terraform 0.15.

## [5.7.2] - 2021-03-08

### Fixed
Expand Down Expand Up @@ -779,7 +785,8 @@ Gandalf the Free-As-In-Beer

- Initial release

[unreleased]: https://github.com/newcontext/kitchen-terraform/compare/v5.7.2...HEAD
[unreleased]: https://github.com/newcontext/kitchen-terraform/compare/v5.8.0...HEAD
[5.8.0]: https://github.com/newcontext/kitchen-terraform/compare/v5.7.2...v5.8.0
[5.7.2]: https://github.com/newcontext/kitchen-terraform/compare/v5.7.1...v5.7.2
[5.7.1]: https://github.com/newcontext/kitchen-terraform/compare/v5.7.0...v5.7.1
[5.7.0]: https://github.com/newcontext/kitchen-terraform/compare/v5.6.0...v5.7.0
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Installation instructions can be found in the
[Terraform: Install Terraform][terraform-install] article.

Kitchen-Terraform supports versions of Terraform in the interval of
`>= 0.11.4, < 0.15.0`.
`>= 0.11.4, < 1.1.0`.

[tfenv] can be used to manage versions of Terraform on the system.

Expand Down Expand Up @@ -102,7 +102,7 @@ example.
> Installing Kitchen-Terraform with RubyGems
```sh
gem install kitchen-terraform --version 5.7.2
gem install kitchen-terraform --version 5.8.0
```

This approach is not recommended as it requires more effort to install
Expand Down
6 changes: 3 additions & 3 deletions kitchen-terraform.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ end
require "kitchen/terraform/version.rb"
require "rubygems"

version_parts_strings = RUBY_VERSION.split('.')
version_parts_strings = RUBY_VERSION.split(".")
version_parts = []
version_parts_strings.each { |vp| version_parts.push(vp.to_i) }

Expand Down Expand Up @@ -50,7 +50,7 @@ end
if version_gt_25
specification.add_development_dependency "reek", "~> 6.0.2"
else
puts 'version <= 2.5'
puts "version <= 2.5"
specification.add_development_dependency "reek", "~> 5.5"
end

Expand All @@ -63,6 +63,6 @@ end
specification.add_runtime_dependency "tty-which", "~> 0.4.0"
specification.cert_chain = ["certs/gem-public_cert.pem"]
specification.required_ruby_version = [">= 2.4", "< 2.8"]
specification.requirements = ["Terraform >= v0.11.4, < v0.15.0"]
specification.requirements = ["Terraform >= v0.11.4, < v1.1.0"]
specification.signing_key = "certs/gem-private_key.pem" if $PROGRAM_NAME =~ /gem\z/
end
140 changes: 136 additions & 4 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,44 @@ suites:
output_third_output: first_output
controls:
- precedence
- name: attributes-post-0-15-0
driver:
root_module_directory: test/terraform/post-0-15-0/attributes
variables:
passthrough: value
verifier:
systems:
- name: default
backend: local
controls:
- default
profile_locations:
- test/integration/attributes
reporter:
- cli
- json:test/reports/inspec/default-attributes.json
- junit:test/reports/inspec/default-attributes.junit.xml
- junit2:test/reports/inspec/default-attributes.junit2.xml
- name: attrs_outputs
backend: local
attrs_outputs:
first_output: second_output
controls:
- attrs_outputs
profile_locations:
- test/integration/attributes
- name: precedence
backend: local
attrs:
- test/integration/attributes/Attribute File.yml
attrs_outputs:
first_output: second_output
second_output: third_output
output_third_output: first_output
controls:
- precedence
profile_locations:
- test/integration/attributes
- name: backend-ssh
excludes:
- osx
Expand Down Expand Up @@ -81,6 +119,40 @@ suites:
shell_command: /bin/sh
shell_options: -x
user: root
- name: backend-ssh-post-0-15-0
excludes:
- osx
- windows
driver:
root_module_directory: test/terraform/post-0-15-0/backend-ssh
verifier:
systems:
- name: bastion, hosts, key files, one remote profile location
backend: ssh
bastion_host_output: bastion_host
bastion_port: 2223
bastion_user: root
hosts:
- 172.21.0.2
key_files:
- test/terraform/post-0-15-0/backend-ssh/id_ed25519
port: 22
profile_locations:
- https://github.com/brentm5/chef-compliance-profile-test.git
user: root
- name: hosts output, password, proxy command, shell, two local profile locations
backend: ssh
hosts_output: hosts
password: root
port: 2222
profile_locations:
- test/integration/backend-ssh/behaviour
- test/integration/backend-ssh/state
proxy_command: nc %h %p
shell: true
shell_command: /bin/sh
shell_options: -x
user: root
- name: plug-ins-11
driver:
plugin_directory: test/terraform/11/PlugIns/PlugInDirectory
Expand All @@ -99,6 +171,16 @@ suites:
systems:
- name: default
backend: local
- name: plug-ins-post-0-15-0
driver:
plugin_directory: test/terraform/post-0-15-0/PlugIns/PlugInDirectory
root_module_directory: test/terraform/post-0-15-0/PlugIns
verifier:
systems:
- name: default
backend: local
profile_locations:
- test/integration/plug-ins
- name: variables
driver:
root_module_directory: test/terraform/variables
Expand All @@ -119,21 +201,71 @@ suites:
backend: local
controls:
- variables
- name: workspace-one
- name: variables-post-0-15-0
driver:
root_module_directory: test/terraform/post-0-15-0/variables
variable_files:
- test/terraform/post-0-15-0/variables/variable_files/Variable File.tfvars
variables:
string: 'A String'
map: '{ key = \"A Value\" }'
list_of_strings: '[ \"Element One\", \"Element Two\" ]'
list_of_maps: '[ { key = \"A List Of Maps Value\" } ]'
verifier:
systems:
- name: variable_files
backend: local
controls:
- variable_files
profile_locations:
- test/integration/variables
- name: variables
backend: local
controls:
- variables
profile_locations:
- test/integration/variables
- name: workspace-one-pre-0-15-0
driver:
root_module_directory: test/terraform/workspace
root_module_directory: test/terraform/pre-0-15-0/workspace
variables:
workspace: one
verifier:
systems:
- name: one
backend: local
- name: workspace-two
profile_locations:
- test/integration/workspace-one
- name: workspace-two-pre-0-15-0
driver:
root_module_directory: test/terraform/workspace
root_module_directory: test/terraform/pre-0-15-0/workspace
variables:
workspace: two
verifier:
systems:
- name: two
backend: local
profile_locations:
- test/integration/workspace-two
- name: workspace-one-post-0-15-0
driver:
root_module_directory: test/terraform/post-0-15-0/workspace
variables:
workspace: one
verifier:
systems:
- name: one
backend: local
profile_locations:
- test/integration/workspace-one
- name: workspace-two-post-0-15-0
driver:
root_module_directory: test/terraform/post-0-15-0/workspace
variables:
workspace: two
verifier:
systems:
- name: two
backend: local
profile_locations:
- test/integration/workspace-two
Loading

0 comments on commit 6e07f5b

Please sign in to comment.