terrafile 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 469225ce5f92735515d498168db91d8b9934c3ec6453ffffe4ab0b27c6733670
4
+ data.tar.gz: 2d0cf01aa1d12fc6c6d234c021164675e7151be5a919cec0c7ca8452d3ef99b7
5
+ SHA512:
6
+ metadata.gz: af6611c61844166d9f71514e75d280681cdd90fe00d64e29917faaf4292ee907c68a446967d92273862f3d15eee770281ea251fb537d4c9ee4abbc5e55ffcc50
7
+ data.tar.gz: 375cda366d6be1d34d626612b737ebfbaeca1dc7102830b6da5541122ddb3c32374f7e9c9b56712c1d46632544264d739e6a26fca1b63297a23e4e9be97a049e
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,51 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5.1
3
+ # Exclude:
4
+
5
+ Bundler/OrderedGems:
6
+ Enabled: false
7
+
8
+ Style/Alias:
9
+ Enabled: false
10
+
11
+ Style/FrozenStringLiteralComment:
12
+ Enabled: false
13
+
14
+ Style/NumericLiterals:
15
+ Enabled: false
16
+
17
+ Style/TrailingCommaInArrayLiteral:
18
+ EnforcedStyleForMultiline: comma
19
+
20
+ Style/TrailingCommaInHashLiteral:
21
+ EnforcedStyleForMultiline: comma
22
+
23
+ Style/TrailingCommaInArguments:
24
+ Enabled: false
25
+
26
+ Style/Documentation:
27
+ Enabled: false
28
+
29
+ Style/FormatStringToken:
30
+ Enabled: false
31
+
32
+ Layout/EmptyLineAfterGuardClause:
33
+ Enabled: false
34
+
35
+ Metrics/LineLength:
36
+ Max: 100
37
+ Exclude:
38
+ - 'spec/**/*'
39
+ - 'features/**/*'
40
+
41
+ Metrics/MethodLength:
42
+ Exclude:
43
+ - 'spec/**/*'
44
+
45
+ Metrics/ModuleLength:
46
+ Exclude:
47
+ - 'spec/**/*'
48
+
49
+ Metrics/BlockLength:
50
+ Exclude:
51
+ - 'spec/**/*'
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.1
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+ before_install: gem install bundler -v 1.17.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at systems@dxw.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in terrafile.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,105 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ terrafile (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ aruba (0.14.6)
10
+ childprocess (>= 0.6.3, < 0.10.0)
11
+ contracts (~> 0.9)
12
+ cucumber (>= 1.3.19)
13
+ ffi (~> 1.9.10)
14
+ rspec-expectations (>= 2.99)
15
+ thor (~> 0.19)
16
+ ast (2.4.0)
17
+ backports (3.11.4)
18
+ builder (3.2.3)
19
+ byebug (10.0.2)
20
+ childprocess (0.9.0)
21
+ ffi (~> 1.0, >= 1.0.11)
22
+ coderay (1.1.2)
23
+ contracts (0.16.0)
24
+ cucumber (3.1.2)
25
+ builder (>= 2.1.2)
26
+ cucumber-core (~> 3.2.0)
27
+ cucumber-expressions (~> 6.0.1)
28
+ cucumber-wire (~> 0.0.1)
29
+ diff-lcs (~> 1.3)
30
+ gherkin (~> 5.1.0)
31
+ multi_json (>= 1.7.5, < 2.0)
32
+ multi_test (>= 0.1.2)
33
+ cucumber-core (3.2.1)
34
+ backports (>= 3.8.0)
35
+ cucumber-tag_expressions (~> 1.1.0)
36
+ gherkin (~> 5.0)
37
+ cucumber-expressions (6.0.1)
38
+ cucumber-tag_expressions (1.1.1)
39
+ cucumber-wire (0.0.1)
40
+ diff-lcs (1.3)
41
+ docile (1.3.1)
42
+ ffi (1.9.25)
43
+ gherkin (5.1.0)
44
+ jaro_winkler (1.5.1)
45
+ json (2.1.0)
46
+ method_source (0.9.0)
47
+ multi_json (1.13.1)
48
+ multi_test (0.1.2)
49
+ parallel (1.12.1)
50
+ parser (2.5.3.0)
51
+ ast (~> 2.4.0)
52
+ powerpack (0.1.2)
53
+ pry (0.11.3)
54
+ coderay (~> 1.1.0)
55
+ method_source (~> 0.9.0)
56
+ pry-byebug (3.6.0)
57
+ byebug (~> 10.0)
58
+ pry (~> 0.10)
59
+ rainbow (3.0.0)
60
+ rake (10.5.0)
61
+ rspec (3.8.0)
62
+ rspec-core (~> 3.8.0)
63
+ rspec-expectations (~> 3.8.0)
64
+ rspec-mocks (~> 3.8.0)
65
+ rspec-core (3.8.0)
66
+ rspec-support (~> 3.8.0)
67
+ rspec-expectations (3.8.2)
68
+ diff-lcs (>= 1.2.0, < 2.0)
69
+ rspec-support (~> 3.8.0)
70
+ rspec-mocks (3.8.0)
71
+ diff-lcs (>= 1.2.0, < 2.0)
72
+ rspec-support (~> 3.8.0)
73
+ rspec-support (3.8.0)
74
+ rubocop (0.58.2)
75
+ jaro_winkler (~> 1.5.1)
76
+ parallel (~> 1.10)
77
+ parser (>= 2.5, != 2.5.1.1)
78
+ powerpack (~> 0.1)
79
+ rainbow (>= 2.2.2, < 4.0)
80
+ ruby-progressbar (~> 1.7)
81
+ unicode-display_width (~> 1.0, >= 1.0.1)
82
+ ruby-progressbar (1.10.0)
83
+ simplecov (0.16.1)
84
+ docile (~> 1.1)
85
+ json (>= 1.8, < 3)
86
+ simplecov-html (~> 0.10.0)
87
+ simplecov-html (0.10.2)
88
+ thor (0.20.0)
89
+ unicode-display_width (1.4.0)
90
+
91
+ PLATFORMS
92
+ ruby
93
+
94
+ DEPENDENCIES
95
+ aruba (~> 0.14)
96
+ bundler (~> 1.17)
97
+ pry-byebug (~> 3.6)
98
+ rake (~> 10.5)
99
+ rspec (~> 3.8)
100
+ rubocop (~> 0.58)
101
+ simplecov (~> 0.16)
102
+ terrafile!
103
+
104
+ BUNDLED WITH
105
+ 1.17.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Ed Davey
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # Terrafile
2
+
3
+ This gem provides a `terrafile` executable (Ruby) to install a Terraform project's modules using `git`.
4
+
5
+ The idea of using a 'Terrafile' (like a 'Puppetfile' or a 'Gemfile') to manage a project's dependencies comes from Ben Snape and this code is based on his blog post [http://bensnape.com/2016/01/14/terraform-design-patterns-the-terrafile/](http://bensnape.com/2016/01/14/terraform-design-patterns-the-terrafile/).
6
+
7
+ Conventions:
8
+
9
+ - a project's modules are described in a `Terrafile` located at the root of the project
10
+ - terraform modules are installed in `vendor/terraform_modules`
11
+
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'terrafile'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install terrafile
28
+
29
+ ## Usage
30
+
31
+ Invoke the executable from your shell:
32
+
33
+ $ terrafile
34
+
35
+ to install the modules listed in `Terrafile` into `vendor/terraform_modules`.
36
+
37
+ ## Development
38
+
39
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
40
+
41
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
+
43
+ ### Installing gem in development
44
+
45
+ - `gem build terrafile.gemspec`
46
+ - `gem install terrafile-*.gem`
47
+
48
+ Then you can run `$ terrafile` to run the latest version
49
+
50
+ ## Contributing
51
+
52
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/terrafile. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
53
+
54
+ ## License
55
+
56
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
57
+
58
+ ## Code of Conduct
59
+
60
+ Everyone interacting in the Terrafile project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/dxw/terrafile/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :test
7
+
8
+ desc 'run specs, simplecov and rubocop'
9
+ task :test do
10
+ raise 'FAILURE: Failing specs or incomplete coverage!' unless system 'rspec'
11
+ raise 'FAILURE: Rubocop violations!' unless system 'rubocop'
12
+ end
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bin/terrafile ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/terrafile'
3
+ Terrafile::Installer.new.call
data/lib/terrafile.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'yaml'
2
+ require 'fileutils'
3
+ require 'open3'
4
+ require_relative 'terrafile/version'
5
+ require_relative 'terrafile/errors'
6
+ require_relative 'terrafile/helper'
7
+ require_relative 'terrafile/dependency'
8
+ require_relative 'terrafile/installer'
9
+
10
+ module Terrafile
11
+ TERRAFILE_PATH = 'Terrafile'.freeze
12
+ end
@@ -0,0 +1,35 @@
1
+ module Terrafile
2
+ class Dependency
3
+ def initialize(name:, source:, version:)
4
+ @name = name
5
+ @source = source
6
+ @version = version
7
+ end
8
+
9
+ attr_reader :name, :source, :version
10
+
11
+ def self.build_from_terrafile
12
+ (YAML.safe_load(File.read(TERRAFILE_PATH)) || []).map do |module_name, details|
13
+ new(
14
+ name: module_name,
15
+ version: details['version'],
16
+ source: details['source']
17
+ )
18
+ end
19
+ end
20
+
21
+ def fetch
22
+ return Helper.clone(source, name) unless Helper.dir_exists?(name)
23
+
24
+ Dir.chdir(name) do
25
+ Helper.pull_repo unless Helper.repo_up_to_date?(version)
26
+ end
27
+ end
28
+
29
+ def checkout
30
+ Dir.chdir(name) do
31
+ Helper.run!("git checkout #{version} &> /dev/null")
32
+ end
33
+ end
34
+ end
35
+ end