opswalrus 1.0.37 → 1.0.39

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab53631e63fd44c1825e7a38721905420b063e4480ace3cb48c9d5aad922dc14
4
- data.tar.gz: aecd03aadaab772dfae1e8379036038ed17e0c57b78c75c178f70c4b3a65afeb
3
+ metadata.gz: 413ca26075395f1e533a83af05aae8522f66fb91b96de13d8932f5856053222d
4
+ data.tar.gz: cf99aa4a8e71dba2a36129ed3ca2cb51b603d106fd240a0d1d39784e53e6806c
5
5
  SHA512:
6
- metadata.gz: af2a6bc851e53a1bee7e2b1d9d7dd57f2f953661223d464f57c7e7e8157b4ab725c9db90cc835380c12c6a9f5438a515e435cf4009e753492c6304e7a3b2a750
7
- data.tar.gz: 15fbd461e6c794325bee7def61a517b91c840318348b83e83639c175d3efb5f1a5cbd424b6a8634bfdc20c2b2805af383aee3ce1d7870a1dd222e843ef9ed509
6
+ metadata.gz: 5ba6764a3018cc959a075b9616d14116ae28c565a53f557864fb6d9ce1b922d75439e79b1563fedd7a4a5cd2a17277243ee8b1d47d5f82c30f6898d08b4088bc
7
+ data.tar.gz: f8985876bbc10366839f871818a50d4578728d63f5234ec13479a54801b5771fc8f5e7f9a5c3328c58a508997cd5e12b581b45de1aae759e1a6a71dedeb33118
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- opswalrus (1.0.37)
4
+ opswalrus (1.0.39)
5
5
  amazing_print (~> 1.5)
6
6
  bcrypt_pbkdf (~> 1.1)
7
7
  binding_of_caller (~> 1.0)
@@ -224,7 +224,15 @@ module OpsWalrus
224
224
  end
225
225
 
226
226
  def desc(msg)
227
- puts msg.mustache(2)
227
+ puts msg.mustache(2) # we use two here, because one stack frame accounts for the call from the ops script into HostProxy#desc
228
+ end
229
+
230
+ def env(*args, **kwargs)
231
+ @ops_file_script.env(*args, **kwargs)
232
+ end
233
+
234
+ def params(*args, **kwargs)
235
+ @ops_file_script.params(*args, **kwargs)
228
236
  end
229
237
 
230
238
  def host_prop(name)
@@ -360,6 +368,10 @@ module OpsWalrus
360
368
  @runtime_env = runtime_env
361
369
  end
362
370
 
371
+ def set_ops_file_script(ops_file_script)
372
+ @ops_file_script = ops_file_script
373
+ end
374
+
363
375
  def set_ssh_session_connection(sshkit_backend)
364
376
  @sshkit_backend = sshkit_backend
365
377
  end
@@ -370,6 +382,7 @@ module OpsWalrus
370
382
 
371
383
  def clear_ssh_session
372
384
  @runtime_env = nil
385
+ ops_file_script = nil
373
386
  @sshkit_backend = nil
374
387
  @tmp_bundle_root_dir = nil
375
388
  @tmp_ssh_key_files.each {|tmpfile| tmpfile.close() rescue nil; File.unlink(tmpfile) rescue nil }
@@ -141,12 +141,11 @@ module OpsWalrus
141
141
  def _invoke(runtime_env, hashlike_params)
142
142
  @runtime_env = runtime_env
143
143
  @params = InvocationParams.new(hashlike_params)
144
- params = @params
145
144
  #{ruby_script}
146
145
  end
147
146
  INVOKE_METHOD
148
147
 
149
- invoke_method_line_count_prior_to_ruby_script_from_ops_file = 4
148
+ invoke_method_line_count_prior_to_ruby_script_from_ops_file = 3
150
149
  klass.module_eval(invoke_method_definition, ops_file.ops_file_path.to_s, ops_file.script_line_offset - invoke_method_line_count_prior_to_ruby_script_from_ops_file)
151
150
 
152
151
  klass
@@ -161,6 +160,7 @@ module OpsWalrus
161
160
  @ops_file = ops_file
162
161
  @script = ruby_script
163
162
  @runtime_env = nil # this is set at the very first line of #_invoke
