terraspace 0.6.9 → 0.6.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/lib/terraspace/cli.rb +2 -2
- data/lib/terraspace/cli/check_setup.rb +2 -1
- data/lib/terraspace/cli/fmt.rb +1 -1
- data/lib/terraspace/cli/help/fmt.md +6 -2
- data/lib/terraspace/cli/help/state.md +30 -0
- data/lib/terraspace/cli/init.rb +1 -1
- data/lib/terraspace/command.rb +9 -1
- data/lib/terraspace/compiler/builder.rb +9 -5
- data/lib/terraspace/compiler/commands_concern.rb +2 -2
- data/lib/terraspace/compiler/dsl/syntax/helpers/common.rb +1 -1
- data/lib/terraspace/core.rb +10 -0
- data/lib/terraspace/shell.rb +2 -2
- data/lib/terraspace/terraform/args/default.rb +16 -4
- data/lib/terraspace/version.rb +1 -1
- data/terraspace.gemspec +2 -2
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ac77946fdc6f6073084fd5a862f38676d9c37ed661941cc877c3445e338ff0e
|
4
|
+
data.tar.gz: fb5315dc9d3c37bf6d6a10206019b5de9c53be812ff3955161ca344fe7b12ac3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edb6864335554ada73820a9700bb4e5b5c04ce5ebc2c4e68a54fb44d336fef33b705c78b90da8083bc48eaafae2ad5427a74f856d7b60ca558f1fe56965a6799
|
7
|
+
data.tar.gz: 97656cb6d7eba975df38388468b0e69168d777a9e3de91268ecfafe9b8430121d54af96aee4df72834a28425f7919a3741b833f9dca0cb45363f451b4802069a
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,24 @@
|
|
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.6.13] - 2021-08-10
|
7
|
+
- use terraspace-bundler 0.4.0
|
8
|
+
|
9
|
+
## [0.6.12] - 2021-07-26
|
10
|
+
- [#128](https://github.com/boltops-tools/terraspace/pull/128) Improve terraspace state comands and Terraspace.argv for internal usage
|
11
|
+
- [#129](https://github.com/boltops-tools/terraspace/pull/129) use Dir.glob(expr, File::FNM_DOTMATCH) so dotfiles are copied, allowing .terraform-version for tfenv
|
12
|
+
- allow -h to help outside terraspace project generally
|
13
|
+
- require rspec-terraspace 0.3.0
|
14
|
+
- state subcommands: straight delegate args
|
15
|
+
- Terraspace.argv for consistency with terraspace test
|
16
|
+
|
17
|
+
## [0.6.11] - 2021-06-22
|
18
|
+
- [#120](https://github.com/boltops-tools/terraspace/pull/120) version check handles a major change
|
19
|
+
|
20
|
+
## [0.6.10] - 2021-06-01
|
21
|
+
- [#117](https://github.com/boltops-tools/terraspace/pull/117) fix terraspace fmt -t all
|
22
|
+
- clean up IO select call
|
23
|
+
|
6
24
|
## [0.6.9] - 2021-05-07
|
7
25
|
- [#112](https://github.com/boltops-tools/terraspace/pull/112) fix smart auto retry
|
8
26
|
|
data/lib/terraspace/cli.rb
CHANGED
@@ -189,8 +189,8 @@ module Terraspace
|
|
189
189
|
|
190
190
|
desc "state SUBCOMMAND STACK", "Run state."
|
191
191
|
long_desc Help.text(:state)
|
192
|
-
def state(subcommand, mod)
|
193
|
-
State.new(options.merge(subcommand: subcommand, mod: mod)).run
|
192
|
+
def state(subcommand, mod, *rest)
|
193
|
+
State.new(options.merge(subcommand: subcommand, mod: mod, rest: rest)).run
|
194
194
|
end
|
195
195
|
|
196
196
|
desc "test", "Run test."
|
@@ -35,7 +35,7 @@ class Terraspace::CLI
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def check_command?
|
38
|
-
|
38
|
+
Terraspace.argv[0] == "check_setup"
|
39
39
|
end
|
40
40
|
|
41
41
|
def terraform_is_not_installed
|
@@ -58,6 +58,7 @@ class Terraspace::CLI
|
|
58
58
|
end
|
59
59
|
major, minor, _ = version.split('.')
|
60
60
|
required_major, required_minor = REQUIRED_TERRAFORM_VERSION.split('.')
|
61
|
+
return true if major.to_i > required_major.to_i
|
61
62
|
x = major.to_i >= required_major.to_i
|
62
63
|
y = minor.to_i >= required_minor.to_i
|
63
64
|
x && y
|
data/lib/terraspace/cli/fmt.rb
CHANGED
@@ -14,9 +14,13 @@ Format all source files.
|
|
14
14
|
Format specific module or stack.
|
15
15
|
|
16
16
|
$ terraspace fmt stack1
|
17
|
-
$ terraspace fmt module1
|
17
|
+
$ terraspace fmt module1 -t module
|
18
18
|
|
19
19
|
Format scoping to module or stack types. In case there's a module and stack with the same name.
|
20
20
|
|
21
21
|
$ terraspace fmt example -t module
|
22
|
-
$ terraspace fmt demo -t
|
22
|
+
$ terraspace fmt demo -t stack
|
23
|
+
|
24
|
+
Format all, so both modules and stacks:
|
25
|
+
|
26
|
+
$ terraspace fmt -t all
|
@@ -0,0 +1,30 @@
|
|
1
|
+
## Examples
|
2
|
+
|
3
|
+
terraspace state list demo
|
4
|
+
terraspace state mv demo
|
5
|
+
terraspace state pull demo
|
6
|
+
terraspace state push demo
|
7
|
+
terraspace state replace demo
|
8
|
+
terraspace state rm demo
|
9
|
+
terraspace state show demo
|
10
|
+
|
11
|
+
## Args Straight Delegation
|
12
|
+
|
13
|
+
The `terraspace state` command delegates to the `terraform state` commands passing the arguments straight through. Refer to the underlying `terraform` command help for arguments. Example:
|
14
|
+
|
15
|
+
terraform state list -h
|
16
|
+
...
|
17
|
+
Options:
|
18
|
+
...
|
19
|
+
-id=ID Filters the results to include only instances whose
|
20
|
+
resource types have an attribute named "id" whose value
|
21
|
+
equals the given id string.
|
22
|
+
|
23
|
+
This means we can use the `-id` or `--id` option and terraspace will pass it straight through. Example:
|
24
|
+
|
25
|
+
terraspace state list demo --id enabled-bull
|
26
|
+
Building .terraspace-cache/us-west-2/dev/stacks/demo
|
27
|
+
Built in .terraspace-cache/us-west-2/dev/stacks/demo
|
28
|
+
Current directory: .terraspace-cache/us-west-2/dev/stacks/demo
|
29
|
+
=> terraform state list --id enabled-bull
|
30
|
+
random_pet.this
|
data/lib/terraspace/cli/init.rb
CHANGED
data/lib/terraspace/command.rb
CHANGED
@@ -30,6 +30,9 @@ module Terraspace
|
|
30
30
|
include Terraspace::Util::Logging
|
31
31
|
|
32
32
|
def dispatch(m, args, options, config)
|
33
|
+
# Terraspace.argv provides consistency when terraspace is being called by rspec-terrspace test harness
|
34
|
+
Terraspace.argv = args.clone # important to clone since Thor removes the first argv
|
35
|
+
|
33
36
|
check_standalone_install!
|
34
37
|
check_project!(args.first)
|
35
38
|
|
@@ -42,7 +45,6 @@ module Terraspace
|
|
42
45
|
# as well thor's normal way:
|
43
46
|
#
|
44
47
|
# terraspace help command
|
45
|
-
help_flags = Thor::HELP_MAPPINGS + ["help"]
|
46
48
|
if args.length > 1 && !(args & help_flags).empty?
|
47
49
|
args -= help_flags
|
48
50
|
args.insert(-2, "help")
|
@@ -59,6 +61,11 @@ module Terraspace
|
|
59
61
|
super
|
60
62
|
end
|
61
63
|
|
64
|
+
def help_flags
|
65
|
+
Thor::HELP_MAPPINGS + ["help"]
|
66
|
+
end
|
67
|
+
private :help_flags
|
68
|
+
|
62
69
|
def check_standalone_install!
|
63
70
|
return unless opt?
|
64
71
|
version_manager = "rvm" if rvm?
|
@@ -94,6 +101,7 @@ module Terraspace
|
|
94
101
|
def check_project!(command_name)
|
95
102
|
return if subcommand?
|
96
103
|
return if command_name.nil?
|
104
|
+
return if help_flags.include?(Terraspace.argv.last) # IE: -h help
|
97
105
|
return if %w[-h -v check_setup completion completion_script help new test version].include?(command_name)
|
98
106
|
return if File.exist?("#{Terraspace.root}/config/app.rb")
|
99
107
|
logger.error "ERROR: It doesnt look like this is a terraspace project. Are you sure you are in a terraspace project?".color(:red)
|
@@ -37,7 +37,7 @@ module Terraspace::Compiler
|
|
37
37
|
|
38
38
|
def build_config_terraform
|
39
39
|
expr = "#{Terraspace.root}/config/terraform/**/*"
|
40
|
-
|
40
|
+
search(expr).each do |path|
|
41
41
|
next unless File.file?(path)
|
42
42
|
next if path.include?('config/terraform/tfvars')
|
43
43
|
build_config_file(basename(path))
|
@@ -45,13 +45,13 @@ module Terraspace::Compiler
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def build_config_file(file)
|
48
|
-
existing =
|
48
|
+
existing = search("#{@mod.root}/#{file}").first
|
49
49
|
return if existing && existing.ends_with?(".tf") # do not overwrite existing backend.tf, provider.tf, etc
|
50
50
|
|
51
51
|
if file.ends_with?(".rb")
|
52
|
-
src_path =
|
52
|
+
src_path = search("#{@mod.root}/#{basename(file)}").first # existing source. IE: backend.rb in module folder
|
53
53
|
end
|
54
|
-
src_path ||=
|
54
|
+
src_path ||= search("#{Terraspace.root}/config/terraform/#{file}").first
|
55
55
|
build_mod_file(src_path) if src_path
|
56
56
|
end
|
57
57
|
|
@@ -65,7 +65,7 @@ module Terraspace::Compiler
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def with_path(path)
|
68
|
-
|
68
|
+
search(path).each do |src_path|
|
69
69
|
next if skip?(src_path)
|
70
70
|
yield(src_path)
|
71
71
|
end
|
@@ -80,5 +80,9 @@ module Terraspace::Compiler
|
|
80
80
|
src_path.include?("#{@mod.root}/test") ||
|
81
81
|
src_path.include?("#{@mod.root}/tfvars")
|
82
82
|
end
|
83
|
+
|
84
|
+
def search(expr)
|
85
|
+
Dir.glob(expr, File::FNM_DOTMATCH)
|
86
|
+
end
|
83
87
|
end
|
84
88
|
end
|
@@ -11,8 +11,8 @@ module Terraspace::Compiler
|
|
11
11
|
def command_is?(*commands)
|
12
12
|
commands.flatten!
|
13
13
|
commands.map!(&:to_s)
|
14
|
-
commands.include?(
|
15
|
-
|
14
|
+
commands.include?(Terraspace.argv[0]) || # IE: terraspace up
|
15
|
+
Terraspace.argv[0] == "all" && commands.include?(Terraspace.argv[1]) # IE: terraspace all up
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -19,7 +19,7 @@ module Terraspace::Compiler::Dsl::Syntax::Helpers
|
|
19
19
|
# terraspace_command('-') => "terraspace-up-demo"
|
20
20
|
#
|
21
21
|
def terraspace_command(separator=' ')
|
22
|
-
args =
|
22
|
+
args = Terraspace.argv[0..1] || []
|
23
23
|
command = ["terraspace"] + args
|
24
24
|
command.join(separator)
|
25
25
|
end
|
data/lib/terraspace/core.rb
CHANGED
@@ -58,5 +58,15 @@ module Terraspace
|
|
58
58
|
i.is_a?(Regexp) ? path =~ i : path.include?(i)
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
# Terraspace.argv provides consistency when terraspace is being called by rspec-terrspace test harness
|
63
|
+
# So use Terraspace.argv instead of ARGV constant
|
64
|
+
def argv=(argv)
|
65
|
+
@@argv = argv
|
66
|
+
end
|
67
|
+
|
68
|
+
def argv
|
69
|
+
@@argv
|
70
|
+
end
|
61
71
|
end
|
62
72
|
end
|
data/lib/terraspace/shell.rb
CHANGED
@@ -38,12 +38,12 @@ module Terraspace
|
|
38
38
|
BLOCK_SIZE = Integer(ENV['TS_BUFFER_BLOCK_SIZE'] || 102400)
|
39
39
|
BUFFER_TIMEOUT = Integer(ENV['TS_BUFFER_TIMEOUT'] || 3600) # 3600s = 1h
|
40
40
|
def handle_streams(stdin, stdout, stderr)
|
41
|
-
files = [stdout, stderr]
|
42
41
|
# note: t=0 and t=nil means no timeout. See: https://bit.ly/2PURlCX
|
43
42
|
t = BUFFER_TIMEOUT.to_i unless BUFFER_TIMEOUT.nil?
|
44
43
|
Timeout::timeout(t) do
|
44
|
+
files = [stdout, stderr]
|
45
45
|
until all_eof?(files) do
|
46
|
-
ready = IO.select(files
|
46
|
+
ready = IO.select(files)
|
47
47
|
next unless ready
|
48
48
|
|
49
49
|
readable = ready[0]
|
@@ -11,12 +11,24 @@ module Terraspace::Terraform::Args
|
|
11
11
|
# https://terraspace.cloud/docs/ci-automation/
|
12
12
|
ENV['TF_IN_AUTOMATION'] = '1' if @options[:auto]
|
13
13
|
|
14
|
-
|
14
|
+
args = []
|
15
|
+
|
16
|
+
if straight_delegate_args?
|
17
|
+
args += @options[:rest]
|
18
|
+
args.flatten!
|
19
|
+
end
|
20
|
+
|
21
|
+
args_meth = "#{@name}_args".gsub(' ', '_') # IE: apply_args, init_args
|
15
22
|
if respond_to?(args_meth)
|
16
|
-
send(args_meth)
|
17
|
-
else
|
18
|
-
[]
|
23
|
+
args += send(args_meth)
|
19
24
|
end
|
25
|
+
|
26
|
+
args
|
27
|
+
end
|
28
|
+
|
29
|
+
# delegate args straight through for special commands, currently state seems to be the only case
|
30
|
+
def straight_delegate_args?
|
31
|
+
@name.include?("state") # IE: "state list", "state pull", "state show"
|
20
32
|
end
|
21
33
|
|
22
34
|
def force_unlock_args
|
data/lib/terraspace/version.rb
CHANGED
data/terraspace.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_dependency "memoist"
|
29
29
|
spec.add_dependency "rainbow"
|
30
30
|
spec.add_dependency "render_me_pretty"
|
31
|
-
spec.add_dependency "terraspace-bundler", "~> 0.
|
31
|
+
spec.add_dependency "terraspace-bundler", "~> 0.4.0"
|
32
32
|
spec.add_dependency "thor"
|
33
33
|
spec.add_dependency "tty-tree"
|
34
34
|
spec.add_dependency "zeitwerk"
|
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_dependency "terraspace_plugin_aws", "~> 0.3.0"
|
38
38
|
spec.add_dependency "terraspace_plugin_azurerm", "~> 0.3.0"
|
39
39
|
spec.add_dependency "terraspace_plugin_google", "~> 0.3.0"
|
40
|
-
spec.add_dependency "rspec-terraspace", "~> 0.
|
40
|
+
spec.add_dependency "rspec-terraspace", "~> 0.3.0"
|
41
41
|
|
42
42
|
spec.add_development_dependency "bundler"
|
43
43
|
spec.add_development_dependency "byebug"
|
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.6.
|
4
|
+
version: 0.6.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.
|
159
|
+
version: 0.4.0
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.
|
166
|
+
version: 0.4.0
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: thor
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -254,14 +254,14 @@ dependencies:
|
|
254
254
|
requirements:
|
255
255
|
- - "~>"
|
256
256
|
- !ruby/object:Gem::Version
|
257
|
-
version: 0.
|
257
|
+
version: 0.3.0
|
258
258
|
type: :runtime
|
259
259
|
prerelease: false
|
260
260
|
version_requirements: !ruby/object:Gem::Requirement
|
261
261
|
requirements:
|
262
262
|
- - "~>"
|
263
263
|
- !ruby/object:Gem::Version
|
264
|
-
version: 0.
|
264
|
+
version: 0.3.0
|
265
265
|
- !ruby/object:Gem::Dependency
|
266
266
|
name: bundler
|
267
267
|
requirement: !ruby/object:Gem::Requirement
|
@@ -532,6 +532,7 @@ files:
|
|
532
532
|
- lib/terraspace/cli/help/refresh.md
|
533
533
|
- lib/terraspace/cli/help/seed.md
|
534
534
|
- lib/terraspace/cli/help/show.md
|
535
|
+
- lib/terraspace/cli/help/state.md
|
535
536
|
- lib/terraspace/cli/help/summary.md
|
536
537
|
- lib/terraspace/cli/help/test.md
|
537
538
|
- lib/terraspace/cli/help/tfc/destroy.md
|