terraspace 0.5.1 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/README.md +3 -3
- data/lib/terraspace/app.rb +3 -0
- data/lib/terraspace/autoloader.rb +2 -4
- data/lib/terraspace/builder.rb +6 -0
- data/lib/terraspace/builder/allow.rb +43 -0
- data/lib/terraspace/bundle.rb +6 -0
- data/lib/terraspace/cli/check_setup.rb +17 -3
- data/lib/terraspace/command.rb +35 -1
- data/lib/terraspace/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e58f700f76a198ca29730aa7f8dfa70a009dd8fefc11e49c9796d060f01d6e1
|
4
|
+
data.tar.gz: 81b4dfd9f3280335608feebcdace38ebc97f9dd2739272e10f7482feb95ed2f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71c1f99ec511b8f846d19978ba614e18801a267badc7df6d16b54113f7b9a9aafe959b3035af06e4efd46c6d2735af597532540edd849791b9b62f51f69087af
|
7
|
+
data.tar.gz: afd0feb506627ce32f7bd986db7c4b41a995ddf744a1be9198a56a6928d2a1642b249925622c1de83eee65fd49307672a520aea4f446d0fadb9afb95c40c064d
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,25 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [0.5.6] - 2020-11-30
|
7
|
+
- [#61](https://github.com/boltops-tools/terraspace/pull/61) allow envs and regions check feature
|
8
|
+
- fix terraspace build before hook
|
9
|
+
|
10
|
+
## [0.5.5] - 2020-11-27
|
11
|
+
- fix link
|
12
|
+
|
13
|
+
## [0.5.4] - 2020-11-27
|
14
|
+
- fix check setup when terraform not found
|
15
|
+
|
16
|
+
## [0.5.3] - 2020-11-27
|
17
|
+
- [#60](https://github.com/boltops-tools/terraspace/pull/60) fix terraspace check_setup, use type and allow to run outside project
|
18
|
+
- improve terraform is not installed message
|
19
|
+
|
20
|
+
## [0.5.2] - 2020-11-27
|
21
|
+
- [#59](https://github.com/boltops-tools/terraspace/pull/59) only run bundler/setup within terraspace project and check standalone install
|
22
|
+
- fix terraspace help
|
23
|
+
- fix terraspace setup check when terraform is not installed
|
24
|
+
|
6
25
|
## [0.5.1] - 2020-11-17
|
7
26
|
- [#56](https://github.com/boltops-tools/terraspace/pull/56) fix arg and hook generators
|
8
27
|
- fix ci build
|
data/README.md
CHANGED
@@ -12,9 +12,9 @@ The Terraform Framework.
|
|
12
12
|
|
13
13
|
Official Docs Site: [terraspace.cloud](https://terraspace.cloud)
|
14
14
|
|
15
|
-
|
15
|
+
Quick Start Demo:
|
16
16
|
|
17
|
-
[![Watch the video](https://img.boltops.com/boltops/tools/terraspace/terraspace-
|
17
|
+
[![Watch the video](https://img.boltops.com/boltops/tools/terraspace/youtube/terraspace-quick-start.png)](https://www.youtube.com/watch?v=EZfsBJx8pxQ)
|
18
18
|
|
19
19
|
## Quick Start
|
20
20
|
|
@@ -103,7 +103,7 @@ To install modules:
|
|
103
103
|
|
104
104
|
## Features
|
105
105
|
|
106
|
-
* [
|
106
|
+
* [DRY](https://terraspace.cloud/docs/intro/how-terraspace-works/): You can keep your code DRY. Terraspace builds your Terraform project with common `app` and `config/terraform` structure that gets built each deploy. You can override the settings if needed, like for using existing backends. See: [Existing Backends](https://terraspace.cloud/docs/state/existing/).
|
107
107
|
* [Generators](https://terraspace.cloud/docs/generators/): Built-in generators to quickly create the starter module. Focus on code instead of boilerplate structure.
|
108
108
|
* [Multiple Environments](https://terraspace.cloud/docs/patterns/multiple-envs/): [Tfvars](https://terraspace.cloud/docs/tfvars/) & [Layering](https://terraspace.cloud/docs/tfvars/layering/) allow you to the same code with different tfvars to create multiple environments. Terraspace conventionally loads tfvars from the `tfvars` folder. Rich layering support allows you to build different environments like dev and prod with the same code. Examples are in [Full Layering](https://terraspace.cloud/docs/tfvars/full-layering/).
|
109
109
|
* [Deploy Multiple Stacks](https://terraspace.cloud/docs/intro/deploy-all/): The ability to deploy multiple stacks with a single command. Terraspace calculates the [dependency graph](https://terraspace.cloud/docs/dependencies/) and deploys stacks in the right order. You can also target specific stacks and deploy [subgraphs](https://terraspace.cloud/docs/dependencies/subgraphs/).
|
data/lib/terraspace/app.rb
CHANGED
@@ -18,6 +18,9 @@ module Terraspace
|
|
18
18
|
config.all.exit_on_fail.down = true
|
19
19
|
config.all.exit_on_fail.up = true
|
20
20
|
config.all.ignore_stacks = []
|
21
|
+
config.allow = ActiveSupport::OrderedOptions.new
|
22
|
+
config.allow.envs = nil
|
23
|
+
config.allow.regions = nil
|
21
24
|
config.auto_create_backend = true
|
22
25
|
config.build = ActiveSupport::OrderedOptions.new
|
23
26
|
config.build.cache_dir = ":CACHE_ROOT/:REGION/:ENV/:BUILD_DIR"
|
data/lib/terraspace/builder.rb
CHANGED
@@ -16,7 +16,9 @@ module Terraspace
|
|
16
16
|
logger.info "Building #{build_dir}" unless @options[:quiet] # from terraspace all
|
17
17
|
|
18
18
|
batches = nil
|
19
|
+
FileUtils.mkdir_p(@mod.cache_dir) # so terraspace before build hooks work
|
19
20
|
run_hooks("terraspace.rb", "build") do
|
21
|
+
check_allow!
|
20
22
|
build_unresolved
|
21
23
|
auto_create_backend
|
22
24
|
batches = build_batches
|
@@ -26,6 +28,10 @@ module Terraspace
|
|
26
28
|
batches
|
27
29
|
end
|
28
30
|
|
31
|
+
def check_allow!
|
32
|
+
Allow.new(@mod).check!
|
33
|
+
end
|
34
|
+
|
29
35
|
# Builds dependency graph and returns the batches to run
|
30
36
|
def build_batches
|
31
37
|
dependencies = Terraspace::Dependency::Registry.data # populated after build_unresolved
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class Terraspace::Builder
|
2
|
+
class Allow
|
3
|
+
def initialize(mod)
|
4
|
+
@mod = mod
|
5
|
+
end
|
6
|
+
|
7
|
+
def check!
|
8
|
+
messages = []
|
9
|
+
unless env_allowed?
|
10
|
+
messages << "This env is not allowed to be used: TS_ENV=#{Terraspace.env}"
|
11
|
+
messages << "Allowed envs: #{config.allow.envs.join(', ')}"
|
12
|
+
end
|
13
|
+
unless region_allowed?
|
14
|
+
messages << "This region is not allowed to be used: Detected current region=#{current_region}"
|
15
|
+
messages << "Allowed regions: #{config.allow.regions.join(', ')}"
|
16
|
+
end
|
17
|
+
unless messages.empty?
|
18
|
+
puts "ERROR: The configs do not allow this.".color(:red)
|
19
|
+
puts messages
|
20
|
+
exit 1
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def env_allowed?
|
25
|
+
return true unless config.allow.envs
|
26
|
+
config.allow.envs.include?(Terraspace.env)
|
27
|
+
end
|
28
|
+
|
29
|
+
def region_allowed?
|
30
|
+
return true unless config.allow.regions
|
31
|
+
config.allow.regions.include?(current_region)
|
32
|
+
end
|
33
|
+
|
34
|
+
def current_region
|
35
|
+
expander = Terraspace::Compiler::Expander.autodetect(@mod).expander
|
36
|
+
expander.region
|
37
|
+
end
|
38
|
+
|
39
|
+
def config
|
40
|
+
Terraspace.config
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/terraspace/bundle.rb
CHANGED
@@ -8,6 +8,7 @@ module Terraspace
|
|
8
8
|
#
|
9
9
|
def setup
|
10
10
|
return unless gemfile?
|
11
|
+
return unless terraspace_project?
|
11
12
|
Kernel.require "bundler/setup"
|
12
13
|
Bundler.setup # Same as Bundler.setup(:default)
|
13
14
|
rescue LoadError => e
|
@@ -16,12 +17,17 @@ module Terraspace
|
|
16
17
|
|
17
18
|
def require
|
18
19
|
return unless gemfile?
|
20
|
+
return unless terraspace_project?
|
19
21
|
Kernel.require "bundler/setup"
|
20
22
|
Bundler.require(*bundler_groups)
|
21
23
|
rescue LoadError => e
|
22
24
|
handle_error(e)
|
23
25
|
end
|
24
26
|
|
27
|
+
def terraspace_project?
|
28
|
+
File.exist?("config/app.rb")
|
29
|
+
end
|
30
|
+
|
25
31
|
def handle_error(e)
|
26
32
|
puts e.message
|
27
33
|
return if e.message.include?("already activated")
|
@@ -17,7 +17,7 @@ class Terraspace::CLI
|
|
17
17
|
puts "Detected #{terraform_version_message}"
|
18
18
|
check_required_version!
|
19
19
|
else
|
20
|
-
puts
|
20
|
+
puts terraform_is_not_installed
|
21
21
|
exit 1
|
22
22
|
end
|
23
23
|
end
|
@@ -38,7 +38,19 @@ class Terraspace::CLI
|
|
38
38
|
ARGV[0] == "check_setup"
|
39
39
|
end
|
40
40
|
|
41
|
+
def terraform_is_not_installed
|
42
|
+
<<~EOL
|
43
|
+
Terraform not installed. Unable to detect a terraform command. Please double check that terraform is installed.
|
44
|
+
See: https://terraspace.cloud/docs/install/terraform/
|
45
|
+
EOL
|
46
|
+
end
|
47
|
+
|
41
48
|
def ok?
|
49
|
+
unless terraform_bin
|
50
|
+
puts terraform_is_not_installed
|
51
|
+
exit 1
|
52
|
+
end
|
53
|
+
|
42
54
|
version = terraform_version_message.sub(/.*v/,'') # => 0.12.24
|
43
55
|
unless version.match(/\d+\.\d+\.\d+/) # just parse did not find the version number
|
44
56
|
puts "WARN: Unable to get the terraform version".color(:yellow)
|
@@ -52,8 +64,10 @@ class Terraspace::CLI
|
|
52
64
|
end
|
53
65
|
|
54
66
|
def terraform_bin
|
55
|
-
|
56
|
-
|
67
|
+
out = `type terraform 2>&1`.strip
|
68
|
+
return unless $?.success?
|
69
|
+
md = out.match(/is (.*)/)
|
70
|
+
md[1] if md
|
57
71
|
end
|
58
72
|
memoize :terraform_bin
|
59
73
|
|
data/lib/terraspace/command.rb
CHANGED
@@ -30,6 +30,7 @@ module Terraspace
|
|
30
30
|
include Terraspace::Util::Logging
|
31
31
|
|
32
32
|
def dispatch(m, args, options, config)
|
33
|
+
check_standalone_install!
|
33
34
|
check_project!(args.first)
|
34
35
|
|
35
36
|
# Allow calling for help via:
|
@@ -58,9 +59,42 @@ module Terraspace
|
|
58
59
|
super
|
59
60
|
end
|
60
61
|
|
62
|
+
def check_standalone_install!
|
63
|
+
return unless opt?
|
64
|
+
version_manager = "rvm" if rvm?
|
65
|
+
version_manager = "rbenv" if rbenv?
|
66
|
+
if rbenv? || rvm?
|
67
|
+
puts <<~EOL.color(:yellow)
|
68
|
+
WARN: It looks like a standalone Terraspace install and #{version_manager} is also in use.
|
69
|
+
Different gems from the standalone Terraspace install and #{version_manager} can cause all kinds of trouble.
|
70
|
+
Please install Terraspace as a gem instead and remove the standalone Terraspace /opt/terraspace installation.
|
71
|
+
See: https://terraspace.cloud/docs/install/gem/
|
72
|
+
EOL
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def opt?
|
77
|
+
paths = ENV['PATH'].split(':')
|
78
|
+
opt = paths.detect { |p| p.include?('/opt/terraspace') }
|
79
|
+
opt && File.exist?('/opt/terraspace')
|
80
|
+
end
|
81
|
+
|
82
|
+
def rvm?
|
83
|
+
paths = ENV['PATH'].split(':')
|
84
|
+
rvm = paths.detect { |p| p.include?('/rvm/') || p.include?('/.rvm/') }
|
85
|
+
rvm && system("type rvm > /dev/null 2>&1")
|
86
|
+
end
|
87
|
+
|
88
|
+
def rbenv?
|
89
|
+
paths = ENV['PATH'].split(':')
|
90
|
+
rbenv = paths.detect { |p| p.include?('/rbenv/') || p.include?('/.rbenv/') }
|
91
|
+
rbenv && system("type rbenv > /dev/null 2>&1")
|
92
|
+
end
|
93
|
+
|
61
94
|
def check_project!(command_name)
|
62
95
|
return if subcommand?
|
63
|
-
return if
|
96
|
+
return if command_name.nil?
|
97
|
+
return if %w[-h -v check_setup completion completion_script help new test version].include?(command_name)
|
64
98
|
return if File.exist?("#{Terraspace.root}/config/app.rb")
|
65
99
|
logger.error "ERROR: It doesnt look like this is a terraspace project. Are you sure you are in a terraspace project?".color(:red)
|
66
100
|
ENV['TS_TEST'] ? raise : exit(1)
|
data/lib/terraspace/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terraspace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -465,6 +465,7 @@ files:
|
|
465
465
|
- lib/terraspace/autoloader.rb
|
466
466
|
- lib/terraspace/booter.rb
|
467
467
|
- lib/terraspace/builder.rb
|
468
|
+
- lib/terraspace/builder/allow.rb
|
468
469
|
- lib/terraspace/bundle.rb
|
469
470
|
- lib/terraspace/cli.rb
|
470
471
|
- lib/terraspace/cli/all.rb
|