163
+ @params = nil # this is set at the very first line of #_invoke
164
164
  end
165
165
 
166
166
  def backend
@@ -184,6 +184,15 @@ module OpsWalrus
184
184
  raise "Not implemented in base class."
185
185
  end
186
186
 
187
+ def params(*keys, default: nil)
188
+ keys = keys.map(&:to_s)
189
+ if keys.empty?
190
+ @params
191
+ else
192
+ @params.dig(*keys) || default
193
+ end
194
+ end
195
+
187
196
  def to_s
188
197
  @script
189
198
  end
@@ -107,7 +107,7 @@ module OpsWalrus
107
107
  hosts = inventory(*args, **kwargs).map {|host| host_proxy_class.new(runtime_env, host) }
108
108
  sshkit_hosts = hosts.map(&:sshkit_host)
109
109
  sshkit_host_to_ops_host_map = sshkit_hosts.zip(hosts).to_h
110
- local_host = self
110
+ ops_file_script = local_host = self
111
111
  # bootstrap_shell_script = BootstrapLinuxHostShellScript
112
112
  # on sshkit_hosts do |sshkit_host|
113
113
  SSHKit::Coordinator.new(sshkit_hosts).each(in: kwargs[:in] || :parallel) do |sshkit_host|
@@ -116,6 +116,7 @@ module OpsWalrus
116
116
 
117
117
  begin
118
118
  host.set_runtime_env(runtime_env)
119
+ host.set_ops_file_script(ops_file_script)
119
120
  host.set_ssh_session_connection(self) # self is an instance of one of the subclasses of SSHKit::Backend::Abstract, e.g. SSHKit::Backend::Netssh
120
121
 
121
122
  host._bootstrap_host
@@ -162,7 +163,7 @@ module OpsWalrus
162
163
 
163
164
  def exit(exit_status, message = nil)
164
165
  if message
165
- puts message.mustache(3)
166
+ puts message.mustache(1)
166
167
  end
167
168
  result = if exit_status == 0
168
169
  Invocation::Success.new(nil)
@@ -172,15 +173,6 @@ module OpsWalrus
172
173
  throw :exit_now, result
173
174
  end
174
175
 
175
- def env(*keys)
176
- keys = keys.map(&:to_s)
177
- if keys.empty?
178
- @runtime_env.env
179
- else
180
- @runtime_env.env.dig(*keys)
181
- end
182
- end
183
-
184
176
  # currently, import may only be used to import a package that is referenced in the script's package file
185
177
  # I may decide to extend this to work with dynamic package references
186
178
  #
@@ -198,17 +190,17 @@ module OpsWalrus
198
190
  # invocation_context._invoke(*args, **kwargs)
199
191
  end
200
192
 
201
- # def params(*keys, default: nil)
202
- # keys = keys.map(&:to_s)
203
- # if keys.empty?
204
- # @params
205
- # else
206
- # @params.dig(*keys) || default
207
- # end
208
- # end
209
-
210
193
  def desc(msg)
211
- puts msg.mustache(2)
194
+ puts msg.mustache(1)
195
+ end
196
+
197
+ def env(*keys)
198
+ keys = keys.map(&:to_s)
199
+ if keys.empty?
200
+ @runtime_env.env
201
+ else
202
+ @runtime_env.env.dig(*keys)
203
+ end
212
204
  end
213
205
 
214
206
  # runs the given command
@@ -1,3 +1,3 @@
1
1
  module OpsWalrus
2
- VERSION = "1.0.37"
2
+ VERSION = "1.0.39"
3
3
  end
@@ -74,8 +74,10 @@ class String
74
74
  WalrusLang.render(self, hash)
75
75
  end
76
76
 
77
- def mustache(bindings_from_stack_frame_offset = 2)
78
- WalrusLang.eval(self, bindings_from_stack_frame_offset)
77
+ # bindings_from_stack_frame_offset is a count relative to the stack from from which #mustache is called
78
+ def mustache(bindings_from_stack_frame_offset = 0)
79
+ base_offset = 2
80
+ WalrusLang.eval(self, base_offset + bindings_from_stack_frame_offset)
79
81
  end
80
82
  end
81
83
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opswalrus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.37
4
+ version: 1.0.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Ellis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-05 00:00:00.000000000 Z
11
+ date: 2023-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: amazing_print