terrafile 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/Gemfile.lock +1 -1
- data/Rakefile +1 -0
- data/features/processes_a_terrafile.feature +13 -0
- data/features/step_definitions/terrafile_steps.rb +31 -0
- data/features/support/aruba.rb +1 -0
- data/features/support/env.rb +2 -0
- data/lib/terrafile/dependency.rb +1 -1
- data/lib/terrafile/helper.rb +2 -2
- data/lib/terrafile/installer.rb +1 -3
- data/lib/terrafile/version.rb +1 -1
- data/lib/terrafile.rb +1 -0
- data/spec/spec_helper.rb +1 -2
- data/spec/unit/dependency_spec.rb +2 -2
- data/spec/unit/helper_spec.rb +4 -4
- data/spec/unit/installer_spec.rb +4 -4
- data/terrafile.gemspec +5 -15
- metadata +7 -5
- data/spec/integration/runs_terrafile_executable_spec.rb +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4be422a234065c714ad67e455de5b3c330f8a21bfd4662d1913ad4e116bb8a0a
|
4
|
+
data.tar.gz: '07939a6f15d164865a0debcb71885632dfa5eaec869e42d4467b4fdecfa542d6'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1326581ca3870aa2d4df2d930fd912c2339e826c1119f3674a2dbce608de52996d50556a62ca74f884ad43b21c7b6094ab0a88b07f0dbd007ae573cf93a728c5
|
7
|
+
data.tar.gz: 0af82f425c8ad201bcb0e6f6b9f4c2cac656ca217aeede14ae43383a732f3af43e8bba17870212fafef88f31e272dd2631a53b37191d35b54d2aea14e1810a02
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -8,5 +8,6 @@ task default: :test
|
|
8
8
|
desc 'run specs, simplecov and rubocop'
|
9
9
|
task :test do
|
10
10
|
raise 'FAILURE: Failing specs or incomplete coverage!' unless system 'rspec'
|
11
|
+
raise 'FAILURE: Failing integration tests!' unless system 'cucumber'
|
11
12
|
raise 'FAILURE: Rubocop violations!' unless system 'rubocop'
|
12
13
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Feature: processes a terrafile
|
2
|
+
|
3
|
+
Background:
|
4
|
+
And a valid Terrafile exists
|
5
|
+
|
6
|
+
Scenario: all modules are installable
|
7
|
+
When I run the _terrafile_ command
|
8
|
+
And I should see that each module listed in the Terrafile is to be installed
|
9
|
+
|
10
|
+
Scenario: modules subdirectory created if not present
|
11
|
+
When I run the _terrafile_ command
|
12
|
+
Then I should see that a _modules_ directory will be created
|
13
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Given('a valid Terrafile exists') do
|
2
|
+
content = <<~YML
|
3
|
+
terraform-aws-cloudtrail:
|
4
|
+
source: "git@github.com:deanwilson/terraform-aws-cloudtrail"
|
5
|
+
version: "01ccc3a1816373dff0a0084377e24991dc0212bc"
|
6
|
+
|
7
|
+
terraform-aws-s3-bucket:
|
8
|
+
source: "git@github.com:Smartbrood/terraform-aws-s3-bucket.git"
|
9
|
+
version: "v0.7"
|
10
|
+
YML
|
11
|
+
write_file 'Terrafile', content
|
12
|
+
end
|
13
|
+
|
14
|
+
When('I run the _terrafile_ command') do
|
15
|
+
run_simple('terrafile', fail_on_error: false)
|
16
|
+
end
|
17
|
+
|
18
|
+
Then('I should see that a _modules_ directory will be created') do
|
19
|
+
notice = "Creating Terraform modules directory at 'vendor/terraform_modules'"
|
20
|
+
expect(last_command_started.output).to match(/#{notice}/)
|
21
|
+
end
|
22
|
+
|
23
|
+
Then('I should see that each module listed in the Terrafile is to be installed') do
|
24
|
+
notice1 = 'Checking out 01ccc3a1816373dff0a0084377e24991dc0212bc from ' \
|
25
|
+
'git@github.com:deanwilson/terraform-aws-cloudtrail'
|
26
|
+
notice2 = 'Checking out v0.7 from ' \
|
27
|
+
'git@github.com:Smartbrood/terraform-aws-s3-bucket.git'
|
28
|
+
|
29
|
+
expect(last_command_started.output).to match(/#{notice1}/)
|
30
|
+
expect(last_command_started.output).to match(/#{notice2}/)
|
31
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'aruba/cucumber'
|
data/lib/terrafile/dependency.rb
CHANGED
data/lib/terrafile/helper.rb
CHANGED
@@ -26,7 +26,7 @@ module Terrafile
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.clone(source, destination)
|
29
|
-
run!("git clone
|
29
|
+
run!("git clone #{source} #{destination} 1> /dev/null")
|
30
30
|
end
|
31
31
|
|
32
32
|
def self.dir_exists?(path)
|
@@ -44,7 +44,7 @@ module Terrafile
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def self.pull_repo
|
47
|
-
run!('git pull
|
47
|
+
run!('git pull 1> /dev/null')
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
data/lib/terrafile/installer.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
module Terrafile
|
2
2
|
class Installer
|
3
|
-
MODULES_PATH = 'vendor/terraform_modules'.freeze
|
4
|
-
|
5
3
|
def initialize
|
6
4
|
@dependencies = read_terrafile
|
7
5
|
end
|
@@ -27,7 +25,7 @@ module Terrafile
|
|
27
25
|
end
|
28
26
|
|
29
27
|
def checkout_modules
|
30
|
-
Dir.chdir(
|
28
|
+
Dir.chdir(Terrafile::MODULES_PATH) do
|
31
29
|
dependencies.each do |dependency|
|
32
30
|
msg = "Checking out #{dependency.version} from #{dependency.source}"
|
33
31
|
Kernel.puts msg
|
data/lib/terrafile/version.rb
CHANGED
data/lib/terrafile.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -141,10 +141,10 @@ module Terrafile
|
|
141
141
|
expect(Dir).to have_received(:chdir).with('terraform-of-mine')
|
142
142
|
end
|
143
143
|
|
144
|
-
it 'checks out the right version of that dependency, suppressing
|
144
|
+
it 'checks out the right version of that dependency, suppressing STDOUT' do
|
145
145
|
dependency.checkout
|
146
146
|
|
147
|
-
expect(Helper).to have_received(:run!).with('git checkout 1.2.3
|
147
|
+
expect(Helper).to have_received(:run!).with('git checkout 1.2.3 1> /dev/null')
|
148
148
|
end
|
149
149
|
end
|
150
150
|
end
|
data/spec/unit/helper_spec.rb
CHANGED
@@ -112,7 +112,7 @@ module Terrafile
|
|
112
112
|
end
|
113
113
|
|
114
114
|
describe '::clone(source, destination)' do
|
115
|
-
it 'checks out the given revision using run!' do
|
115
|
+
it 'checks out the given revision using run! suppressing STDOUT' do
|
116
116
|
allow(Helper).to receive(:run!)
|
117
117
|
source = 'git@github.com:org1/repo1'
|
118
118
|
destination = 'terraform-aws-name1'
|
@@ -120,7 +120,7 @@ module Terrafile
|
|
120
120
|
Helper.clone(source, destination)
|
121
121
|
|
122
122
|
expect(Helper).to have_received(:run!)
|
123
|
-
.with("git clone
|
123
|
+
.with("git clone #{source} #{destination} 1> /dev/null")
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
@@ -170,12 +170,12 @@ module Terrafile
|
|
170
170
|
end
|
171
171
|
|
172
172
|
describe '::pull_repo' do
|
173
|
-
it 'pulls the latest code
|
173
|
+
it 'pulls the latest code suppressing STDOUT' do
|
174
174
|
allow(Helper).to receive(:run!)
|
175
175
|
|
176
176
|
Helper.pull_repo
|
177
177
|
|
178
|
-
expect(Helper).to have_received(:run!).with('git pull
|
178
|
+
expect(Helper).to have_received(:run!).with('git pull 1> /dev/null')
|
179
179
|
end
|
180
180
|
end
|
181
181
|
end
|
data/spec/unit/installer_spec.rb
CHANGED
@@ -65,7 +65,7 @@ module Terrafile
|
|
65
65
|
context 'when the directory already exists' do
|
66
66
|
before do
|
67
67
|
allow(Helper).to receive(:dir_exists?)
|
68
|
-
.with(
|
68
|
+
.with(Terrafile::MODULES_PATH).and_return(true)
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'does not attempt to make the directory' do
|
@@ -77,7 +77,7 @@ module Terrafile
|
|
77
77
|
context 'when the directory does NOT exist' do
|
78
78
|
before do
|
79
79
|
allow(Helper).to receive(:dir_exists?)
|
80
|
-
.with(
|
80
|
+
.with(Terrafile::MODULES_PATH).and_return(false)
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'notifies us of its intention to make the directory' do
|
@@ -87,7 +87,7 @@ module Terrafile
|
|
87
87
|
|
88
88
|
it 'makes the directory' do
|
89
89
|
Installer.new.call
|
90
|
-
expect(FileUtils).to have_received(:makedirs).with(
|
90
|
+
expect(FileUtils).to have_received(:makedirs).with(Terrafile::MODULES_PATH)
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -133,7 +133,7 @@ module Terrafile
|
|
133
133
|
|
134
134
|
it 'changes to the module installation directory' do
|
135
135
|
Installer.new.call
|
136
|
-
expect(Dir).to have_received(:chdir).with(
|
136
|
+
expect(Dir).to have_received(:chdir).with(Terrafile::MODULES_PATH)
|
137
137
|
end
|
138
138
|
|
139
139
|
describe 'for each dependency' do
|
data/terrafile.gemspec
CHANGED
@@ -13,24 +13,14 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.summary = 'Installs the modules listed in Terrafile'
|
14
14
|
spec.description = 'Terraform modules listed in Terrafile are installed in ' \
|
15
15
|
'vendor/terraform_modules'
|
16
|
-
|
16
|
+
spec.homepage = 'https://github.com/dxw/terrafile'
|
17
17
|
spec.license = 'MIT'
|
18
18
|
spec.post_install_message = 'Thanks for installing terrafile.'
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
'http://bensnape.com/2016/01/14/terraform-design-patterns-the-terrafile/'
|
25
|
-
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
26
|
-
|
27
|
-
# spec.metadata["homepage_uri"] = spec.homepage
|
28
|
-
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
29
|
-
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
30
|
-
# else
|
31
|
-
# raise "RubyGems 2.0 or newer is required to protect against " \
|
32
|
-
# "public gem pushes."
|
33
|
-
# end
|
20
|
+
if spec.respond_to?(:metadata)
|
21
|
+
spec.metadata['credit'] = 'Original code and rationale found at: ' \
|
22
|
+
'http://bensnape.com/2016/01/14/terraform-design-patterns-the-terrafile/'
|
23
|
+
end
|
34
24
|
|
35
25
|
spec.files = `git ls-files`.split("\n")
|
36
26
|
spec.test_files = `git ls-files -- spec/*`.split("\n")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terrafile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dxw
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aruba
|
@@ -129,20 +129,23 @@ files:
|
|
129
129
|
- Rakefile
|
130
130
|
- bin/setup
|
131
131
|
- bin/terrafile
|
132
|
+
- features/processes_a_terrafile.feature
|
133
|
+
- features/step_definitions/terrafile_steps.rb
|
134
|
+
- features/support/aruba.rb
|
135
|
+
- features/support/env.rb
|
132
136
|
- lib/terrafile.rb
|
133
137
|
- lib/terrafile/dependency.rb
|
134
138
|
- lib/terrafile/errors.rb
|
135
139
|
- lib/terrafile/helper.rb
|
136
140
|
- lib/terrafile/installer.rb
|
137
141
|
- lib/terrafile/version.rb
|
138
|
-
- spec/integration/runs_terrafile_executable_spec.rb
|
139
142
|
- spec/spec_helper.rb
|
140
143
|
- spec/terrafile_spec.rb
|
141
144
|
- spec/unit/dependency_spec.rb
|
142
145
|
- spec/unit/helper_spec.rb
|
143
146
|
- spec/unit/installer_spec.rb
|
144
147
|
- terrafile.gemspec
|
145
|
-
homepage:
|
148
|
+
homepage: https://github.com/dxw/terrafile
|
146
149
|
licenses:
|
147
150
|
- MIT
|
148
151
|
metadata:
|
@@ -168,7 +171,6 @@ signing_key:
|
|
168
171
|
specification_version: 4
|
169
172
|
summary: Installs the modules listed in Terrafile
|
170
173
|
test_files:
|
171
|
-
- spec/integration/runs_terrafile_executable_spec.rb
|
172
174
|
- spec/spec_helper.rb
|
173
175
|
- spec/terrafile_spec.rb
|
174
176
|
- spec/unit/dependency_spec.rb
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
|
3
|
-
module Terrafile
|
4
|
-
RSpec.describe 'CLI runs terrafile executable', type: :aruba do
|
5
|
-
context 'when no Terrafile is found' do
|
6
|
-
let(:file) { 'Bananafile' }
|
7
|
-
let(:content) { 'Something else entirely' }
|
8
|
-
let(:output) { 'Terrafile does not exist' }
|
9
|
-
|
10
|
-
before(:each) { write_file file, content }
|
11
|
-
before(:each) { run('terrafile') }
|
12
|
-
|
13
|
-
it 'prints out an error message' do
|
14
|
-
expect(last_command_started).to have_output(/#{output}/)
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'exits non-zero' do
|
18
|
-
expect(last_command_started).not_to have_exit_status(0)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'when a Terrafile IS found' do
|
23
|
-
let(:file) { 'Terrafile' }
|
24
|
-
let(:content) do
|
25
|
-
<<~YML
|
26
|
-
terraform-aws-module1:
|
27
|
-
source: "git@github.com:org1/repo1.git"
|
28
|
-
version: "0.8.0"
|
29
|
-
|
30
|
-
terraform-aws-module2:
|
31
|
-
source: "git@github.com:org2/repo2.git"
|
32
|
-
version: "004e5791c2ef816578420fb6695e4009a838c863"
|
33
|
-
YML
|
34
|
-
end
|
35
|
-
let(:notice) { 'Creating Terraform modules directory' }
|
36
|
-
|
37
|
-
before(:each) { write_file file, content }
|
38
|
-
before(:each) { run('terrafile') }
|
39
|
-
|
40
|
-
context 'and the modules directory does not yet exist' do
|
41
|
-
it 'prints out its intention to create that directory' do
|
42
|
-
expect(last_command_started).to have_output(/#{notice}/)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|