Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Commit 6e07f5b

Browse files
authored
Add support for Terraform 0.15 (#452)
* 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
1 parent 3a5d19f commit 6e07f5b

File tree

76 files changed

+1537
-537
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1537
-537
lines changed

.github/actions/install-tf-extras-linux/install-tf-extras-linux.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ SHASUM3=ca9fe963f261236b3f3308f8b4979cdd95dd68281b00c1c18a6d17db07519ac8
1818

1919
PLUGIN_DIR='test/terraform/11/PlugIns/PlugInDirectory'
2020
MAJOR_VERSION=$(echo $TERRAFORM_VERSION|sed 's/0\.\([0-9][0-9]*\)\.[0-9][0-9]*$/\1/')
21-
if [ "$MAJOR_VERSION" -ge 13 ]; then
21+
if [ "$MAJOR_VERSION" -ge 15 ]; then
22+
PLUGIN_DIR="test/terraform/post-0-15-0/PlugIns/PlugInDirectory/registry.terraform.io/hashicorp/local/1.4.0/linux_amd64"
23+
elif [ "$MAJOR_VERSION" -ge 13 ]; then
2224
PLUGIN_DIR="${PLUGIN_DIR}/registry.terraform.io/hashicorp/local/1.4.0/linux_amd64"
2325
fi
2426
mkdir -p "$PLUGIN_DIR"

.github/actions/install-tf-macos/install-tf-macos.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ SHASUM3=7ef13da7e8ae7129fae8a9c72845d52d4586db496359228ed435aeab2f44aea8
2727

2828
PLUGIN_DIR='test/terraform/11/PlugIns/PlugInDirectory'
2929
MAJOR_VERSION=$(echo $TERRAFORM_VERSION|sed 's/0\.\([0-9][0-9]*\)\.[0-9][0-9]*$/\1/')
30-
if [ "$MAJOR_VERSION" -ge 13 ]; then
30+
if [ "$MAJOR_VERSION" -ge 15 ]; then
31+
PLUGIN_DIR="test/terraform/post-0-15-0/PlugIns/PlugInDirectory/registry.terraform.io/hashicorp/local/1.4.0/linux_amd64"
32+
elif [ "$MAJOR_VERSION" -ge 13 ]; then
3133
PLUGIN_DIR="${PLUGIN_DIR}/registry.terraform.io/hashicorp/local/1.4.0/darwin_amd64"
3234
fi
3335
mkdir -p "$PLUGIN_DIR"

.github/actions/install-tf-win/install-tf-win.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ $PLUGIN_DIR_END='PlugInDirectory'
3838
# MAJOR_VERSION=$(echo $TERRAFORM_VERSION|sed 's/0\.\([0-9][0-9]*\)\.[0-9][0-9]*$/\1/')
3939
$MAJOR_VERSION=$(Select-String -Input $ENV:TERRAFORM_VERSION "0\.([0-9]+)\.[0-9]+" |
4040
ForEach-Object { $_.Matches[0].Groups[1].Value })
41-
if ("$MAJOR_VERSION" -ge 13) {
41+
if ("$MAJOR_VERSION" -ge 15) {
42+
$PLUGIN_DIR_PARENT="test/terraform/post-0-15-0/PlugIns/${PLUGIN_DIR_END}/registry.terraform.io/hashicorp/local/1.4.0/"
43+
$PLUGIN_DIR_END="windows_amd64"
44+
} elseif ("$MAJOR_VERSION" -ge 13) {
4245
$PLUGIN_DIR_PARENT="${PLUGIN_DIR_PARENT}/${PLUGIN_DIR_END}/registry.terraform.io/hashicorp/local/1.4.0/"
4346
$PLUGIN_DIR_END="windows_amd64"
4447
}

.github/workflows/tests.yml

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ jobs:
8888
./$GEMFILE_DIR/bin/rake test:kitchen:attributes-linux
8989
./$GEMFILE_DIR/bin/rake test:kitchen:plug-ins-11-linux
9090
./$GEMFILE_DIR/bin/rake test:kitchen:variables-linux
91-
./$GEMFILE_DIR/bin/rake test:kitchen:workspaces-linux
91+
./$GEMFILE_DIR/bin/rake test:kitchen:workspaces-pre-0-15-0-linux
9292
# this test does not run under ruby 2.7
9393
# chmod 400 test/terraform/backend-ssh/id_ed25519
9494
# ./$GEMFILE_DIR/bin/rake test:kitchen:backend-ssh-linux
@@ -120,7 +120,7 @@ jobs:
120120
./$GEMFILE_DIR/bin/rake test:kitchen:attributes-osx
121121
./$GEMFILE_DIR/bin/rake test:kitchen:plug-ins-11-osx
122122
./$GEMFILE_DIR/bin/rake test:kitchen:variables-osx
123-
./$GEMFILE_DIR/bin/rake test:kitchen:workspaces-osx
123+
./$GEMFILE_DIR/bin/rake test:kitchen:workspaces-pre-0-15-0-osx
124124
125125
126126
test_macos_ruby_2_7_tf13:
@@ -149,7 +149,7 @@ jobs:
149149
./$GEMFILE_DIR/bin/rake test:kitchen:attributes-osx
150150
./$GEMFILE_DIR/bin/rake test:kitchen:plug-ins-11-osx
151151
./$GEMFILE_DIR/bin/rake test:kitchen:variables-osx
152-
./$GEMFILE_DIR/bin/rake test:kitchen:workspaces-osx
152+
./$GEMFILE_DIR/bin/rake test:kitchen:workspaces-pre-0-15-0-osx
153153
154154
test_macos_ruby_2_7_tf14:
155155
name: MacOS Ruby 2.7 TF14
@@ -177,7 +177,42 @@ jobs:
177177
./$GEMFILE_DIR/bin/rake test:kitchen:attributes-osx
178178
./$GEMFILE_DIR/bin/rake test:kitchen:plug-ins-11-osx
179179
./$GEMFILE_DIR/bin/rake test:kitchen:variables-osx
180-
./$GEMFILE_DIR/bin/rake test:kitchen:workspaces-osx
180+
./$GEMFILE_DIR/bin/rake test:kitchen:workspaces-pre-0-15-0-osx
181+
182+
test_ubun_ruby_2_7_tf15:
183+
name: Ubuntu Ruby 2.7 TF15
184+
runs-on: ubuntu-latest
185+
env:
186+
GEMFILE_DIR: .
187+
RUBY_VERSION: 2.7.x
188+
TERRAFORM_VERSION: 0.15.2
189+
190+
steps:
191+
- name: Checkout repo
192+
uses: actions/checkout@v2
193+
- name: Set up Ruby
194+
uses: actions/setup-ruby@v1
195+
with:
196+
ruby-version: ${{ env.RUBY_VERSION }}
197+
- name: Setup bundler
198+
uses: ./.github/actions/setup-bundler-for-testing
199+
- name: Install TF
200+
uses: hashicorp/setup-terraform@v1
201+
with:
202+
terraform_version: 0.15.2
203+
terraform_wrapper: false
204+
- name: Install TF Extras
205+
uses: ./.github/actions/install-tf-extras-linux
206+
- name: Build
207+
run: |
208+
bundle install
209+
chmod 400 test/terraform/post-0-15-0/backend-ssh/id_ed25519
210+
./$GEMFILE_DIR/bin/rake test:kitchen:attributes-post-0-15-0-linux
211+
./$GEMFILE_DIR/bin/rake test:kitchen:attributes-post-0-15-0-linux
212+
./$GEMFILE_DIR/bin/rake test:kitchen:backend-ssh-post-0-15-0-linux
213+
./$GEMFILE_DIR/bin/rake test:kitchen:plug-ins-post-0-15-0-linux
214+
./$GEMFILE_DIR/bin/rake test:kitchen:variables-post-0-15-0-linux
215+
./$GEMFILE_DIR/bin/rake test:kitchen:workspaces-post-0-15-0-linux
181216
182217
test_windows_ruby_2_7:
183218
name: Windows Ruby 2.7
@@ -209,7 +244,7 @@ jobs:
209244
ruby $rake_path test:kitchen:attributes-windows
210245
ruby $rake_path test:kitchen:plug-ins-11-windows
211246
ruby $rake_path test:kitchen:variables-windows
212-
ruby $rake_path test:kitchen:workspaces-windows
247+
ruby $rake_path test:kitchen:workspaces-pre-0-15-0-windows
213248
echo 'done!'
214249
215250

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
88

99
## [Unreleased][unreleased]
1010

11+
## [5.8.0] - 2021-05-18
12+
13+
### Added
14+
15+
- Support for Terraform 0.15.
16+
1117
## [5.7.2] - 2021-03-08
1218

1319
### Fixed
@@ -779,7 +785,8 @@ Gandalf the Free-As-In-Beer
779785

780786
- Initial release
781787

782-
[unreleased]: https://github.com/newcontext/kitchen-terraform/compare/v5.7.2...HEAD
788+
[unreleased]: https://github.com/newcontext/kitchen-terraform/compare/v5.8.0...HEAD
789+
[5.8.0]: https://github.com/newcontext/kitchen-terraform/compare/v5.7.2...v5.8.0
783790
[5.7.2]: https://github.com/newcontext/kitchen-terraform/compare/v5.7.1...v5.7.2
784791
[5.7.1]: https://github.com/newcontext/kitchen-terraform/compare/v5.7.0...v5.7.1
785792
[5.7.0]: https://github.com/newcontext/kitchen-terraform/compare/v5.6.0...v5.7.0

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Installation instructions can be found in the
3636
[Terraform: Install Terraform][terraform-install] article.
3737

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

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

@@ -102,7 +102,7 @@ example.
102102
> Installing Kitchen-Terraform with RubyGems
103103
104104
```sh
105-
gem install kitchen-terraform --version 5.7.2
105+
gem install kitchen-terraform --version 5.8.0
106106
```
107107

108108
This approach is not recommended as it requires more effort to install

kitchen-terraform.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ end
77
require "kitchen/terraform/version.rb"
88
require "rubygems"
99

10-
version_parts_strings = RUBY_VERSION.split('.')
10+
version_parts_strings = RUBY_VERSION.split(".")
1111
version_parts = []
1212
version_parts_strings.each { |vp| version_parts.push(vp.to_i) }
1313

@@ -50,7 +50,7 @@ end
5050
if version_gt_25
5151
specification.add_development_dependency "reek", "~> 6.0.2"
5252
else
53-
puts 'version <= 2.5'
53+
puts "version <= 2.5"
5454
specification.add_development_dependency "reek", "~> 5.5"
5555
end
5656

@@ -63,6 +63,6 @@ end
6363
specification.add_runtime_dependency "tty-which", "~> 0.4.0"
6464
specification.cert_chain = ["certs/gem-public_cert.pem"]
6565
specification.required_ruby_version = [">= 2.4", "< 2.8"]
66-
specification.requirements = ["Terraform >= v0.11.4, < v0.15.0"]
66+
specification.requirements = ["Terraform >= v0.11.4, < v1.1.0"]
6767
specification.signing_key = "certs/gem-private_key.pem" if $PROGRAM_NAME =~ /gem\z/
6868
end

kitchen.yml

Lines changed: 136 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,44 @@ suites:
4747
output_third_output: first_output
4848
controls:
4949
- precedence
50+
- name: attributes-post-0-15-0
51+
driver:
52+
root_module_directory: test/terraform/post-0-15-0/attributes
53+
variables:
54+
passthrough: value
55+
verifier:
56+
systems:
57+
- name: default
58+
backend: local
59+
controls:
60+
- default
61+
profile_locations:
62+
- test/integration/attributes
63+
reporter:
64+
- cli
65+
- json:test/reports/inspec/default-attributes.json
66+
- junit:test/reports/inspec/default-attributes.junit.xml
67+
- junit2:test/reports/inspec/default-attributes.junit2.xml
68+
- name: attrs_outputs
69+
backend: local
70+
attrs_outputs:
71+
first_output: second_output
72+
controls:
73+
- attrs_outputs
74+
profile_locations:
75+
- test/integration/attributes
76+
- name: precedence
77+
backend: local
78+
attrs:
79+
- test/integration/attributes/Attribute File.yml
80+
attrs_outputs:
81+
first_output: second_output
82+
second_output: third_output
83+
output_third_output: first_output
84+
controls:
85+
- precedence
86+
profile_locations:
87+
- test/integration/attributes
5088
- name: backend-ssh
5189
excludes:
5290
- osx
@@ -81,6 +119,40 @@ suites:
81119
shell_command: /bin/sh
82120
shell_options: -x
83121
user: root
122+
- name: backend-ssh-post-0-15-0
123+
excludes:
124+
- osx
125+
- windows
126+
driver:
127+
root_module_directory: test/terraform/post-0-15-0/backend-ssh
128+
verifier:
129+
systems:
130+
- name: bastion, hosts, key files, one remote profile location
131+
backend: ssh
132+
bastion_host_output: bastion_host
133+
bastion_port: 2223
134+
bastion_user: root
135+
hosts:
136+
- 172.21.0.2
137+
key_files:
138+
- test/terraform/post-0-15-0/backend-ssh/id_ed25519
139+
port: 22
140+
profile_locations:
141+
- https://github.com/brentm5/chef-compliance-profile-test.git
142+
user: root
143+
- name: hosts output, password, proxy command, shell, two local profile locations
144+
backend: ssh
145+
hosts_output: hosts
146+
password: root
147+
port: 2222
148+
profile_locations:
149+
- test/integration/backend-ssh/behaviour
150+
- test/integration/backend-ssh/state
151+
proxy_command: nc %h %p
152+
shell: true
153+
shell_command: /bin/sh
154+
shell_options: -x
155+
user: root
84156
- name: plug-ins-11
85157
driver:
86158
plugin_directory: test/terraform/11/PlugIns/PlugInDirectory
@@ -99,6 +171,16 @@ suites:
99171
systems:
100172
- name: default
101173
backend: local
174+
- name: plug-ins-post-0-15-0
175+
driver:
176+
plugin_directory: test/terraform/post-0-15-0/PlugIns/PlugInDirectory
177+
root_module_directory: test/terraform/post-0-15-0/PlugIns
178+
verifier:
179+
systems:
180+
- name: default
181+
backend: local
182+
profile_locations:
183+
- test/integration/plug-ins
102184
- name: variables
103185
driver:
104186
root_module_directory: test/terraform/variables
@@ -119,21 +201,71 @@ suites:
119201
backend: local
120202
controls:
121203
- variables
122-
- name: workspace-one
204+
- name: variables-post-0-15-0
205+
driver:
206+
root_module_directory: test/terraform/post-0-15-0/variables
207+
variable_files:
208+
- test/terraform/post-0-15-0/variables/variable_files/Variable File.tfvars
209+
variables:
210+
string: 'A String'
211+
map: '{ key = \"A Value\" }'
212+
list_of_strings: '[ \"Element One\", \"Element Two\" ]'
213+
list_of_maps: '[ { key = \"A List Of Maps Value\" } ]'
214+
verifier:
215+
systems:
216+
- name: variable_files
217+
backend: local
218+
controls:
219+
- variable_files
220+
profile_locations:
221+
- test/integration/variables
222+
- name: variables
223+
backend: local
224+
controls:
225+
- variables
226+
profile_locations:
227+
- test/integration/variables
228+
- name: workspace-one-pre-0-15-0
123229
driver:
124-
root_module_directory: test/terraform/workspace
230+
root_module_directory: test/terraform/pre-0-15-0/workspace
125231
variables:
126232
workspace: one
127233
verifier:
128234
systems:
129235
- name: one
130236
backend: local
131-
- name: workspace-two
237+
profile_locations:
238+
- test/integration/workspace-one
239+
- name: workspace-two-pre-0-15-0
132240
driver:
133-
root_module_directory: test/terraform/workspace
241+
root_module_directory: test/terraform/pre-0-15-0/workspace
134242
variables:
135243
workspace: two
136244
verifier:
137245
systems:
138246
- name: two
139247
backend: local
248+
profile_locations:
249+
- test/integration/workspace-two
250+
- name: workspace-one-post-0-15-0
251+
driver:
252+
root_module_directory: test/terraform/post-0-15-0/workspace
253+
variables:
254+
workspace: one
255+
verifier:
256+
systems:
257+
- name: one
258+
backend: local
259+
profile_locations:
260+
- test/integration/workspace-one
261+
- name: workspace-two-post-0-15-0
262+
driver:
263+
root_module_directory: test/terraform/post-0-15-0/workspace
264+
variables:
265+
workspace: two
266+
verifier:
267+
systems:
268+
- name: two
269+
backend: local
270+
profile_locations:
271+
- test/integration/workspace-two

0 commit comments

Comments
 (0)