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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c2aa6a1c4c6ccf4382d03834690a695627f66d10
4
- data.tar.gz: 6aedf16460fbc6924fac95e1dd4be0ead1b4fc37
2
+ SHA256:
3
+ metadata.gz: c1f0c156feee597ac1651b3e2270a61487bc5a218689674c14a25d0dd50461bd
4
+ data.tar.gz: 9eb3130e3cdbad8cf272beb4b1888dad7e6d37701d7a09b071c8b5b3418319c4
5
5
  SHA512:
6
- metadata.gz: 5aac4b464edb1a3171bb52a6599823e336f532d0dec0dff6a9ffda3343bfea7900ae23e45eba36070f16a34f8fbffd6be97fd53e7af1c81a360a3bcc50a23714
7
- data.tar.gz: fcee792dcf9c2494a1437799f4c57bf67cbe5dd6de6debb41ce406edc48cff00948158fe74d70fb180f72c0ae2e08476512f82a38461d303cac1bea1b54a7c7b
6
+ metadata.gz: ac9892aaa66a79a9a91de820d00801c0cbae75a835a0af8d60b426a304d1d4c14c77e3847b6c832f0003c7e7cec90ba8981996853e1f6808f38555689a89c47f
7
+ data.tar.gz: c65919387feb38c36067ec8ebddc8578446062147162df7c1673fc0fb7df960e058ab444017bc19e8d63b25062fc867543935e3bab96167089fdd0e9f651d385
data/Gemfile CHANGED
@@ -13,7 +13,6 @@ group :test do
13
13
  if RUBY_VERSION < '2.1'
14
14
  gem 'public_suffix', '< 3'
15
15
  gem 'rainbow', '< 3'
16
- gem 'rubocop', '< 0.51.0'
17
16
  else
18
17
  gem 'public_suffix'
19
18
  gem 'rubocop', '~> 0.52.1'
@@ -1,3 +1,5 @@
1
+ raise LoadError, 'Ruby >= 2.1 is required' unless RUBY_VERSION >= '2.1'
2
+
1
3
  require 'dynflow'
2
4
  require 'smart_proxy_dynflow_core/task_launcher_registry'
3
5
  require 'foreman_tasks_core'
@@ -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
- authorize_with_token || authorize_with_ssl_client
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" do |task_id|
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
- complete_task(task_id, data)
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 complete_task(task_id, params)
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 === message
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, formatters = [])
77
+ def initialize(logger, level = Logger::DEBUG, _formatters = [])
78
78
  @logger = logger
79
79
  @logger.level = level
80
80
  @logger.formatter = ProxyStructuredFormater.new(@logger)
@@ -1,7 +1,6 @@
1
1
  module SmartProxyDynflowCore
2
2
  class TaskLauncherRegistry
3
3
  class << self
4
-
5
4
  def register(name, launcher)
6
5
  registry[name] = launcher
7
6
  end
@@ -1,3 +1,3 @@
1
1
  module SmartProxyDynflowCore
2
- VERSION = '0.2.2'.freeze
2
+ VERSION = '0.2.3'.freeze
3
3
  end
@@ -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.1.7')
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.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-01-08 00:00:00.000000000 Z
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.1.7
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.1.7
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
- rubyforge_project:
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