terraspace 0.5.4 → 0.5.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +3 -3
- data/lib/terraspace/all/grapher.rb +21 -4
- data/lib/terraspace/app.rb +5 -0
- data/lib/terraspace/builder.rb +6 -0
- data/lib/terraspace/builder/allow.rb +43 -0
- data/lib/terraspace/cli/build/placeholder.rb +4 -4
- data/lib/terraspace/cli/check_setup.rb +1 -1
- data/lib/terraspace/{completer.rb → cli/completer.rb} +66 -72
- data/lib/terraspace/{completer → cli/completer}/script.rb +2 -2
- data/lib/terraspace/{completer → cli/completer}/script.sh +0 -0
- data/lib/terraspace/mod.rb +1 -1
- data/lib/terraspace/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc9e2f5079f389bf4c52871ff21d07fd768a72c63b246d770b95c378f0d5a8ad
|
4
|
+
data.tar.gz: f8e957d00f64e54a789f2237161a35c8f9cfbb3af903e40c929829c4ca4d4136
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cf81a81351b8dd8134d19ea9e5ff19644c9ef7470d64e2b54d10d9d35fd69fbc2f5da96a6c34f9e1fb547383d0721d30b49e63df6fbd5958c7b88c3d48dd47f
|
7
|
+
data.tar.gz: f2e202040a50b4a2123ff8e4e177fda89b9ff04d46ba6b759266ea98b75c12e7258ee3a8f424596718875b074155b01319d60107bccfbb43d75d777abda1b56e
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,23 @@
|
|
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.9] - 2020-12-11
|
7
|
+
- [#68](https://github.com/boltops-tools/terraspace/pull/68) require singleton
|
8
|
+
- fix graphviz check for format text, improve graphviz install help message
|
9
|
+
|
10
|
+
## [0.5.8] - 2020-12-04
|
11
|
+
- [#67](https://github.com/boltops-tools/terraspace/pull/67) fix find placeholder stack so config/terraform only builds for stacks
|
12
|
+
|
13
|
+
## [0.5.7] - 2020-12-02
|
14
|
+
- [#64](https://github.com/boltops-tools/terraspace/pull/64) fix completion_script
|
15
|
+
|
16
|
+
## [0.5.6] - 2020-11-30
|
17
|
+
- [#61](https://github.com/boltops-tools/terraspace/pull/61) allow envs and regions check feature
|
18
|
+
- fix terraspace build before hook
|
19
|
+
|
20
|
+
## [0.5.5] - 2020-11-27
|
21
|
+
- fix link
|
22
|
+
|
6
23
|
## [0.5.4] - 2020-11-27
|
7
24
|
- fix check setup when terraform not found
|
8
25
|
|
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/).
|
@@ -109,13 +109,12 @@ module Terraspace::All
|
|
109
109
|
|
110
110
|
# Check if Graphiz is installed and prints a user friendly message if it is not installed.
|
111
111
|
def check_graphviz!
|
112
|
+
return if @options[:format] == 'text'
|
113
|
+
|
112
114
|
installed = system("type dot > /dev/null 2>&1") # dot is a command that is part of the graphviz package
|
113
115
|
return if installed
|
114
116
|
logger.error "ERROR: It appears that the Graphviz is not installed. Please install it to use the graph command.".color(:red)
|
115
|
-
|
116
|
-
logger.error "You can install Graphviz with homebrew:"
|
117
|
-
logger.error " brew install graphviz"
|
118
|
-
end
|
117
|
+
install_instructions
|
119
118
|
logger.info <<~EOL
|
120
119
|
Also consider:
|
121
120
|
|
@@ -125,5 +124,23 @@ module Terraspace::All
|
|
125
124
|
EOL
|
126
125
|
exit 1
|
127
126
|
end
|
127
|
+
|
128
|
+
def install_instructions
|
129
|
+
installer = if RUBY_PLATFORM =~ /darwin/
|
130
|
+
"brew"
|
131
|
+
elsif system("type yum > /dev/null 2>&1")
|
132
|
+
"yum"
|
133
|
+
elsif system("type apt-get > /dev/null 2>&1")
|
134
|
+
"apt-get"
|
135
|
+
end
|
136
|
+
|
137
|
+
return unless installer
|
138
|
+
logger.error <<~EOL
|
139
|
+
You can install Graphviz with:
|
140
|
+
|
141
|
+
#{installer} install graphviz
|
142
|
+
|
143
|
+
EOL
|
144
|
+
end
|
128
145
|
end
|
129
146
|
end
|
data/lib/terraspace/app.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "singleton"
|
2
|
+
|
1
3
|
module Terraspace
|
2
4
|
class App
|
3
5
|
include Singleton
|
@@ -18,6 +20,9 @@ module Terraspace
|
|
18
20
|
config.all.exit_on_fail.down = true
|
19
21
|
config.all.exit_on_fail.up = true
|
20
22
|
config.all.ignore_stacks = []
|
23
|
+
config.allow = ActiveSupport::OrderedOptions.new
|
24
|
+
config.allow.envs = nil
|
25
|
+
config.allow.regions = nil
|
21
26
|
config.auto_create_backend = true
|
22
27
|
config.build = ActiveSupport::OrderedOptions.new
|
23
28
|
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
|
@@ -18,17 +18,17 @@ module Terraspace::CLI::Build
|
|
18
18
|
mod = @options[:mod]
|
19
19
|
if !mod or %w[placeholder].include?(mod)
|
20
20
|
logger.info "Building one of the modules to get backend.tf info"
|
21
|
-
mod =
|
21
|
+
mod = find_stack
|
22
22
|
end
|
23
23
|
Terraspace::Builder.new(@options.merge(mod: mod, init: false)).run # generate and init
|
24
24
|
Terraspace::Mod.new(mod, @options) # mod metadata
|
25
25
|
end
|
26
26
|
|
27
27
|
# Used by: terraspace build placeholder
|
28
|
-
def
|
29
|
-
mod_path = Dir.glob("{app,vendor}/
|
28
|
+
def find_stack
|
29
|
+
mod_path = Dir.glob("{app,vendor}/stacks/*").last
|
30
30
|
unless mod_path
|
31
|
-
logger.info "No
|
31
|
+
logger.info "No stacks found."
|
32
32
|
exit 0
|
33
33
|
end
|
34
34
|
File.basename(mod_path) # mod name
|
@@ -41,7 +41,7 @@ class Terraspace::CLI
|
|
41
41
|
def terraform_is_not_installed
|
42
42
|
<<~EOL
|
43
43
|
Terraform not installed. Unable to detect a terraform command. Please double check that terraform is installed.
|
44
|
-
See: https://
|
44
|
+
See: https://terraspace.cloud/docs/install/terraform/
|
45
45
|
EOL
|
46
46
|
end
|
47
47
|
|
@@ -1,74 +1,69 @@
|
|
1
|
-
|
2
|
-
Code Explanation:
|
3
|
-
|
4
|
-
There are 3 types of things to auto-complete:
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
Here's an example:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
When command parameters are done processing, the remaining completion words will be options. We can tell that the command params are completed based on the method arity.
|
19
|
-
|
20
|
-
## Arity
|
21
|
-
|
22
|
-
For example, say you had a method for a CLI command with the following form:
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
It's equivalent ruby method:
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
So typing:
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
So the completion should only show options, something like this:
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
## Splat Arguments
|
39
|
-
|
40
|
-
When the ruby method has a splat argument, it's arity is negative. Here are some example methods and their arities.
|
41
|
-
|
42
|
-
|
43
|
-
scale(service, count) = 2
|
44
|
-
|
45
|
-
foo(example, *rest) = -2
|
46
|
-
|
47
|
-
Fortunately, negative and positive arity values are processed the same way. So we take simply take the absolute value of the arity and process it the same.
|
48
|
-
|
49
|
-
Here are some test cases, hit TAB after typing the command:
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
* Thor::Group command: ufo init
|
68
|
-
|
69
|
-
Auto-completion accounts for each of these type of commands.
|
70
|
-
=end
|
71
|
-
module Terraspace
|
1
|
+
# begin
|
2
|
+
# Code Explanation:
|
3
|
+
#
|
4
|
+
# There are 3 types of things to auto-complete:
|
5
|
+
#
|
6
|
+
# 1. command: the command itself
|
7
|
+
# 2. parameters: command parameters.
|
8
|
+
# 3. options: command options
|
9
|
+
#
|
10
|
+
# Here's an example:
|
11
|
+
#
|
12
|
+
# mycli hello name --from me
|
13
|
+
#
|
14
|
+
# * command: hello
|
15
|
+
# * parameters: name
|
16
|
+
# * option: --from
|
17
|
+
#
|
18
|
+
# When command parameters are done processing, the remaining completion words will be options. We can tell that the command params are completed based on the method arity.
|
19
|
+
#
|
20
|
+
# ## Arity
|
21
|
+
#
|
22
|
+
# For example, say you had a method for a CLI command with the following form:
|
23
|
+
#
|
24
|
+
# terraspace up STACK
|
25
|
+
#
|
26
|
+
# It's equivalent ruby method:
|
27
|
+
#
|
28
|
+
# up(mod) = has an arity of 1
|
29
|
+
#
|
30
|
+
# So typing:
|
31
|
+
#
|
32
|
+
# terraspace up [TAB] # there is parameter including the "scale" command according to Thor's CLI processing.
|
33
|
+
#
|
34
|
+
# So the completion should only show options, something like this:
|
35
|
+
#
|
36
|
+
# --noop --verbose --cluster
|
37
|
+
#
|
38
|
+
# ## Splat Arguments
|
39
|
+
#
|
40
|
+
# When the ruby method has a splat argument, it's arity is negative. Here are some example methods and their arities.
|
41
|
+
#
|
42
|
+
# up(mod) = 1
|
43
|
+
# scale(service, count) = 2
|
44
|
+
# bundle(*args) = -1
|
45
|
+
# foo(example, *rest) = -2
|
46
|
+
#
|
47
|
+
# Fortunately, negative and positive arity values are processed the same way. So we take simply take the absolute value of the arity and process it the same.
|
48
|
+
#
|
49
|
+
# Here are some test cases, hit TAB after typing the command:
|
50
|
+
#
|
51
|
+
# terraspace completion
|
52
|
+
# terraspace completion up
|
53
|
+
# terraspace completion up name
|
54
|
+
# terraspace completion up name --
|
55
|
+
# terraspace completion up name --noop
|
56
|
+
#
|
57
|
+
# ## Subcommands and Thor::Group Registered Commands
|
58
|
+
#
|
59
|
+
# Sometimes the commands are not simple thor commands but are subcommands or Thor::Group commands. A good specific example is the terraspace tool.
|
60
|
+
#
|
61
|
+
# * regular command: terraspace up
|
62
|
+
# * subcommand: terraspace all
|
63
|
+
# * Thor::Group command: terraspace new project
|
64
|
+
|
65
|
+
# Auto-completion accounts for each of these type of commands.
|
66
|
+
class Terraspace::CLI
|
72
67
|
class Completer
|
73
68
|
def initialize(command_class, *params)
|
74
69
|
@params = params
|
@@ -132,7 +127,6 @@ module Terraspace
|
|
132
127
|
|
133
128
|
def params_completion
|
134
129
|
offset = @params.size - 1
|
135
|
-
offset_params = command_params[offset..-1]
|
136
130
|
command_params[offset..-1].first
|
137
131
|
end
|
138
132
|
|
File without changes
|
data/lib/terraspace/mod.rb
CHANGED
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.9
|
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-12-11 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
|
@@ -480,6 +481,9 @@ files:
|
|
480
481
|
- lib/terraspace/cli/cloud.rb
|
481
482
|
- lib/terraspace/cli/cloud/runs.rb
|
482
483
|
- lib/terraspace/cli/commander.rb
|
484
|
+
- lib/terraspace/cli/completer.rb
|
485
|
+
- lib/terraspace/cli/completer/script.rb
|
486
|
+
- lib/terraspace/cli/completer/script.sh
|
483
487
|
- lib/terraspace/cli/down.rb
|
484
488
|
- lib/terraspace/cli/help.rb
|
485
489
|
- lib/terraspace/cli/help/all/down.md
|
@@ -607,9 +611,6 @@ files:
|
|
607
611
|
- lib/terraspace/compiler/strategy/tfvar/rb.rb
|
608
612
|
- lib/terraspace/compiler/strategy/tfvar/tfvars.rb
|
609
613
|
- lib/terraspace/compiler/writer.rb
|
610
|
-
- lib/terraspace/completer.rb
|
611
|
-
- lib/terraspace/completer/script.rb
|
612
|
-
- lib/terraspace/completer/script.sh
|
613
614
|
- lib/terraspace/core.rb
|
614
615
|
- lib/terraspace/dependency/graph.rb
|
615
616
|
- lib/terraspace/dependency/helper/base.rb
|