loom-core 0.0.6 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +31 -0
- data/Gemfile.lock +108 -56
- data/Rakefile +2 -0
- data/bin/loom +3 -0
- data/docs/architecture.jpg +0 -0
- data/gentags.sh +2 -0
- data/lib/loom/all.rb +1 -1
- data/lib/loom/config.rb +2 -2
- data/lib/loom/method_signature.rb +1 -1
- data/lib/loom/mods/action_proxy.rb +2 -2
- data/lib/loom/mods/mod_loader.rb +10 -5
- data/lib/loom/mods/module.rb +6 -5
- data/lib/loom/pattern/all.rb +1 -0
- data/lib/loom/pattern/definition_context.rb +7 -5
- data/lib/loom/pattern/dsl.rb +184 -119
- data/lib/loom/pattern/expanding_reference.rb +82 -6
- data/lib/loom/pattern/loader.rb +2 -18
- data/lib/loom/pattern/pattern.rb +52 -0
- data/lib/loom/pattern/reference.rb +17 -13
- data/lib/loom/pattern/reference_set.rb +71 -50
- data/lib/loom/runner/all.rb +2 -0
- data/lib/loom/runner/execution_context.rb +9 -0
- data/lib/loom/{dsl.rb → runner/sshkit_connector.rb} +5 -7
- data/lib/loom/runner.rb +46 -33
- data/lib/loom/shell/api.rb +3 -3
- data/lib/loom/shell/cmd_wrapper.rb +5 -2
- data/lib/loom/shell/core.rb +16 -16
- data/lib/loom/shell.rb +4 -2
- data/lib/loom/version.rb +1 -1
- data/lib/loomext/coremods/exec.rb +1 -0
- data/lib/loomext/coremods/systemd/all.rb +1 -0
- data/lib/loomext/coremods/systemd/hostname.rb +10 -0
- data/loom.TAGS +797 -0
- data/loom.gemspec +4 -3
- data/spec/.loom/error_handling.loom +1 -0
- data/spec/.loom/fail.loom +27 -13
- data/spec/.loom/files.loom +1 -0
- data/spec/.loom/inventory.yml +3 -0
- data/spec/.loom/net.loom +1 -0
- data/spec/.loom/pattern_context.loom +1 -0
- data/spec/.loom/pkg.loom +1 -0
- data/spec/.loom/regression.loom +23 -0
- data/spec/.loom/shell.loom +1 -0
- data/spec/.loom/test.loom +21 -4
- data/spec/.loom/user.loom +1 -0
- data/spec/.loom/vms.loom +1 -0
- data/spec/loom/host_spec_spec.rb +1 -1
- data/spec/loom/pattern/dsl_spec.rb +3 -2
- data/spec/shared/loom_internals_helper.rb +1 -1
- data/spec/test_loom_spec.rb +102 -42
- data/test +15 -0
- metadata +40 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76771b34a40961ff3eec048ed42682f49488cfd2f770d35ca2e19c255b534051
|
4
|
+
data.tar.gz: f9a8fec00bf59b419af9669b263ff09fa34224429640dd49d68aa110de49ea5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1b14c69e8ce6a26d399f0f7bdc8fa71c2d41204b3199169d7c0ec00b37549c378bb50a7e30c4875661e43b0da7cead2aaa58936bf644d9bd9e716965bc39dd3
|
7
|
+
data.tar.gz: 152a387d0f25af816f35b6695c3a0827fe576acaf049be7c94931261d00f53b03402c2c79db0459854df0d25ba11aa4cb330649a786b67727bdf2d93b0250c2b
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# https://rubocop.readthedocs.io/en/latest/cops_layout/
|
2
|
+
Layout/EmptyLineAfterGuardClause:
|
3
|
+
Enabled: false
|
4
|
+
Layout/EmptyLinesAroundModuleBody:
|
5
|
+
Enabled: false
|
6
|
+
Layout/EmptyLinesAroundClassBody:
|
7
|
+
Enabled: false
|
8
|
+
Layout/MultilineMethodCallBrace:
|
9
|
+
Enabled: false
|
10
|
+
Layout/MultilineMethodCallIndentation:
|
11
|
+
EnforcedStyle: indented
|
12
|
+
|
13
|
+
Lint/BooleanSymbol:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
# https://rubocop.readthedocs.io/en/latest/cops_metrics/
|
17
|
+
Metrics/LineLength:
|
18
|
+
Max: 100
|
19
|
+
|
20
|
+
Naming/HeredocDelimiterNaming:
|
21
|
+
Enable: false
|
22
|
+
|
23
|
+
# https://rubocop.readthedocs.io/en/latest/cops_style/
|
24
|
+
Style/Alias:
|
25
|
+
Enabled: false
|
26
|
+
Style/ClassAndModuleChildren:
|
27
|
+
Enabled: false
|
28
|
+
Style/Encoding:
|
29
|
+
Enabled: false
|
30
|
+
Sylte/IfUnlessModifier:
|
31
|
+
Enabled: false
|
data/Gemfile.lock
CHANGED
@@ -1,33 +1,47 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
loom-core (0.0.
|
4
|
+
loom-core (0.0.8)
|
5
5
|
bcrypt_pbkdf (>= 1.0, < 2.0)
|
6
6
|
commander (~> 4.4)
|
7
7
|
ed25519 (>= 1.0, < 2.0)
|
8
8
|
net-ssh (>= 5)
|
9
|
-
rbnacl-libsodium (= 1.0.
|
10
|
-
sshkit (~> 1.
|
9
|
+
rbnacl-libsodium (= 1.0.16)
|
10
|
+
sshkit (~> 1.23)
|
11
11
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
15
|
+
ast (2.4.2)
|
16
|
+
base64 (0.2.0)
|
17
|
+
bcrypt_pbkdf (1.1.1)
|
18
|
+
bcrypt_pbkdf (1.1.1-arm64-darwin)
|
19
|
+
bcrypt_pbkdf (1.1.1-x86_64-darwin)
|
20
|
+
byebug (11.1.3)
|
21
|
+
coderay (1.1.3)
|
22
|
+
commander (4.6.0)
|
23
|
+
highline (~> 2.0.0)
|
24
|
+
diff-lcs (1.5.1)
|
25
|
+
ed25519 (1.3.0)
|
26
|
+
ffi (1.17.0)
|
27
|
+
ffi (1.17.0-aarch64-linux-gnu)
|
28
|
+
ffi (1.17.0-aarch64-linux-musl)
|
29
|
+
ffi (1.17.0-arm-linux-gnu)
|
30
|
+
ffi (1.17.0-arm-linux-musl)
|
31
|
+
ffi (1.17.0-arm64-darwin)
|
32
|
+
ffi (1.17.0-x86-linux-gnu)
|
33
|
+
ffi (1.17.0-x86-linux-musl)
|
34
|
+
ffi (1.17.0-x86_64-darwin)
|
35
|
+
ffi (1.17.0-x86_64-linux-gnu)
|
36
|
+
ffi (1.17.0-x86_64-linux-musl)
|
37
|
+
formatador (1.1.0)
|
38
|
+
guard (2.19.0)
|
25
39
|
formatador (>= 0.2.4)
|
26
40
|
listen (>= 2.7, < 4.0)
|
27
|
-
lumberjack (
|
41
|
+
lumberjack (>= 1.0.12, < 2.0)
|
28
42
|
nenv (~> 0.1)
|
29
43
|
notiffany (~> 0.0)
|
30
|
-
pry (>= 0.
|
44
|
+
pry (>= 0.13.0)
|
31
45
|
shellany (~> 0.0)
|
32
46
|
thor (>= 0.18.1)
|
33
47
|
guard-compat (1.2.1)
|
@@ -35,67 +49,105 @@ GEM
|
|
35
49
|
guard (~> 2.1)
|
36
50
|
guard-compat (~> 1.1)
|
37
51
|
rspec (>= 2.99.0, < 4.0)
|
38
|
-
highline (
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
52
|
+
highline (2.0.3)
|
53
|
+
json (2.8.2)
|
54
|
+
language_server-protocol (3.17.0.3)
|
55
|
+
listen (3.9.0)
|
56
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
57
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
58
|
+
lumberjack (1.2.10)
|
59
|
+
method_source (1.1.0)
|
45
60
|
nenv (0.3.0)
|
46
|
-
net-scp (
|
47
|
-
net-ssh (>= 2.6.5)
|
48
|
-
net-
|
49
|
-
|
61
|
+
net-scp (4.0.0)
|
62
|
+
net-ssh (>= 2.6.5, < 8.0.0)
|
63
|
+
net-sftp (4.0.0)
|
64
|
+
net-ssh (>= 5.0.0, < 8.0.0)
|
65
|
+
net-ssh (7.3.0)
|
66
|
+
notiffany (0.1.3)
|
50
67
|
nenv (~> 0.1)
|
51
68
|
shellany (~> 0.0)
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
69
|
+
ostruct (0.6.1)
|
70
|
+
parallel (1.26.3)
|
71
|
+
parser (3.3.6.0)
|
72
|
+
ast (~> 2.4.1)
|
73
|
+
racc
|
74
|
+
pry (0.14.2)
|
75
|
+
coderay (~> 1.1)
|
76
|
+
method_source (~> 1.0)
|
77
|
+
pry-byebug (3.10.1)
|
78
|
+
byebug (~> 11.0)
|
79
|
+
pry (>= 0.13, < 0.15)
|
80
|
+
racc (1.8.1)
|
81
|
+
rainbow (3.1.1)
|
59
82
|
rake (11.3.0)
|
60
|
-
rb-fsevent (0.
|
61
|
-
rb-inotify (0.
|
62
|
-
ffi (
|
63
|
-
rbnacl (
|
64
|
-
ffi
|
65
|
-
rbnacl-libsodium (1.0.
|
83
|
+
rb-fsevent (0.11.2)
|
84
|
+
rb-inotify (0.11.1)
|
85
|
+
ffi (~> 1.0)
|
86
|
+
rbnacl (7.1.2)
|
87
|
+
ffi (~> 1)
|
88
|
+
rbnacl-libsodium (1.0.16)
|
66
89
|
rbnacl (>= 3.0.1)
|
67
|
-
|
68
|
-
|
69
|
-
rspec-
|
70
|
-
rspec-
|
71
|
-
|
72
|
-
|
73
|
-
|
90
|
+
regexp_parser (2.9.3)
|
91
|
+
rspec (3.13.0)
|
92
|
+
rspec-core (~> 3.13.0)
|
93
|
+
rspec-expectations (~> 3.13.0)
|
94
|
+
rspec-mocks (~> 3.13.0)
|
95
|
+
rspec-core (3.13.2)
|
96
|
+
rspec-support (~> 3.13.0)
|
97
|
+
rspec-expectations (3.13.3)
|
74
98
|
diff-lcs (>= 1.2.0, < 2.0)
|
75
|
-
rspec-support (~> 3.
|
76
|
-
rspec-mocks (3.
|
99
|
+
rspec-support (~> 3.13.0)
|
100
|
+
rspec-mocks (3.13.2)
|
77
101
|
diff-lcs (>= 1.2.0, < 2.0)
|
78
|
-
rspec-support (~> 3.
|
79
|
-
rspec-support (3.
|
80
|
-
|
102
|
+
rspec-support (~> 3.13.0)
|
103
|
+
rspec-support (3.13.1)
|
104
|
+
rubocop (1.69.0)
|
105
|
+
json (~> 2.3)
|
106
|
+
language_server-protocol (>= 3.17.0)
|
107
|
+
parallel (~> 1.10)
|
108
|
+
parser (>= 3.3.0.2)
|
109
|
+
rainbow (>= 2.2.2, < 4.0)
|
110
|
+
regexp_parser (>= 2.4, < 3.0)
|
111
|
+
rubocop-ast (>= 1.36.1, < 2.0)
|
112
|
+
ruby-progressbar (~> 1.7)
|
113
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
114
|
+
rubocop-ast (1.36.2)
|
115
|
+
parser (>= 3.3.1.0)
|
116
|
+
ruby-progressbar (1.13.0)
|
81
117
|
shellany (0.0.1)
|
82
|
-
|
83
|
-
|
118
|
+
sshkit (1.23.2)
|
119
|
+
base64
|
84
120
|
net-scp (>= 1.1.2)
|
121
|
+
net-sftp (>= 2.1.2)
|
85
122
|
net-ssh (>= 2.8.0)
|
86
|
-
|
123
|
+
ostruct
|
124
|
+
thor (1.3.2)
|
125
|
+
unicode-display_width (3.1.2)
|
126
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
127
|
+
unicode-emoji (4.0.4)
|
87
128
|
|
88
129
|
PLATFORMS
|
130
|
+
aarch64-linux-gnu
|
131
|
+
aarch64-linux-musl
|
132
|
+
arm-linux-gnu
|
133
|
+
arm-linux-musl
|
134
|
+
arm64-darwin
|
89
135
|
ruby
|
136
|
+
x86-linux-gnu
|
137
|
+
x86-linux-musl
|
138
|
+
x86_64-darwin
|
139
|
+
x86_64-linux-gnu
|
140
|
+
x86_64-linux-musl
|
90
141
|
|
91
142
|
DEPENDENCIES
|
92
|
-
bundler
|
143
|
+
bundler
|
93
144
|
guard-rspec (~> 4.7)
|
94
145
|
loom-core!
|
95
146
|
pry (~> 0.10)
|
96
147
|
pry-byebug
|
97
148
|
rake (~> 11.3)
|
98
149
|
rspec (~> 3.5)
|
150
|
+
rubocop
|
99
151
|
|
100
152
|
BUNDLED WITH
|
101
|
-
|
153
|
+
2.5.23
|
data/Rakefile
CHANGED
data/bin/loom
CHANGED
@@ -158,6 +158,9 @@ EOS
|
|
158
158
|
end
|
159
159
|
end
|
160
160
|
end
|
161
|
+
# TODO: p and patterns produce different output on failure, p is a
|
162
|
+
# truncated stack. Figure out why, and fix that. This is going to be
|
163
|
+
# somewhere in Commander.
|
161
164
|
alias_command :"p", :"patterns"
|
162
165
|
|
163
166
|
command :"config" do |c|
|
Binary file
|
data/gentags.sh
ADDED
data/lib/loom/all.rb
CHANGED
@@ -9,12 +9,12 @@ require_relative "config"
|
|
9
9
|
|
10
10
|
require_relative "shell"
|
11
11
|
require_relative "host_spec"
|
12
|
-
require_relative "dsl"
|
13
12
|
|
14
13
|
require_relative "inventory"
|
15
14
|
require_relative "facts"
|
16
15
|
require_relative "pattern"
|
17
16
|
require_relative "mods"
|
17
|
+
require_relative "runner/all"
|
18
18
|
require_relative "runner"
|
19
19
|
|
20
20
|
require_relative "version"
|
data/lib/loom/config.rb
CHANGED
@@ -69,7 +69,7 @@ module Loom
|
|
69
69
|
map = config ? config.config_map : CONFIG_VARS.dup
|
70
70
|
config_struct = OpenStruct.new **map
|
71
71
|
yield config_struct if block_given?
|
72
|
-
Config.new config_struct.to_h
|
72
|
+
Config.new **config_struct.to_h
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -77,7 +77,7 @@ module Loom
|
|
77
77
|
class FileManager
|
78
78
|
|
79
79
|
def initialize(config)
|
80
|
-
@loom_search_paths = config.loom_search_paths
|
80
|
+
@loom_search_paths = [config.loom_search_paths].flatten
|
81
81
|
@loom_files = config.loom_files
|
82
82
|
@loom_file_patterns = config.loom_file_patterns
|
83
83
|
end
|
@@ -40,7 +40,7 @@ module Loom::Mods
|
|
40
40
|
# idiomatic.
|
41
41
|
bound_action_name = tuple[1]
|
42
42
|
|
43
|
-
define_method public_action_name do |*args, &block|
|
43
|
+
define_method public_action_name do |*args, **kwargs, &block|
|
44
44
|
# TODO[P0]: Effectively this is the API for all mods, but it's
|
45
45
|
# burried here in the middle of nowhere. Add documentation - or make
|
46
46
|
# it easier to read.
|
@@ -48,7 +48,7 @@ module Loom::Mods
|
|
48
48
|
"proxy to mod action: #{public_action_name} => #{bound_action_name}, #{@mod}"
|
49
49
|
end
|
50
50
|
|
51
|
-
@mod.send bound_action_name, *args, &block
|
51
|
+
@mod.send bound_action_name, *args, **kwargs, &block
|
52
52
|
end
|
53
53
|
Loom.log.debug2 self do
|
54
54
|
"defined action proxy action: #{public_action_name} => #{bound_action_name}"
|
data/lib/loom/mods/mod_loader.rb
CHANGED
@@ -10,7 +10,12 @@ module Loom::Mods
|
|
10
10
|
@loom_config = loom_config
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def load_mod_klass(mod_klass, shell)
|
14
|
+
verify_shell_cmds mod_klass, shell
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
def verify_shell_cmds(mod_klass, shell)
|
14
19
|
Loom.log.debug2(self) { "verifying cmds for mod => #{mod_klass}" }
|
15
20
|
mod_klass.required_commands.each do |cmd|
|
16
21
|
begin
|
@@ -49,14 +54,14 @@ module Loom::Mods
|
|
49
54
|
raise ModDefinedError, name if instance_methods.include? name
|
50
55
|
registered_mods[mod_klass.name] = [name]
|
51
56
|
|
52
|
-
define_method name do |shell, *args, &pattern_block|
|
57
|
+
define_method name do |shell, *args, **kwargs, &pattern_block|
|
53
58
|
Loom.log.debug3(self) do
|
54
|
-
"handling mod call => #{mod_klass}##{name} #{args} #{pattern_block}"
|
59
|
+
"handling mod call => #{mod_klass}##{name} #{args} #{kwargs} #{pattern_block}"
|
55
60
|
end
|
56
|
-
|
61
|
+
load_mod_klass mod_klass, shell
|
57
62
|
|
58
63
|
mod = mod_klass.new shell, @loom_config
|
59
|
-
mod.execute *args, &pattern_block
|
64
|
+
mod.execute *args, **kwargs, &pattern_block
|
60
65
|
end
|
61
66
|
end
|
62
67
|
|
data/lib/loom/mods/module.rb
CHANGED
@@ -32,13 +32,13 @@ module Loom::Mods
|
|
32
32
|
@action_block = pattern_block
|
33
33
|
end
|
34
34
|
|
35
|
-
def execute(*args, &pattern_block)
|
35
|
+
def execute(*args, **kwargs, &pattern_block)
|
36
36
|
if respond_to? :mod_block
|
37
37
|
Loom.log.debug3(self) { "executing mod block => #{args} #{pattern_block}" }
|
38
|
-
mod_block *args, &pattern_block
|
38
|
+
mod_block *args, **kwargs, &pattern_block
|
39
39
|
else
|
40
40
|
Loom.log.debug3(self) { "initing action => #{args}" }
|
41
|
-
init_action *args, &pattern_block
|
41
|
+
init_action *args, **kwargs, &pattern_block
|
42
42
|
|
43
43
|
# TODO: ooohhh... the action_proxy code path is fucking
|
44
44
|
# crazy. ActionProxy needs some documentation.
|
@@ -99,11 +99,12 @@ module Loom::Mods
|
|
99
99
|
# (e.g.) to each instance of Module. (actually I think it's because this
|
100
100
|
# is executing from the subclass (via import_actions), so it's only that
|
101
101
|
# class). in any case, add more docs and code pointers.
|
102
|
-
define_method bound_method_name do |*args, &block|
|
102
|
+
define_method bound_method_name do |*args, **kwargs, &block|
|
103
103
|
Loom.log.debug1(self) { "exec mod action #{self.class}##{bound_method_name}" }
|
104
104
|
|
105
105
|
bound_method = unbound_method.bind self
|
106
|
-
|
106
|
+
|
107
|
+
bound_method.call *args, **kwargs, &block
|
107
108
|
end
|
108
109
|
Loom.log.debug2(self) { "bound mod action => #{self.class.name}##{action_name}" }
|
109
110
|
|
data/lib/loom/pattern/all.rb
CHANGED
@@ -8,11 +8,11 @@ module Loom::Pattern
|
|
8
8
|
|
9
9
|
NilLetValueError = Class.new Loom::LoomError
|
10
10
|
|
11
|
-
def initialize(
|
12
|
-
@fact_map =
|
13
|
-
@let_map =
|
11
|
+
def initialize(dsl_builder, parent_context=nil)
|
12
|
+
@fact_map = dsl_builder.facts.dup
|
13
|
+
@let_map = dsl_builder.let_map.dup
|
14
14
|
|
15
|
-
@hooks =
|
15
|
+
@hooks = dsl_builder.hooks.dup
|
16
16
|
@parent_context = parent_context
|
17
17
|
|
18
18
|
@merged_fact_map = merged_fact_map
|
@@ -46,7 +46,9 @@ module Loom::Pattern
|
|
46
46
|
|
47
47
|
if value.nil? || value.equal?(Loom::Facts::EMPTY)
|
48
48
|
Loom.log.error "value of let expression[:#{let_key}] is nil"
|
49
|
-
|
49
|
+
# TODO: I'm not sure what to do here, but raising an error isn't
|
50
|
+
# very user friendly.... as I just learned.
|
51
|
+
# raise NilLetValueError, "empty value for let[#{let_key}]"
|
50
52
|
end
|
51
53
|
scope_object.define_singleton_method(let_key) { value }
|
52
54
|
end
|