opswalrus 1.0.14 → 1.0.16

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: 9ee2d0af10d38f7722a8af82b44af64f3c0d906de21b4425d472d4e27b9495b0
4
- data.tar.gz: e42c56ffcdf0c1cf1b08e68771dcf46364439c057393ed325b5325964816d1a8
3
+ metadata.gz: f6d990ac1fac1a918ebca3eac342377ee61702f0864e635e378ad8e69d7ec0d5
4
+ data.tar.gz: 900661d04774a42b0a960624fd7fc51b9690c23ad15fba5aaf94f8a3e1241de6
5
5
  SHA512:
6
- metadata.gz: 39a22eed3d76788bb6d70ad4f4700d512a4e9612614508e407ee9d0187bd2f0aab3593845f5f6a8adb91020d330bd7d955bbe21c869c3aa7e6c1185af4204b6a
7
- data.tar.gz: 63e635e997cead804423e1c966e7e429538e625532277b98178c19186345455b469222d5eabd4b7829998690753ba8d95d09788248b167e706d3512d05ece6de
6
+ metadata.gz: 88e94b27da26afb8b925f1b363c6ccf889f3e105d28e3f7d2ccfd1d2d8fe1b61d443d64dc1829c42b8644216e19bad1c4e384757246414b62dc18104421cb8fe
7
+ data.tar.gz: 3e5b2b2062a592102bed054b7bae779a66b676ca8d47beb42cbab0a6cc6096e191129b3fd9a2c6fc815f8964bf78270b15687cbba99787c0323fb51c87e82c9c
data/Gemfile.lock CHANGED
@@ -1,12 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- opswalrus (1.0.14)
4
+ opswalrus (1.0.16)
5
+ amazing_print (~> 1.5)
5
6
  bcrypt_pbkdf (~> 1.1)
6
7
  citrus (~> 3.0)
7
8
  ed25519 (~> 1.3)
8
9
  git (~> 1.18)
9
10
  gli (~> 2.21)
11
+ ougai (~> 2.0)
10
12
  rubyzip (~> 2.3)
11
13
  sshkit (~> 1.21)
12
14
 
@@ -15,6 +17,7 @@ GEM
15
17
  specs:
16
18
  addressable (2.8.5)
17
19
  public_suffix (>= 2.0.2, < 6.0)
20
+ amazing_print (1.5.0)
18
21
  bcrypt_pbkdf (1.1.0)
19
22
  citrus (3.0.2)
20
23
  diff-lcs (1.5.0)
@@ -26,6 +29,9 @@ GEM
26
29
  net-scp (4.0.0)
27
30
  net-ssh (>= 2.6.5, < 8.0.0)
28
31
  net-ssh (7.2.0)
32
+ oj (3.16.0)
33
+ ougai (2.0.0)
34
+ oj (~> 3.10)
29
35
  public_suffix (5.0.3)
30
36
  rake (13.0.6)
31
37
  rchardet (1.8.0)
data/lib/opswalrus/app.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  require "citrus"
2
2
  require "io/console"
3
3
  require "json"
4
- require "logger"
4
+ # require "logger"
5
5
  require "random/formatter"
6
+ require "ougai"
6
7
  require "shellwords"
7
8
  require "socket"
8
9
  require "stringio"
@@ -31,7 +32,9 @@ module OpsWalrus
31
32
  attr_reader :local_hostname
32
33
 
33
34
  def initialize(pwd = Dir.pwd)
34
- @logger = Logger.new($stdout, level: Logger::INFO)
35
+ @logger = Ougai::Logger.new($stdout, level: Logger::INFO) # Logger.new($stdout, level: Logger::INFO)
36
+ @logger.formatter = Ougai::Formatters::Readable.new
37
+
35
38
 
36
39
  @verbose = false
37
40
  @sudo_user = nil
@@ -117,6 +120,10 @@ module OpsWalrus
117
120
  @logger.debug(msg)
118
121
  end
119
122
 
123
+ def trace(msg)
124
+ @logger.trace(msg)
125
+ end
126
+
120
127
  def set_pwd(pwd)
121
128
  @pwd = pwd.to_pathname
122
129
  @bundler = Bundler.new(@pwd)
