smart_proxy_openbolt 0.1.1 → 1.2.0

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.
@@ -1,7 +1,6 @@
1
1
  require 'json'
2
2
  require 'smart_proxy_openbolt/error'
3
3
  require 'smart_proxy_openbolt/job'
4
- require 'smart_proxy_openbolt/main'
5
4
  require 'smart_proxy_openbolt/result'
6
5
 
7
6
  module Proxy::OpenBolt
@@ -16,58 +15,54 @@ module Proxy::OpenBolt
16
15
  end
17
16
 
18
17
  def execute
19
- command = get_cmd
20
- stdout, stderr, status = Proxy::OpenBolt.openbolt(command)
21
- Proxy::OpenBolt::Result.new(
22
- Proxy::OpenBolt.scrub(@options, command),
18
+ command = ['bolt', 'task', 'run', @name,
19
+ '--targets', @targets.join(','),
20
+ '--no-save-rerun',
21
+ "--concurrency=#{Plugin.settings.concurrency}",
22
+ "--connect-timeout=#{Plugin.settings.connect_timeout}",
23
+ '--project', Plugin.settings.environment_path,
24
+ '--format', 'json',
25
+ '--no-color']
26
+ command.concat(parse_options)
27
+ command.concat(parse_parameters)
28
+ stdout, stderr, exitcode = Proxy::OpenBolt.openbolt(command)
29
+ Result.new(
30
+ Proxy::OpenBolt.scrub(@options, command.join(' ')),
23
31
  Proxy::OpenBolt.scrub(@options, stdout),
24
32
  Proxy::OpenBolt.scrub(@options, stderr),
25
- status.exitstatus
33
+ exitcode
26
34
  )
27
35
  end
28
36
 
29
- def get_cmd
30
- # Service config settings (not per-task)
31
- concurrency = "--concurrency=#{Proxy::OpenBolt::Plugin.settings.concurrency}"
32
- connect_timeout = "--connect-timeout=#{Proxy::OpenBolt::Plugin.settings.connect_timeout}"
33
- "bolt task run #{@name} --targets #{@targets.join(',')} --no-save-rerun #{concurrency} #{connect_timeout} --project #{Proxy::OpenBolt::Plugin.settings.environment_path} --format json --no-color #{parse_options} #{parse_parameters}"
34
- end
35
-
36
37
  def parse_parameters
37
- params = []
38
- @parameters.each do |key, value|
39
- if value.is_a?(Array)
40
- params << "#{key}='#{value}'"
41
- elsif value.is_a?(Hash)
42
- params << "#{key}='#{value.to_json}'"
43
- else
44
- params << "#{key}=#{value}"
45
- end
38
+ @parameters.map do |key, value|
39
+ formatted = value.is_a?(Array) || value.is_a?(Hash) ? value.to_json : value
40
+ "#{key}=#{formatted}"
46
41
  end
47
- params.join(' ')
48
42
  end
49
43
 
50
44
  def parse_options
51
- opt_str = ''
52
- if @options
53
- @options.each do |key, value|
54
- # --noop doesn't have a --[no-] prefix
55
- next if key == 'noop' && value.is_a?(FalseClass)
56
- # For some mindboggling reason, there are both '--log-level trace'
57
- # and '--trace' options. We only expose log level, so just
58
- # tack on --trace if that's what we find.
59
- if key == 'log-level' && value == 'trace'
60
- opt_str += "--log-level=trace --trace "
61
- elsif value.is_a?(TrueClass)
62
- opt_str += "--#{key} "
63
- elsif value.is_a?(FalseClass)
64
- opt_str += "--no-#{key} "
65
- else
66
- opt_str += "--#{key}=#{value} "
67
- end
45
+ opts = []
46
+ return opts unless @options
47
+
48
+ @options.each do |key, value|
49
+ # --noop doesn't have a --[no-] prefix
50
+ next if key == 'noop' && value.is_a?(FalseClass)
51
+ # For some mindboggling reason, there are both '--log-level trace'
52
+ # and '--trace' options. We only expose log level, so just
53
+ # tack on --trace if that's what we find.
54
+ if key == 'log-level' && value == 'trace'
55
+ opts << '--log-level=trace'
56
+ opts << '--trace'
57
+ elsif value.is_a?(TrueClass)
58
+ opts << "--#{key}"
59
+ elsif value.is_a?(FalseClass)
60
+ opts << "--no-#{key}"
61
+ else
62
+ opts << "--#{key}=#{value}"
68
63
  end
69
64
  end
70
- opt_str
65
+ opts
71
66
  end
72
67
  end
73
68
  end
@@ -1,5 +1,5 @@
1
1
  module Proxy
2
2
  module OpenBolt
3
- VERSION = '0.1.1'
3
+ VERSION = '1.2.0'.freeze
4
4
  end
5
5
  end
@@ -1,3 +1,4 @@
1
+ # OpenBolt Smart Proxy
1
2
  ---
2
3
  :enabled: https
3
4
  :environment_path: /etc/puppetlabs/code/environments/production
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_proxy_openbolt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Overlook InfraTech
@@ -42,10 +42,12 @@ files:
42
42
  - bundler.d/openbolt.rb
43
43
  - lib/smart_proxy_openbolt.rb
44
44
  - lib/smart_proxy_openbolt/api.rb
45
+ - lib/smart_proxy_openbolt/config/choria-client.conf
45
46
  - lib/smart_proxy_openbolt/error.rb
46
47
  - lib/smart_proxy_openbolt/executor.rb
47
48
  - lib/smart_proxy_openbolt/http_config.ru
48
49
  - lib/smart_proxy_openbolt/job.rb
50
+ - lib/smart_proxy_openbolt/lru_cache.rb
49
51
  - lib/smart_proxy_openbolt/main.rb
50
52
  - lib/smart_proxy_openbolt/plugin.rb
51
53
  - lib/smart_proxy_openbolt/result.rb
@@ -55,7 +57,8 @@ files:
55
57
  homepage: http://github.com/overlookinfra/smart_proxy_openbolt
56
58
  licenses:
57
59
  - GPL-3.0-only
58
- metadata: {}
60
+ metadata:
61
+ rubygems_mfa_required: 'true'
59
62
  rdoc_options: []
60
63
  require_paths:
61
64
  - lib
@@ -70,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
73
  - !ruby/object:Gem::Version
71
74
  version: '0'
72
75
  requirements: []
73
- rubygems_version: 3.6.9
76
+ rubygems_version: 4.0.6
74
77
  specification_version: 4
75
78
  summary: Smart Proxy plugin for OpenBolt integration
76
79
  test_files: []