dtk-client 0.7.5 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dtk +12 -1
- data/dtk-client.gemspec +1 -1
- data/lib/command_helpers/git_repo/merge.rb +139 -0
- data/lib/command_helpers/git_repo.rb +29 -51
- data/lib/command_helpers/service_importer.rb +1 -1
- data/lib/commands/common/thor/assembly_workspace.rb +55 -42
- data/lib/commands/common/thor/pull_from_remote.rb +11 -3
- data/lib/commands/common/thor/puppet_forge.rb +1 -1
- data/lib/commands/thor/component_module.rb +3 -1
- data/lib/commands/thor/developer.rb +25 -4
- data/lib/commands/thor/node.rb +5 -2
- data/lib/commands/thor/node_group.rb +1 -1
- data/lib/commands/thor/service.rb +39 -23
- data/lib/commands/thor/workspace.rb +48 -11
- data/lib/domain/git_adapter.rb +8 -0
- data/lib/dtk-client/version.rb +1 -1
- data/lib/execute/cli_pure/cli_rerouter.rb +3 -0
- data/lib/parser/adapters/thor.rb +1 -1
- data/lib/shell/context.rb +1 -1
- data/lib/{commands/common/thor/task_status → task_status}/refresh_mode.rb +0 -0
- data/lib/{commands/common/thor/task_status → task_status}/snapshot_mode.rb +0 -0
- data/lib/task_status/stream_mode/element/format.rb +86 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/result/action.rb +76 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/result/components.rb +9 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/result/node_level.rb +9 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/result.rb +55 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/steps/action.rb +37 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/steps/components.rb +36 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/steps/node_level.rb +25 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/steps.rb +17 -0
- data/lib/task_status/stream_mode/element/hierarchical_task.rb +83 -0
- data/lib/{commands/common/thor/task_status → task_status}/stream_mode/element/no_results.rb +0 -0
- data/lib/task_status/stream_mode/element/render.rb +42 -0
- data/lib/task_status/stream_mode/element/stage/render.rb +59 -0
- data/lib/task_status/stream_mode/element/stage.rb +67 -0
- data/lib/task_status/stream_mode/element/task_end.rb +19 -0
- data/lib/task_status/stream_mode/element/task_start.rb +21 -0
- data/lib/task_status/stream_mode/element.rb +85 -0
- data/lib/{commands/common/thor/task_status → task_status}/stream_mode.rb +5 -5
- data/lib/{commands/common/thor/task_status.rb → task_status.rb} +15 -12
- data/lib/util/os_util.rb +8 -0
- metadata +26 -14
- data/lib/commands/common/thor/task_status/stream_mode/element/render.rb +0 -88
- data/lib/commands/common/thor/task_status/stream_mode/element/stage.rb +0 -13
- data/lib/commands/common/thor/task_status/stream_mode/element/task_end.rb +0 -10
- data/lib/commands/common/thor/task_status/stream_mode/element/task_start.rb +0 -10
- data/lib/commands/common/thor/task_status/stream_mode/element.rb +0 -90
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dtk-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rich PELAVIN
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime-types
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - '='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.7.
|
117
|
+
version: 0.7.3
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - '='
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.7.
|
124
|
+
version: 0.7.3
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: git
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- lib/client.rb
|
202
202
|
- lib/command_helper.rb
|
203
203
|
- lib/command_helpers/git_repo.rb
|
204
|
+
- lib/command_helpers/git_repo/merge.rb
|
204
205
|
- lib/command_helpers/jenkins_client.rb
|
205
206
|
- lib/command_helpers/jenkins_client/config_xml.rb
|
206
207
|
- lib/command_helpers/service_importer.rb
|
@@ -234,16 +235,6 @@ files:
|
|
234
235
|
- lib/commands/common/thor/remotes.rb
|
235
236
|
- lib/commands/common/thor/reparse.rb
|
236
237
|
- lib/commands/common/thor/set_required_attributes.rb
|
237
|
-
- lib/commands/common/thor/task_status.rb
|
238
|
-
- lib/commands/common/thor/task_status/refresh_mode.rb
|
239
|
-
- lib/commands/common/thor/task_status/snapshot_mode.rb
|
240
|
-
- lib/commands/common/thor/task_status/stream_mode.rb
|
241
|
-
- lib/commands/common/thor/task_status/stream_mode/element.rb
|
242
|
-
- lib/commands/common/thor/task_status/stream_mode/element/no_results.rb
|
243
|
-
- lib/commands/common/thor/task_status/stream_mode/element/render.rb
|
244
|
-
- lib/commands/common/thor/task_status/stream_mode/element/stage.rb
|
245
|
-
- lib/commands/common/thor/task_status/stream_mode/element/task_end.rb
|
246
|
-
- lib/commands/common/thor/task_status/stream_mode/element/task_start.rb
|
247
238
|
- lib/commands/thor/account.rb
|
248
239
|
- lib/commands/thor/assembly.rb
|
249
240
|
- lib/commands/thor/attribute.rb
|
@@ -321,6 +312,27 @@ files:
|
|
321
312
|
- lib/shell/message_queue.rb
|
322
313
|
- lib/shell/parse_monkey_patch.rb
|
323
314
|
- lib/shell/status_monitor.rb
|
315
|
+
- lib/task_status.rb
|
316
|
+
- lib/task_status/refresh_mode.rb
|
317
|
+
- lib/task_status/snapshot_mode.rb
|
318
|
+
- lib/task_status/stream_mode.rb
|
319
|
+
- lib/task_status/stream_mode/element.rb
|
320
|
+
- lib/task_status/stream_mode/element/format.rb
|
321
|
+
- lib/task_status/stream_mode/element/hierarchical_task.rb
|
322
|
+
- lib/task_status/stream_mode/element/hierarchical_task/result.rb
|
323
|
+
- lib/task_status/stream_mode/element/hierarchical_task/result/action.rb
|
324
|
+
- lib/task_status/stream_mode/element/hierarchical_task/result/components.rb
|
325
|
+
- lib/task_status/stream_mode/element/hierarchical_task/result/node_level.rb
|
326
|
+
- lib/task_status/stream_mode/element/hierarchical_task/steps.rb
|
327
|
+
- lib/task_status/stream_mode/element/hierarchical_task/steps/action.rb
|
328
|
+
- lib/task_status/stream_mode/element/hierarchical_task/steps/components.rb
|
329
|
+
- lib/task_status/stream_mode/element/hierarchical_task/steps/node_level.rb
|
330
|
+
- lib/task_status/stream_mode/element/no_results.rb
|
331
|
+
- lib/task_status/stream_mode/element/render.rb
|
332
|
+
- lib/task_status/stream_mode/element/stage.rb
|
333
|
+
- lib/task_status/stream_mode/element/stage/render.rb
|
334
|
+
- lib/task_status/stream_mode/element/task_end.rb
|
335
|
+
- lib/task_status/stream_mode/element/task_start.rb
|
324
336
|
- lib/util/common_util.rb
|
325
337
|
- lib/util/console.rb
|
326
338
|
- lib/util/dtk_puppet.rb
|
@@ -1,88 +0,0 @@
|
|
1
|
-
module DTK::Client; class TaskStatus::StreamMode
|
2
|
-
class Element
|
3
|
-
module RenderMixin
|
4
|
-
end
|
5
|
-
end
|
6
|
-
end; end
|
7
|
-
|
8
|
-
=begin
|
9
|
-
def task_status_old()
|
10
|
-
current_index = 1
|
11
|
-
last_printed_index = 0
|
12
|
-
success_indices = []
|
13
|
-
loop do
|
14
|
-
response = post_call(:form => :stream_form)
|
15
|
-
return response unless response.ok?
|
16
|
-
|
17
|
-
current_tasks = response.data.select { |el| el['index'] == current_index }
|
18
|
-
main_task = current_tasks.find { |el| el['sub_index'].nil? }
|
19
|
-
|
20
|
-
# this means this is last tasks
|
21
|
-
unless main_task
|
22
|
-
print_succeeded_tasks(response.data, success_indices)
|
23
|
-
return Response::Ok.new()
|
24
|
-
end
|
25
|
-
|
26
|
-
case main_task['status']
|
27
|
-
when 'executing'
|
28
|
-
if (last_printed_index != current_index)
|
29
|
-
OsUtil.clear_screen
|
30
|
-
print_succeeded_tasks(response.data, success_indices)
|
31
|
-
print_tasks(current_tasks)
|
32
|
-
last_printed_index = current_index
|
33
|
-
end
|
34
|
-
when 'succeeded'
|
35
|
-
success_indices << current_index
|
36
|
-
current_index += 1
|
37
|
-
when nil
|
38
|
-
# ignore
|
39
|
-
else
|
40
|
-
errors = current_tasks.collect { |ct| ct['errors'] }.compact
|
41
|
-
error_msg = errors.collect { |err| err['message'] }.uniq.join(', ')
|
42
|
-
raise DtkError, "We've run into an error on task '#{main_task['type']}' status '#{main_task['status']}', error: #{error_msg}"
|
43
|
-
end
|
44
|
-
|
45
|
-
sleep(5)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
def print_tasks(tasks)
|
51
|
-
hirb_options = {
|
52
|
-
:headers => nil,
|
53
|
-
:filters => [Proc.new { |a| append_to(25, a) },
|
54
|
-
Proc.new { |a| append_to(15, a)},
|
55
|
-
Proc.new { |a| append_to(15, a)},
|
56
|
-
Proc.new { |a| append_to(8, a)}],
|
57
|
-
:unicode => true,
|
58
|
-
:description => false
|
59
|
-
}
|
60
|
-
|
61
|
-
tasks.each do |task|
|
62
|
-
node_name = task['node'] ? task['node']['name'] : ''
|
63
|
-
|
64
|
-
puts Hirb::Helpers::AutoTable.render([[task['type'], task['status'], node_name, task['duration'], parse_date(task['started_at']), parse_date(task['ended_at'])]], hirb_options)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def print_succeeded_tasks(tasks, success_indices)
|
69
|
-
succeeded_tasks = tasks.select { |task| success_indices.include?(task['index']) }
|
70
|
-
print_tasks(succeeded_tasks)
|
71
|
-
end
|
72
|
-
|
73
|
-
def parse_date(string_date)
|
74
|
-
string_date.nil? ? (' ' * 17) : DateTime.parse(string_date).strftime('%H:%M:%S %d/%m/%y')
|
75
|
-
end
|
76
|
-
|
77
|
-
def append_to(number_of_chars, value)
|
78
|
-
value ||= ''
|
79
|
-
value.strip!
|
80
|
-
appending_str = ' ' * (number_of_chars - value.size)
|
81
|
-
value.insert(0, appending_str)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
=end
|
88
|
-
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module DTK::Client; class TaskStatus::StreamMode
|
2
|
-
class Element
|
3
|
-
class Stage < self
|
4
|
-
def self.get(task_status_handle,stage_num)
|
5
|
-
get_stages(task_status_handle,stage_num,stage_num)
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.get_stages(task_status_handle,start_stage_num,end_stage_num)
|
9
|
-
get_task_status_elements(task_status_handle,:stage,:start_index => start_stage_num, :end_index => end_stage_num)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end; end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
module DTK::Client; class TaskStatus::StreamMode
|
2
|
-
class Element
|
3
|
-
require File.expand_path('element/task_start',File.dirname(__FILE__))
|
4
|
-
require File.expand_path('element/task_end',File.dirname(__FILE__))
|
5
|
-
require File.expand_path('element/stage',File.dirname(__FILE__))
|
6
|
-
require File.expand_path('element/no_results',File.dirname(__FILE__))
|
7
|
-
require File.expand_path('element/render',File.dirname(__FILE__))
|
8
|
-
include RenderMixin
|
9
|
-
|
10
|
-
def initialize(response_element)
|
11
|
-
@response_element = response_element
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.get_and_render_task_start(task_status_handle)
|
15
|
-
render_elements(TaskStart.get(task_status_handle))
|
16
|
-
end
|
17
|
-
|
18
|
-
# opts has
|
19
|
-
# :wait - amount to wait if get no results (required)
|
20
|
-
def self.get_and_render_stages(task_status_handle,opts={})
|
21
|
-
unless wait = opts[:wait]
|
22
|
-
raise DtkError::Client, "opts[:wait] must be set"
|
23
|
-
end
|
24
|
-
|
25
|
-
stage = 1
|
26
|
-
task_end = false
|
27
|
-
until task_end do
|
28
|
-
elements = Stage.get(task_status_handle,stage)
|
29
|
-
if no_results_yet?(elements)
|
30
|
-
sleep wait
|
31
|
-
next
|
32
|
-
end
|
33
|
-
|
34
|
-
render_elements(elements)
|
35
|
-
|
36
|
-
if task_end?(elements)
|
37
|
-
task_end = true
|
38
|
-
else
|
39
|
-
stage += 1
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def render()
|
45
|
-
#TODO: stub
|
46
|
-
#TODO: make this nil and overwride all elements types to render
|
47
|
-
pp [:element,self.class,self]
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
# opts will have
|
52
|
-
# :start_index
|
53
|
-
# :end_index
|
54
|
-
def self.get_task_status_elements(task_status_handle,element_type,opts={})
|
55
|
-
response = task_status_handle.post_call(opts.merge(:form => :stream_form))
|
56
|
-
create_elements(response)
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.create_elements(response)
|
60
|
-
response_elements = response.data
|
61
|
-
unless response_elements.kind_of?(Array)
|
62
|
-
raise DtkError::Client.new("Unexpected that response.data no at array")
|
63
|
-
end
|
64
|
-
response_elements.map{|el|create(el)}
|
65
|
-
end
|
66
|
-
def self.create(response_element)
|
67
|
-
type = response_element['type']
|
68
|
-
case type && type.to_sym
|
69
|
-
when :task_start then TaskStart.new(response_element)
|
70
|
-
when :task_end then TaskEnd.new(response_element)
|
71
|
-
when :stage then Stage.new(response_element)
|
72
|
-
when :no_results then NoResults.new(response_element)
|
73
|
-
else raise DtkError::Client.new("Unexpected element type '#{type}'")
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def self.task_end?(elements)
|
78
|
-
elements.empty? or elements.last.kind_of?(TaskEnd)
|
79
|
-
end
|
80
|
-
|
81
|
-
def self.no_results_yet?(elements)
|
82
|
-
elements.find{|el|el.kind_of?(NoResults)}
|
83
|
-
end
|
84
|
-
|
85
|
-
def self.render_elements(elements)
|
86
|
-
elements.each{|el|el.render()}
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
end; end
|