@@ -6,94 +6,8 @@ require_relative "invocation"
6
6
 
7
7
  module OpsWalrus
8
8
 
9
- class HostProxyOpsFileInvocationBuilder
10
- def initialize(host_proxy, is_invocation_a_call_to_package_in_bundle_dir = false)
11
- @host_proxy = host_proxy
12
- @is_invocation_a_call_to_package_in_bundle_dir = is_invocation_a_call_to_package_in_bundle_dir
13
- @method_chain = []
14
- end
15
-
16
- def method_missing(method_name, *args, **kwargs)
17
- @method_chain << method_name.to_s
18
-
19
- if args.empty? && kwargs.empty? # when there are no args and no kwargs, we are just drilling down through another namespace
20
- self
21
- else
22
- # when there are args or kwargs, then the method invocation represents an attempt to run an OpsFile on a remote host,
23
- # so we want to build up a command and send it to the remote host via HostDSL#run_ops
24
- @method_chain.unshift(Bundler::BUNDLE_DIR) if @is_invocation_a_call_to_package_in_bundle_dir
25
-
26
- remote_run_command_args = @method_chain.join(" ")
27
-
28
- unless args.empty?
29
- remote_run_command_args << " "
30
- remote_run_command_args << args.join(" ")
31
- end
32
-
33
- unless kwargs.empty?
34
- remote_run_command_args << " "
35
- remote_run_command_args << kwargs.map do |k, v|
36
- case v
37
- when Array
38
- v.map {|v_element| "#{k}:#{v_element}" }
39
- else
40
- "#{k}:#{v}"
41
- end
42
- end.join(" ")
43
- end
44
-
45
- @host_proxy.run_ops(:run, "--script", remote_run_command_args)
46
- end
47
- end
48
- end
49
-
50
9
  # the subclasses of HostProxy will define methods that handle method dispatch via HostProxyOpsFileInvocationBuilder objects
51
10
  class HostProxy
52
- # def self.define_host_proxy_class(ops_file)
53
- # klass = Class.new(HostProxy)
54
-
55
- # methods_defined = Set.new
56
-
57
- # # define methods for every import in the script
58
- # ops_file.local_symbol_table.each do |symbol_name, import_reference|
59
- # unless methods_defined.include? symbol_name
60
- # # puts "1. defining: #{symbol_name}(...)"
61
- # klass.define_method(symbol_name) do |*args, **kwargs, &block|
62
- # invocation_builder = case import_reference
63
- # # we know we're dealing with a package dependency reference, so we want to run an ops file contained within the bundle directory,
64
- # # therefore, we want to reference the specified ops file with respect to the bundle dir
65
- # when PackageDependencyReference
66
- # HostProxyOpsFileInvocationBuilder.new(self, true)
67
-
68
- # # we know we're dealing with a directory reference or OpsFile reference outside of the bundle dir, so we want to reference
69
- # # the specified ops file with respect to the root directory, and not with respect to the bundle dir
70
- # when DirectoryReference, OpsFileReference
71
- # HostProxyOpsFileInvocationBuilder.new(self, false)
72
- # end
73
-
74
- # invocation_builder.send(symbol_name, *args, **kwargs, &block)
75
- # end
76
- # methods_defined << symbol_name
77
- # end
78
- # end
79
-
80
- # # define methods for every Namespace or OpsFile within the namespace that the OpsFile resides within
81
- # sibling_symbol_table = Set.new
82
- # sibling_symbol_table |= ops_file.dirname.glob("*.ops").map {|ops_file_path| ops_file_path.basename(".ops").to_s } # OpsFiles
83
- # sibling_symbol_table |= ops_file.dirname.glob("*").select(&:directory?).map {|dir_path| dir_path.basename.to_s } # Namespaces
84
- # sibling_symbol_table.each do |symbol_name|
85
- # unless methods_defined.include? symbol_name
86
- # # puts "2. defining: #{symbol_name}(...)"
87
- # klass.define_method(symbol_name) do |*args, **kwargs, &block|
88
- # invocation_builder = HostProxyOpsFileInvocationBuilder.new(self, false)
89
- # invocation_builder.invoke(symbol_name, *args, **kwargs, &block)
90
- # end
91
- # methods_defined << symbol_name
92
- # end
93
- # end
94
-
95
- # klass
96
- # end
97
11
 
