terraspace 1.0.5 → 1.0.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 +3 -0
- data/lib/terraspace/app.rb +2 -0
- data/lib/terraspace/autodetect.rb +3 -7
- data/lib/terraspace/compiler/expander/backend.rb +1 -1
- data/lib/terraspace/compiler/expander.rb +38 -14
- data/lib/terraspace/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57c0c4f1c1fce5c1dd8fcd7447f5bc5a82e17d66e5353f4d092d492c137021e5
|
4
|
+
data.tar.gz: 81a4ba08410e898a1dd057625ca556392e746c4b48a3453874472c60424c3949
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e629795fd75ad23d343ec28390e76756650f11740c6b380ad3df87cb216f7a998acfea282ebb1a1399343c3db2b5abe452705bb82fd61e76a8cd1a2ca258300b
|
7
|
+
data.tar.gz: 7104217cb56ee3ba2317d4d2abe0d4f760fe35de359903349a97bef4c2de3c92aaff3e0605789fd9e970f8a841a2203dedc9d740d9bddf127d2555a3f3818f30
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,9 @@
|
|
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
|
+
## [1.0.6] - 2022-01-24
|
7
|
+
- [#195](https://github.com/boltops-tools/terraspace/pull/195) improve autodetection for plugin expander for backend like remote
|
8
|
+
|
6
9
|
## [1.0.5] - 2022-01-23
|
7
10
|
- [#194](https://github.com/boltops-tools/terraspace/pull/194) ability to allow and deny envs, regions, and stacks
|
8
11
|
|
data/lib/terraspace/app.rb
CHANGED
@@ -33,6 +33,8 @@ module Terraspace
|
|
33
33
|
config.all.consider_allow_deny_stacks = true
|
34
34
|
|
35
35
|
config.auto_create_backend = true
|
36
|
+
config.autodetect = ActiveSupport::OrderedOptions.new
|
37
|
+
config.autodetect.expander = nil
|
36
38
|
config.build = ActiveSupport::OrderedOptions.new
|
37
39
|
config.build.cache_dir = ":CACHE_ROOT/:REGION/:ENV/:BUILD_DIR"
|
38
40
|
config.build.cache_root = nil # defaults to /full/path/to/.terraspace-cache
|
@@ -2,13 +2,9 @@ module Terraspace
|
|
2
2
|
class Autodetect
|
3
3
|
def plugin
|
4
4
|
plugins = Terraspace::Plugin.meta.keys
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
precedence = %w[aws azurerm google]
|
9
|
-
precedence.find do |p|
|
10
|
-
plugins.include?(p)
|
11
|
-
end
|
5
|
+
precedence = %w[aws azurerm google]
|
6
|
+
precedence.find do |p|
|
7
|
+
plugins.include?(p)
|
12
8
|
end
|
13
9
|
end
|
14
10
|
end
|
@@ -3,8 +3,8 @@ module Terraspace::Compiler
|
|
3
3
|
extend Memoist
|
4
4
|
delegate :expand, :expansion, to: :expander
|
5
5
|
|
6
|
-
def initialize(mod,
|
7
|
-
@mod, @
|
6
|
+
def initialize(mod, backend=nil)
|
7
|
+
@mod, @backend = mod, backend
|
8
8
|
end
|
9
9
|
|
10
10
|
def expander
|
@@ -12,27 +12,51 @@ module Terraspace::Compiler
|
|
12
12
|
end
|
13
13
|
memoize :expander
|
14
14
|
|
15
|
+
# IE: TerraspacePluginAws::Interfaces::Expander
|
15
16
|
def expander_class
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
class_name = expander_class_name
|
18
|
+
class_name ? class_name.constantize : Terraspace::Plugin::Expander::Generic
|
19
|
+
rescue NameError => e
|
20
|
+
logger.debug "#{e.class}: #{e.message}"
|
20
21
|
Terraspace::Plugin::Expander::Generic
|
21
22
|
end
|
22
23
|
|
24
|
+
def expander_class_name
|
25
|
+
plugin = Terraspace.config.autodetect.expander # contains plugin name. IE: aws, azurerm, google
|
26
|
+
if plugin
|
27
|
+
# early return for user override of autodetection
|
28
|
+
return Terraspace::Plugin.klass("Expander", plugin: plugin) # can return nil
|
29
|
+
end
|
30
|
+
|
31
|
+
backend = @backend || parse_backend
|
32
|
+
class_name = Terraspace::Plugin.klass("Expander", backend: backend) # can return nil
|
33
|
+
unless class_name
|
34
|
+
backend = plugin_backend
|
35
|
+
class_name = Terraspace::Plugin.klass("Expander", backend: backend) # can return nil
|
36
|
+
end
|
37
|
+
class_name
|
38
|
+
end
|
39
|
+
|
40
|
+
# autodetect by parsing backend.tf or backend.rb
|
41
|
+
def parse_backend
|
42
|
+
Backend.new(@mod).detect
|
43
|
+
end
|
44
|
+
|
45
|
+
# autodetect by looking up loaded plugins
|
46
|
+
def plugin_backend
|
47
|
+
plugin = Terraspace::Autodetect.new.plugin # IE: aws, azurerm, google
|
48
|
+
if plugin
|
49
|
+
data = Terraspace::Plugin.meta[plugin]
|
50
|
+
data[:backend] # IE: s3, azurerm, gcs
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
23
54
|
class << self
|
24
55
|
extend Memoist
|
25
|
-
|
26
56
|
def autodetect(mod, opts={})
|
27
|
-
|
28
|
-
new(mod, backend)
|
57
|
+
new(mod, opts)
|
29
58
|
end
|
30
59
|
memoize :autodetect
|
31
|
-
|
32
|
-
def find_backend(mod)
|
33
|
-
Backend.new(mod).detect
|
34
|
-
end
|
35
|
-
memoize :find_backend
|
36
60
|
end
|
37
61
|
end
|
38
62
|
end
|
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: 1.0.
|
4
|
+
version: 1.0.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: 2022-01-
|
11
|
+
date: 2022-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|