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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 469225ce5f92735515d498168db91d8b9934c3ec6453ffffe4ab0b27c6733670
4
- data.tar.gz: 2d0cf01aa1d12fc6c6d234c021164675e7151be5a919cec0c7ca8452d3ef99b7
3
+ metadata.gz: 4be422a234065c714ad67e455de5b3c330f8a21bfd4662d1913ad4e116bb8a0a
4
+ data.tar.gz: '07939a6f15d164865a0debcb71885632dfa5eaec869e42d4467b4fdecfa542d6'
5
5
  SHA512:
6
- metadata.gz: af6611c61844166d9f71514e75d280681cdd90fe00d64e29917faaf4292ee907c68a446967d92273862f3d15eee770281ea251fb537d4c9ee4abbc5e55ffcc50
7
- data.tar.gz: 375cda366d6be1d34d626612b737ebfbaeca1dc7102830b6da5541122ddb3c32374f7e9c9b56712c1d46632544264d739e6a26fca1b63297a23e4e9be97a049e
6
+ metadata.gz: 1326581ca3870aa2d4df2d930fd912c2339e826c1119f3674a2dbce608de52996d50556a62ca74f884ad43b21c7b6094ab0a88b07f0dbd007ae573cf93a728c5
7
+ data.tar.gz: 0af82f425c8ad201bcb0e6f6b9f4c2cac656ca217aeede14ae43383a732f3af43e8bba17870212fafef88f31e272dd2631a53b37191d35b54d2aea14e1810a02
data/.rubocop.yml CHANGED
@@ -49,3 +49,4 @@ Metrics/ModuleLength:
49
49
  Metrics/BlockLength:
50
50
  Exclude:
51
51
  - 'spec/**/*'
52
+ - 'terrafile.gemspec'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- terrafile (0.1.0)
4
+ terrafile (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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'
@@ -0,0 +1,2 @@
1
+ require 'pry'
2
+ require_relative '../../lib/terrafile'
@@ -28,7 +28,7 @@ module Terrafile
28
28
 
29
29
  def checkout
30
30
  Dir.chdir(name) do
31
- Helper.run!("git checkout #{version} &> /dev/null")
31
+ Helper.run!("git checkout #{version} 1> /dev/null")
32
32
  end
33
33
  end
34
34
  end
@@ -26,7 +26,7 @@ module Terrafile
26
26
  end
27
27
 
28
28
  def self.clone(source, destination)
29
- run!("git clone --depth 1 #{source} #{destination} &> /dev/null")
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 &> /dev/null')
47
+ run!('git pull 1> /dev/null')
48
48
  end
49
49
  end
50
50
  end
@@ -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(Installer::MODULES_PATH) do
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
@@ -1,3 +1,3 @@
1
1
  module Terrafile
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
data/lib/terrafile.rb CHANGED
@@ -9,4 +9,5 @@ require_relative 'terrafile/installer'
9
9
 
10
10
  module Terrafile
11
11
  TERRAFILE_PATH = 'Terrafile'.freeze
12
+ MODULES_PATH = File.join('vendor', 'terraform_modules').freeze
12
13
  end
data/spec/spec_helper.rb CHANGED
@@ -3,9 +3,8 @@ SimpleCov.start do
3
3
  minimum_coverage 100
4
4
  end
5
5
  require 'bundler/setup'
6
- require 'aruba/rspec'
7
6
  require 'terrafile'
8
- # require 'pry'
7
+ require 'pry'
9
8
 
10
9
  RSpec.configure do |config|
11
10
  # Enable flags like --only-failures and --next-failure
@@ -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 output' do
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 &> /dev/null')
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
@@ -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 --depth 1 #{source} #{destination} &> /dev/null")
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 without generating any output' do
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 &> /dev/null')
178
+ expect(Helper).to have_received(:run!).with('git pull 1> /dev/null')
179
179
  end
180
180
  end
181
181
  end
@@ -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(Installer::MODULES_PATH).and_return(true)
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(Installer::MODULES_PATH).and_return(false)
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(Installer::MODULES_PATH)
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(Installer::MODULES_PATH)
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
- # spec.homepage = "TODO: Put your gem's website or public repo URL here."
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
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
21
- # to allow pushing to a single host or delete this section to allow pushing to any host.
22
- # if spec.respond_to?(:metadata)
23
- spec.metadata['credit'] = 'Original code and rationale found at: ' \
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.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-13 00:00:00.000000000 Z
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