smart_proxy_dynflow_core 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +0 -1
- data/lib/smart_proxy_dynflow_core.rb +2 -0
- data/lib/smart_proxy_dynflow_core/api.rb +11 -3
- data/lib/smart_proxy_dynflow_core/helpers.rb +4 -3
- data/lib/smart_proxy_dynflow_core/log.rb +2 -2
- data/lib/smart_proxy_dynflow_core/task_launcher_registry.rb +0 -1
- data/lib/smart_proxy_dynflow_core/version.rb +1 -1
- data/smart_proxy_dynflow_core.gemspec +1 -2
- metadata +5 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c1f0c156feee597ac1651b3e2270a61487bc5a218689674c14a25d0dd50461bd
|
4
|
+
data.tar.gz: 9eb3130e3cdbad8cf272beb4b1888dad7e6d37701d7a09b071c8b5b3418319c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac9892aaa66a79a9a91de820d00801c0cbae75a835a0af8d60b426a304d1d4c14c77e3847b6c832f0003c7e7cec90ba8981996853e1f6808f38555689a89c47f
|
7
|
+
data.tar.gz: c65919387feb38c36067ec8ebddc8578446062147162df7c1673fc0fb7df960e058ab444017bc19e8d63b25062fc867543935e3bab96167089fdd0e9f651d385
|
data/Gemfile
CHANGED
@@ -3,10 +3,17 @@ require 'multi_json'
|
|
3
3
|
|
4
4
|
module SmartProxyDynflowCore
|
5
5
|
class Api < ::Sinatra::Base
|
6
|
+
TASK_UPDATE_REGEXP_PATH = %r{/tasks/(\S+)/(update|done)}
|
6
7
|
helpers Helpers
|
7
8
|
|
8
9
|
before do
|
9
|
-
|
10
|
+
if match = request.path_info.match(TASK_UPDATE_REGEXP_PATH)
|
11
|
+
task_id = match[1]
|
12
|
+
action = match[2]
|
13
|
+
authorize_with_token(task_id: task_id, clear: action == 'done')
|
14
|
+
else
|
15
|
+
authorize_with_ssl_client
|
16
|
+
end
|
10
17
|
content_type :json
|
11
18
|
end
|
12
19
|
|
@@ -45,9 +52,10 @@ module SmartProxyDynflowCore
|
|
45
52
|
tasks_count(params['state']).to_json
|
46
53
|
end
|
47
54
|
|
48
|
-
post "/tasks/:task_id/done"
|
55
|
+
# capturing post "/tasks/:task_id/(update|done)"
|
56
|
+
post TASK_UPDATE_REGEXP_PATH do |task_id, _action|
|
49
57
|
data = MultiJson.load(request.body.read)
|
50
|
-
|
58
|
+
dispatch_external_event(task_id, data)
|
51
59
|
end
|
52
60
|
|
53
61
|
get "/tasks/operations" do
|
@@ -4,13 +4,14 @@ module SmartProxyDynflowCore
|
|
4
4
|
SmartProxyDynflowCore::Core.world
|
5
5
|
end
|
6
6
|
|
7
|
-
def authorize_with_token
|
7
|
+
def authorize_with_token(task_id:, clear: true)
|
8
8
|
if request.env.key? 'HTTP_AUTHORIZATION'
|
9
9
|
if defined?(::ForemanTasksCore)
|
10
10
|
auth = request.env['HTTP_AUTHORIZATION']
|
11
11
|
basic_prefix = /\ABasic /
|
12
12
|
if !auth.to_s.empty? && auth =~ basic_prefix &&
|
13
|
-
ForemanTasksCore::OtpManager.authenticate(auth.gsub(basic_prefix, '')
|
13
|
+
ForemanTasksCore::OtpManager.authenticate(auth.gsub(basic_prefix, ''),
|
14
|
+
expected_user: task_id, clear: clear)
|
14
15
|
Log.instance.debug('authorized with token')
|
15
16
|
return true
|
16
17
|
end
|
@@ -63,7 +64,7 @@ module SmartProxyDynflowCore
|
|
63
64
|
{ :count => tasks.count, :state => state }
|
64
65
|
end
|
65
66
|
|
66
|
-
def
|
67
|
+
def dispatch_external_event(task_id, params)
|
67
68
|
world.event(task_id,
|
68
69
|
params['step_id'].to_i,
|
69
70
|
::ForemanTasksCore::Runner::ExternalEvent.new(params))
|
@@ -55,7 +55,7 @@ module SmartProxyDynflowCore
|
|
55
55
|
|
56
56
|
class ProxyStructuredFormater < ::Dynflow::LoggerAdapters::Formatters::Abstract
|
57
57
|
def call(_severity, _datetime, _prog_name, message)
|
58
|
-
if ::Exception
|
58
|
+
if message.is_a?(::Exception)
|
59
59
|
subject = "#{message.message} (#{message.class})"
|
60
60
|
if @base.respond_to?(:exception)
|
61
61
|
@base.exception("Error details", message)
|
@@ -74,7 +74,7 @@ module SmartProxyDynflowCore
|
|
74
74
|
end
|
75
75
|
|
76
76
|
class ProxyAdapter < ::Dynflow::LoggerAdapters::Simple
|
77
|
-
def initialize(logger, level = Logger::DEBUG,
|
77
|
+
def initialize(logger, level = Logger::DEBUG, _formatters = [])
|
78
78
|
@logger = logger
|
79
79
|
@logger.level = level
|
80
80
|
@logger.formatter = ProxyStructuredFormater.new(@logger)
|
@@ -27,11 +27,10 @@ Gem::Specification.new do |gem|
|
|
27
27
|
gem.add_development_dependency('mocha', '~> 1')
|
28
28
|
gem.add_development_dependency('rack-test', '~> 0')
|
29
29
|
gem.add_development_dependency "rake", "~> 10.0"
|
30
|
-
gem.add_development_dependency('rubocop', '~> 0.52.1')
|
31
30
|
gem.add_development_dependency('webmock', '~> 1')
|
32
31
|
|
33
32
|
gem.add_runtime_dependency('dynflow', "~> 1.1")
|
34
|
-
gem.add_runtime_dependency('foreman-tasks-core', '>= 0.
|
33
|
+
gem.add_runtime_dependency('foreman-tasks-core', '>= 0.3.3')
|
35
34
|
gem.add_runtime_dependency('rack')
|
36
35
|
gem.add_runtime_dependency('rest-client')
|
37
36
|
gem.add_runtime_dependency('sequel')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_dynflow_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '10.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubocop
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 0.52.1
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 0.52.1
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: webmock
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +114,14 @@ dependencies:
|
|
128
114
|
requirements:
|
129
115
|
- - ">="
|
130
116
|
- !ruby/object:Gem::Version
|
131
|
-
version: 0.
|
117
|
+
version: 0.3.3
|
132
118
|
type: :runtime
|
133
119
|
prerelease: false
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
135
121
|
requirements:
|
136
122
|
- - ">="
|
137
123
|
- !ruby/object:Gem::Version
|
138
|
-
version: 0.
|
124
|
+
version: 0.3.3
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: rack
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -253,8 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
239
|
- !ruby/object:Gem::Version
|
254
240
|
version: '0'
|
255
241
|
requirements: []
|
256
|
-
|
257
|
-
rubygems_version: 2.6.12
|
242
|
+
rubygems_version: 3.0.3
|
258
243
|
signing_key:
|
259
244
|
specification_version: 4
|
260
245
|
summary: Dynflow runtime for Foreman smart proxy
|