98
12
  def self.define_host_proxy_class(ops_file)
99
13
  klass = Class.new(HostProxy)
@@ -122,21 +36,6 @@ module OpsWalrus
122
36
 
123
37
  invocation_context._invoke(*args, **kwargs)
124
38
 
125
-
126
-
127
- # invocation_builder = case import_reference
128
- # # we know we're dealing with a package dependency reference, so we want to run an ops file contained within the bundle directory,
129
- # # therefore, we want to reference the specified ops file with respect to the bundle dir
130
- # when PackageDependencyReference
131
- # HostProxyOpsFileInvocationBuilder.new(self, true)
132
-
133
- # # we know we're dealing with a directory reference or OpsFile reference outside of the bundle dir, so we want to reference
134
- # # the specified ops file with respect to the root directory, and not with respect to the bundle dir
135
- # when DirectoryReference, OpsFileReference
136
- # HostProxyOpsFileInvocationBuilder.new(self, false)
137
- # end
138
-
139
- # invocation_builder.send(symbol_name, *args, **kwargs, &block)
140
39
  end
141
40
  methods_defined << symbol_name
142
41
  end
@@ -150,9 +49,6 @@ module OpsWalrus
150
49
  unless methods_defined.include? symbol_name
151
50
  # puts "2. defining: #{symbol_name}(...)"
152
51
  klass.define_method(symbol_name) do |*args, **kwargs, &block|
153
- # invocation_builder = HostProxyOpsFileInvocationBuilder.new(self, false)
154
- # invocation_builder.invoke(symbol_name, *args, **kwargs, &block)
155
-
156
52
  invocation_context = RemoteImportInvocationContext.new(@runtime_env, self, namespace_or_ops_file, false)
157
53
  invocation_context._invoke(*args, **kwargs)
158
54
  end
@@ -202,6 +98,7 @@ module OpsWalrus
202
98
  return ["", "", 0] if !desc_or_cmd && !cmd && !block # we were told to do nothing; like hitting enter at the bash prompt; we can do nothing successfully
203
99
 
204
100
  description = desc_or_cmd if cmd || block
101
+ description = WalrusLang.render(description, block.binding) if description && block
205
102
  cmd = block.call if block
206
103
  cmd ||= desc_or_cmd
207
104
 
@@ -264,6 +264,7 @@ module OpsWalrus
264
264
  return ["", "", 0] if !desc_or_cmd && !cmd && !block # we were told to do nothing; like hitting enter at the bash prompt; we can do nothing successfully
265
265
 
266
266
  description = desc_or_cmd if cmd || block
267
+ description = WalrusLang.render(description, block.binding) if description && block
267
268
  cmd = block.call if block
268
269
  cmd ||= desc_or_cmd
269
270
 
@@ -1,3 +1,3 @@
1
1
  module OpsWalrus
2
- VERSION = "1.0.14"
2
+ VERSION = "1.0.16"
3
3
  end
data/opswalrus.gemspec CHANGED
@@ -32,9 +32,11 @@ Gem::Specification.new do |spec|
32
32
  spec.require_paths = ["lib"]
33
33
 
34
34
  # gem dependencies
35
+ spec.add_dependency "amazing_print", "~> 1.5"
35
36
  spec.add_dependency "citrus", "~> 3.0"
36
37
  spec.add_dependency "gli", "~> 2.21"
37
38
  spec.add_dependency "git", "~> 1.18"
39
+ spec.add_dependency "ougai", "~> 2.0"
38
40
  spec.add_dependency "rubyzip", "~> 2.3"
39
41
 
40
42
  spec.add_dependency "bcrypt_pbkdf", "~> 1.1"
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opswalrus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.14
4
+ version: 1.0.16
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-08-22 00:00:00.000000000 Z
11
+ date: 2023-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: amazing_print
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: citrus
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +66,20 @@ dependencies:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
68
  version: '1.18'
69
+ - !ruby/object:Gem::Dependency
70
+ name: ougai
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: rubyzip
57
85
  requirement: !ruby/object:Gem::Requirement