dtk-client 0.8.0 → 0.9.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.
Files changed (146) hide show
  1. checksums.yaml +13 -5
  2. data/dtk-client.gemspec +2 -2
  3. data/lib/auxiliary.rb +1 -1
  4. data/lib/client.rb +1 -1
  5. data/lib/command_helper.rb +1 -1
  6. data/lib/command_helpers/git_repo/merge.rb +1 -1
  7. data/lib/command_helpers/git_repo.rb +1 -1
  8. data/lib/command_helpers/jenkins_client/config_xml.rb +1 -1
  9. data/lib/command_helpers/jenkins_client.rb +1 -1
  10. data/lib/command_helpers/service_importer.rb +6 -2
  11. data/lib/command_helpers/service_link.rb +1 -1
  12. data/lib/command_helpers/test_module_creator.rb +1 -1
  13. data/lib/commands/common/thor/access_control.rb +1 -1
  14. data/lib/commands/common/thor/action_result_handler.rb +57 -57
  15. data/lib/commands/common/thor/assembly_template.rb +1 -1
  16. data/lib/commands/common/thor/assembly_workspace.rb +15 -5
  17. data/lib/commands/common/thor/base_command_helper.rb +1 -1
  18. data/lib/commands/common/thor/clone.rb +1 -1
  19. data/lib/commands/common/thor/common.rb +1 -1
  20. data/lib/commands/common/thor/common_base.rb +1 -1
  21. data/lib/commands/common/thor/create_target.rb +1 -1
  22. data/lib/commands/common/thor/edit.rb +1 -1
  23. data/lib/commands/common/thor/inventory_parser.rb +1 -1
  24. data/lib/commands/common/thor/list_diffs.rb +111 -111
  25. data/lib/commands/common/thor/module/import.rb +1 -1
  26. data/lib/commands/common/thor/module.rb +18 -5
  27. data/lib/commands/common/thor/node.rb +1 -1
  28. data/lib/commands/common/thor/poller.rb +1 -1
  29. data/lib/commands/common/thor/pull_clone_changes.rb +1 -1
  30. data/lib/commands/common/thor/pull_from_remote.rb +1 -1
  31. data/lib/commands/common/thor/puppet_forge.rb +1 -1
  32. data/lib/commands/common/thor/purge_clone.rb +1 -1
  33. data/lib/commands/common/thor/push_clone_changes.rb +1 -1
  34. data/lib/commands/common/thor/push_to_remote.rb +1 -1
  35. data/lib/commands/common/thor/remotes.rb +1 -1
  36. data/lib/commands/common/thor/reparse.rb +1 -1
  37. data/lib/commands/common/thor/set_required_attributes.rb +1 -1
  38. data/lib/commands/thor/account.rb +1 -1
  39. data/lib/commands/thor/assembly.rb +1 -1
  40. data/lib/commands/thor/attribute.rb +1 -1
  41. data/lib/commands/thor/component.rb +1 -1
  42. data/lib/commands/thor/component_module.rb +1 -1
  43. data/lib/commands/thor/component_template.rb +1 -1
  44. data/lib/commands/thor/dependency.rb +1 -1
  45. data/lib/commands/thor/developer.rb +127 -127
  46. data/lib/commands/thor/dtk.rb +1 -1
  47. data/lib/commands/thor/library.rb +1 -1
  48. data/lib/commands/thor/node.rb +1 -1
  49. data/lib/commands/thor/node_group.rb +1 -1
  50. data/lib/commands/thor/node_template.rb +1 -1
  51. data/lib/commands/thor/project.rb +17 -17
  52. data/lib/commands/thor/provider.rb +7 -5
  53. data/lib/commands/thor/remotes.rb +1 -1
  54. data/lib/commands/thor/service.rb +18 -3
  55. data/lib/commands/thor/service_module.rb +1 -1
  56. data/lib/commands/thor/target.rb +233 -231
  57. data/lib/commands/thor/task.rb +1 -1
  58. data/lib/commands/thor/test_module.rb +1 -1
  59. data/lib/commands/thor/workspace.rb +22 -3
  60. data/lib/commands.rb +40 -40
  61. data/lib/config/configuration.rb +1 -1
  62. data/lib/config/disk_cacher.rb +1 -1
  63. data/lib/configurator.rb +1 -1
  64. data/lib/context_router.rb +1 -1
  65. data/lib/core.rb +1 -1
  66. data/lib/domain/git_adapter.rb +395 -395
  67. data/lib/domain/git_error_handler.rb +47 -47
  68. data/lib/domain/response/error_handler.rb +13 -4
  69. data/lib/domain/response.rb +1 -1
  70. data/lib/dtk-client/version.rb +3 -3
  71. data/lib/dtk_client.rb +1 -1
  72. data/lib/dtk_constants.rb +1 -1
  73. data/lib/dtk_error.rb +1 -1
  74. data/lib/dtk_logger.rb +96 -96
  75. data/lib/error.rb +1 -1
  76. data/lib/execute/cli_pure/cli_rerouter.rb +1 -1
  77. data/lib/execute/command/api_call/map.rb +1 -1
  78. data/lib/execute/command/api_call/service.rb +1 -1
  79. data/lib/execute/command/api_call/translation_term.rb +1 -1
  80. data/lib/execute/command/api_call.rb +1 -1
  81. data/lib/execute/command/rest_call.rb +1 -1
  82. data/lib/execute/command.rb +1 -1
  83. data/lib/execute/command_processor/rest_call.rb +1 -1
  84. data/lib/execute/command_processor.rb +1 -1
  85. data/lib/execute/execute_context/result_store.rb +1 -1
  86. data/lib/execute/execute_context.rb +1 -1
  87. data/lib/execute/script/add_tenant.rb +1 -1
  88. data/lib/execute/script.rb +1 -1
  89. data/lib/execute.rb +1 -1
  90. data/lib/parser/adapters/option_parser.rb +1 -1
  91. data/lib/parser/adapters/thor/common_option_defs.rb +1 -1
  92. data/lib/parser/adapters/thor.rb +1 -1
  93. data/lib/require_first.rb +87 -87
  94. data/lib/search_hash.rb +1 -1
  95. data/lib/shell/context.rb +1 -1
  96. data/lib/shell/context_aux.rb +1 -1
  97. data/lib/shell/domain/active_context.rb +1 -1
  98. data/lib/shell/domain/context_entity.rb +1 -1
  99. data/lib/shell/domain/context_params.rb +1 -1
  100. data/lib/shell/domain/override_tasks.rb +1 -1
  101. data/lib/shell/domain/shadow_entity.rb +1 -1
  102. data/lib/shell/header_shell.rb +1 -1
  103. data/lib/shell/help_monkey_patch.rb +1 -1
  104. data/lib/shell/interactive_wizard.rb +1 -1
  105. data/lib/shell/message_queue.rb +1 -1
  106. data/lib/shell/parse_monkey_patch.rb +1 -1
  107. data/lib/shell/status_monitor.rb +107 -107
  108. data/lib/shell.rb +1 -1
  109. data/lib/task_status/refresh_mode.rb +1 -1
  110. data/lib/task_status/snapshot_mode.rb +1 -1
  111. data/lib/task_status/stream_mode/element/format.rb +1 -1
  112. data/lib/task_status/stream_mode/element/hierarchical_task/result/action.rb +1 -1
  113. data/lib/task_status/stream_mode/element/hierarchical_task/result.rb +1 -1
  114. data/lib/task_status/stream_mode/element/hierarchical_task/steps/action.rb +1 -1
  115. data/lib/task_status/stream_mode/element/hierarchical_task/steps/components.rb +1 -1
  116. data/lib/task_status/stream_mode/element/hierarchical_task/steps/node_level.rb +1 -1
  117. data/lib/task_status/stream_mode/element/hierarchical_task/steps.rb +1 -1
  118. data/lib/task_status/stream_mode/element/hierarchical_task.rb +1 -1
  119. data/lib/task_status/stream_mode/element/render.rb +1 -1
  120. data/lib/task_status/stream_mode/element/stage/render.rb +1 -1
  121. data/lib/task_status/stream_mode/element/stage.rb +1 -1
  122. data/lib/task_status/stream_mode/element/task_end.rb +1 -1
  123. data/lib/task_status/stream_mode/element/task_start.rb +1 -1
  124. data/lib/task_status/stream_mode/element.rb +1 -1
  125. data/lib/task_status/stream_mode.rb +1 -1
  126. data/lib/task_status.rb +1 -1
  127. data/lib/util/common_util.rb +1 -1
  128. data/lib/util/console.rb +1 -1
  129. data/lib/util/dtk_puppet.rb +1 -1
  130. data/lib/util/module_util.rb +1 -1
  131. data/lib/util/os_util.rb +6 -2
  132. data/lib/util/permission_util.rb +1 -1
  133. data/lib/util/remote_dependency_util.rb +1 -1
  134. data/lib/util/ssh_util.rb +77 -77
  135. data/lib/view_processor/augmented_simple_list.rb +1 -1
  136. data/lib/view_processor/hash_pretty_print.rb +1 -1
  137. data/lib/view_processor/simple_list.rb +1 -1
  138. data/lib/view_processor/table_print.rb +1 -1
  139. data/lib/view_processor.rb +1 -1
  140. data/spec/lib/spec_helper.rb +1 -1
  141. data/spec/lib/spec_thor.rb +1 -1
  142. data/spec/node_template_spec.rb +1 -1
  143. data/spec/table_print_spec.rb +1 -1
  144. data/spec/target_spec.rb +1 -1
  145. data/spec/task_spec.rb +1 -1
  146. metadata +20 -20
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8bab62a8bff9a56a5888fb17f4128a69891786d0
4
- data.tar.gz: 1ead8b18d171036edbf6f0633f4da99355b00f07
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZGY4MjY3MzI0Mzg2MzVlYWQ5YmE0N2YzZjU1NjNiODA5NzU1MTU5Yw==
5
+ data.tar.gz: !binary |-
6
+ ZThiYjk4YThmM2I4OTg2YTRlNzZhNTVlNjkxNWJlY2Q2YjI3Y2YwMQ==
5
7
  SHA512:
6
- metadata.gz: 11804a4fc9c39c49616b048eaa7a8229b7f0e7a0abeae8a49e9cbaab2bec8e618befe267533ba671473f1c38116381e31a3a00056a2e67945be41034bf0bb456
7
- data.tar.gz: 796071c75b5dce8c4377d849f8a955ae2ca5b8a4c67958f604c52edafe4201b9b3f3257f01a53aa68c3e256aba425f0eff86cb845cc64f35e2321ab3e62f2542
8
+ metadata.gz: !binary |-
9
+ YjU0OGY2NjhkZmRiMGI1NmM1OTVlNTFmZjkxYjVkNGNlZjMyZjE1MDZlYThm
10
+ ZjQyMDQzNjZjN2QzMzYwMGFiNGY3MjQ3NjBkMzQxNTQ2NTA0ZDFmNWZlNGZh
11
+ MmU1YmUwNzI1MzNmN2RhNDdmYjM1ZWY3MTdjNWY1ZDI1MmE3NjM=
12
+ data.tar.gz: !binary |-
13
+ ZGQyZDhjOWQ3Njc3ZmM5YmQ3OWJjYTcyNzA5YTRlZTM2ZTU5NTA1ZDU3MmZm
14
+ NjNmYWVmODFkMTY5NGMwMjM4ODI3ZGQ2YWE5MGI1YzUxNTE1ZGQxMWRlNWNl
15
+ YzRjZTRjNzFlYmQ1ZTE0NzYyOTBiY2Q4ODU3ZmNhOWM2YjdkODU=
data/dtk-client.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |gem|
7
7
  gem.description = %q{The DTK Client is a command line tool to interact with your DTK Server and DTK Service Catalog instance(s).}
8
8
  gem.summary = %q{DTK CLI client for DTK server interaction.}
9
9
  gem.homepage = "https://github.com/rich-reactor8/dtk-client"
10
- gem.licenses = ["GPL-3.0"]
10
+ gem.licenses = ["Apache-2.0"]
11
11
 
12
12
  gem.files = %w(README.md Gemfile Gemfile_dev dtk-client.gemspec)
13
13
  gem.files += Dir.glob("bin/**/*")
@@ -29,7 +29,7 @@ Gem::Specification.new do |gem|
29
29
  gem.add_dependency 'hirb','~> 0.7.0'
30
30
  gem.add_dependency 'thor','~> 0.15.4'
31
31
  gem.add_dependency 'erubis','~> 2.7.0'
32
- gem.add_dependency 'dtk-common-core','0.8.0'
32
+ gem.add_dependency 'dtk-common-core','0.9.0'
33
33
  gem.add_dependency 'git','1.2.9'
34
34
  gem.add_dependency 'colorize','~> 0.5.8'
35
35
  gem.add_dependency 'highline', '1.6.16'
data/lib/auxiliary.rb CHANGED
@@ -58,4 +58,4 @@ module DTK
58
58
  end
59
59
  end
60
60
  end
61
- end
61
+ end
data/lib/client.rb CHANGED
@@ -55,4 +55,4 @@ begin
55
55
  rescue SystemExit, Interrupt
56
56
  #puts "DTK Client action canceled."
57
57
  exit(1)
58
- end
58
+ end
@@ -30,4 +30,4 @@ module DTK; module Client
30
30
  #TODO: make all commands helpers a subclass of this
31
31
  class CommandHelper
32
32
  end
33
- end; end
33
+ end; end
@@ -150,4 +150,4 @@ module DTK; module Client; class CommandHelper
150
150
 
151
151
  end
152
152
  end
153
- end; end; end
153
+ end; end; end
@@ -586,4 +586,4 @@ module DTK; module Client; class CommandHelper
586
586
  repo.repo_dir.gsub(Regexp.new("/$"),"").split("/").last
587
587
  end
588
588
  end; end
589
- end; end; end
589
+ end; end; end
@@ -285,4 +285,4 @@ end
285
285
  eos
286
286
 
287
287
  end
288
- end
288
+ end
@@ -103,4 +103,4 @@ module DTK; module Client
103
103
  end
104
104
  end
105
105
  end
106
- end; end
106
+ end; end
@@ -107,7 +107,10 @@ module DTK::Client
107
107
  version = r_module['version']
108
108
  full_name = (version && !version.eql?('master')) ? "#{module_name}(#{version})" : module_name
109
109
 
110
- print "Using #{module_type.gsub('_', ' ')} '#{full_name}'\n" unless hide_output
110
+ unless hide_output
111
+ print "Using #{module_type.gsub('_', ' ')} '#{full_name}'\n" unless update_all
112
+ end
113
+
111
114
  next if update_none || opts[:update_none]
112
115
 
113
116
  pull_opts = {:force => true, :do_not_raise => true}
@@ -203,6 +206,7 @@ module DTK::Client
203
206
  thor_options["skip_edit"] = true
204
207
  thor_options["omit_output"] = true
205
208
  thor_options.merge!(:module_type => 'component-module')
209
+ thor_options.merge!(:service_importer => true)
206
210
  new_context_params = ::DTK::Shell::ContextParams.new
207
211
  new_context_params.forward_options(thor_options)
208
212
  new_context_params.add_context_to_params(formated_name, :"component-module", m['id'])
@@ -244,4 +248,4 @@ module DTK::Client
244
248
  end
245
249
 
246
250
  end
247
- end
251
+ end
@@ -30,4 +30,4 @@ module DTK; module Client; class CommandHelper
30
30
  end
31
31
 
32
32
  end; end
33
- end; end; end
33
+ end; end; end
@@ -66,4 +66,4 @@ module DTK::Client
66
66
  end
67
67
  end
68
68
  end
69
- end
69
+ end
@@ -130,4 +130,4 @@ module DTK::Client
130
130
  end
131
131
 
132
132
  end
133
- end
133
+ end
@@ -15,60 +15,60 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
- module DTK
19
- module Client
20
- module ActionResultHandler
21
-
22
- def print_action_results(action_results_id, number_of_retries=8)
23
- response = action_results(action_results_id, number_of_retries)
24
-
25
- if response.ok? && response.data['results']
26
- response.data['results'].each do |k,v|
27
- if v['error']
28
- OsUtil.print("#{v['error']} (#{k})", :red)
29
- else
30
- OsUtil.print("#{v['message']} (#{k})", :yellow)
31
- end
32
- end
33
- else
34
- OsUtil.print("Not able to process given request, we apologise for inconvenience", :red)
35
- end
36
-
37
- nil
38
- end
39
-
40
- def print_simple_results(action_results_id, number_of_retries=8)
41
- response = action_results(action_results_id, number_of_retries)
42
- pp response
43
- end
44
-
45
- def action_results(action_results_id, number_of_retries=8)
46
- action_body = {
47
- :action_results_id => action_results_id,
48
- :return_only_if_complete => true,
49
- :disable_post_processing => true
50
- }
51
- response = nil
52
-
53
- number_of_retries.times do
54
- response = post(rest_url("assembly/get_action_results"),action_body)
55
-
56
- # server has found an error
57
- unless response.data(:results).nil?
58
- if response.data(:results)['error']
59
- raise DTK::Client::DtkError, response.data(:results)['error']
60
- end
61
- end
62
-
63
- break if response.data(:is_complete)
64
-
65
- sleep(1.5)
66
- end
67
-
68
- response
69
-
70
- end
71
-
72
- end
73
- end
74
- end
18
+ module DTK
19
+ module Client
20
+ module ActionResultHandler
21
+
22
+ def print_action_results(action_results_id, number_of_retries=8)
23
+ response = action_results(action_results_id, number_of_retries)
24
+
25
+ if response.ok? && response.data['results']
26
+ response.data['results'].each do |k,v|
27
+ if v['error']
28
+ OsUtil.print("#{v['error']} (#{k})", :red)
29
+ else
30
+ OsUtil.print("#{v['message']} (#{k})", :yellow)
31
+ end
32
+ end
33
+ else
34
+ OsUtil.print("Not able to process given request, we apologise for inconvenience", :red)
35
+ end
36
+
37
+ nil
38
+ end
39
+
40
+ def print_simple_results(action_results_id, number_of_retries=8)
41
+ response = action_results(action_results_id, number_of_retries)
42
+ pp response
43
+ end
44
+
45
+ def action_results(action_results_id, number_of_retries=8)
46
+ action_body = {
47
+ :action_results_id => action_results_id,
48
+ :return_only_if_complete => true,
49
+ :disable_post_processing => true
50
+ }
51
+ response = nil
52
+
53
+ number_of_retries.times do
54
+ response = post(rest_url("assembly/get_action_results"),action_body)
55
+
56
+ # server has found an error
57
+ unless response.data(:results).nil?
58
+ if response.data(:results)['error']
59
+ raise DTK::Client::DtkError, response.data(:results)['error']
60
+ end
61
+ end
62
+
63
+ break if response.data(:is_complete)
64
+
65
+ sleep(1.5)
66
+ end
67
+
68
+ response
69
+
70
+ end
71
+
72
+ end
73
+ end
74
+ end
@@ -89,4 +89,4 @@ module DTK::Client
89
89
  end
90
90
  end
91
91
  end
92
- end
92
+ end
@@ -826,10 +826,12 @@ module DTK::Client
826
826
  return response unless response.ok?
827
827
 
828
828
  if r_data = response.data
829
- if r_data.is_a?(Hash) && (ambiguous = r_data['ambiguous'])
830
- unless ambiguous.empty?
831
- msg = "It is ambiguous whether '#{ambiguous.join(', ')}' #{ambiguous.size == 1 ? 'is' : 'are'} node or component attribute(s). Run set-attribute again with one of options -c [--component-attribute] or -n [--node-attribute]."
832
- raise DtkError, msg
829
+ if r_data.is_a?(Hash)
830
+ if ambiguous = r_data['ambiguous']
831
+ unless ambiguous.empty?
832
+ msg = "It is ambiguous whether '#{ambiguous.join(', ')}' #{ambiguous.size == 1 ? 'is' : 'are'} node or component attribute(s). Run set-attribute again with one of options -c [--component-attribute] or -n [--node-attribute]."
833
+ raise DtkError, msg
834
+ end
833
835
  end
834
836
  end
835
837
  end
@@ -898,6 +900,14 @@ module DTK::Client
898
900
 
899
901
  def create_node_group_aux(context_params)
900
902
  assembly_or_workspace_id, node_group_name, node_template_identifier = context_params.retrieve_arguments([[:service_id, :workspace_id!],:option_1!,:option_2!],method_argument_names)
903
+ cardinality = options.cardinality
904
+
905
+ # default value for cardinality is 1 (if user does not specify otherwise)
906
+ # invalid values for cardinality are 0 and any string
907
+ if cardinality.eql?('0') || !cardinality.to_s.match(/^[0-9]+$/)
908
+ fail DtkError.new("Invalid cardinality value '#{cardinality}'!")
909
+ end
910
+
901
911
  post_body = {
902
912
  :assembly_id => assembly_or_workspace_id,
903
913
  :cardinality => options.cardinality,
@@ -1570,4 +1580,4 @@ module DTK::Client
1570
1580
  response = ContextRouter.routeTask(:service_module, "stage", new_context_params, @conn)
1571
1581
  end
1572
1582
  end
1573
- end
1583
+ end
@@ -56,4 +56,4 @@ module DTK::Client
56
56
  end
57
57
 
58
58
  end
59
- end
59
+ end
@@ -79,4 +79,4 @@ module DTK::Client
79
79
  return context_params_for_module
80
80
  end
81
81
  end
82
- end
82
+ end
@@ -85,4 +85,4 @@ module DTK::Client
85
85
  end
86
86
 
87
87
  end
88
- end
88
+ end
@@ -46,4 +46,4 @@ module DTK::Client
46
46
  end
47
47
  end
48
48
  end
49
- end
49
+ end
@@ -67,4 +67,4 @@ module DTK; module Client; module Commands::Common
67
67
  end
68
68
 
69
69
  end
70
- end; end; end
70
+ end; end; end
@@ -252,4 +252,4 @@ end
252
252
  raise DtkValidationError, "Unsupported format type '#{format.to_s}'!"
253
253
  end
254
254
  end
255
- =end
255
+ =end
@@ -95,4 +95,4 @@ module DTK::Client
95
95
  ValidOsTypes = ['ubuntu', 'centos', 'redhat', 'debian']
96
96
 
97
97
  end
98
- end
98
+ end
@@ -15,114 +15,114 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
- module DTK::Client
19
- module ListDiffsMixin
20
- def list_diffs_aux(module_type,module_id,remote,version=nil)
21
- id_field = "#{module_type}_id"
22
- path_to_key = SSHUtil.default_rsa_pub_key_path()
23
- rsa_pub_key = File.file?(path_to_key) && File.open(path_to_key){|f|f.read}.chomp
24
-
25
- post_body = {
26
- id_field => module_id,
27
- :access_rights => "r",
28
- :action => "pull"
29
- }
30
- post_body.merge!(:version => version) if version
31
- post_body.merge!(:rsa_pub_key => rsa_pub_key) if rsa_pub_key
32
-
33
- response = post(rest_url("#{module_type}/get_remote_module_info"),post_body)
34
- return response unless response.ok?
35
-
36
- module_name = response.data(:full_module_name)
37
-
38
- opts = {
39
- :remote_repo_url => response.data(:remote_repo_url),
40
- :remote_repo => response.data(:remote_repo),
41
- :remote_branch => response.data(:remote_branch),
42
- :local_branch => response.data(:workspace_branch)
43
- }
44
- version = response.data(:version)
45
-
46
- # response = Helper(:git_repo).get_diffs(module_type,module_name,version,opts)
47
- response = Helper(:git_repo).get_remote_diffs(module_type,module_name,version,opts)
48
- return response unless response.ok?
49
-
50
- added, deleted, modified = print_diffs(response.data(:status), remote)
51
- diffs = response.data(:diffs)
52
-
53
- raise DTK::Client::DtkValidationError, "There are no changes in current workspace!" if(added.empty? && deleted.empty? && modified.empty? && diffs.empty?)
54
- puts "#{diffs}" unless (diffs||"").empty?
55
-
56
- unless added.empty?
57
- puts "\nNew file(s):"
58
- added.each do |a|
59
- puts "\t #{a.inspect}"
60
- end
61
- end
62
-
63
- unless deleted.empty?
64
- puts "\nDeleted file(s):"
65
- deleted.each do |d|
66
- puts "\t #{d.inspect}"
67
- end
68
- end
69
- end
70
-
71
- def list_remote_diffs_aux(module_type, module_id)
72
- id_field = "#{module_type}_id"
73
-
74
- post_body = {
75
- id_field => module_id
76
- }
77
-
78
- response = post(rest_url("#{module_type}/list_remote_diffs"),post_body)
79
- return response unless response.ok?
80
-
81
- raise DTK::Client::DtkValidationError, "There are no diffs between module on server and remote repo!" if response.data.empty?
82
- response
83
- end
84
-
85
- def list_component_module_diffs(module_id, assembly_name, workspace_branch, commit_sha, module_branch_id, repo_id)
86
- post_body = {
87
- :module_id => module_id,
88
- :assembly_name => assembly_name,
89
- :workspace_branch => workspace_branch,
90
- :module_branch_id => module_branch_id,
91
- :repo_id => repo_id
92
- }
93
-
94
- response = post(rest_url("assembly/list_component_module_diffs"),post_body)
95
- return response unless response.ok?
96
-
97
- raise DTK::Client::DtkValidationError, "There are no diffs between module in service instance and base module!" if response.data.empty?
98
- response
99
- end
100
-
101
- def print_diffs(response, remote)
102
- added = []
103
- deleted = []
104
- modified = []
105
-
106
- unless response[:files_modified].nil?
107
- response[:files_modified].each do |file|
108
- modified << file[:path]
109
- end
110
- end
111
-
112
- unless response[:files_deleted].nil?
113
- response[:files_deleted].each do |file|
114
- deleted << file[:path]
115
- end
116
- end
117
-
118
- unless response[:files_added].nil?
119
- response[:files_added].each do |file|
120
- added << file[:path]
121
- end
122
- end
123
-
124
- return added, deleted, modified
125
- end
126
-
127
- end
128
- end
18
+ module DTK::Client
19
+ module ListDiffsMixin
20
+ def list_diffs_aux(module_type,module_id,remote,version=nil)
21
+ id_field = "#{module_type}_id"
22
+ path_to_key = SSHUtil.default_rsa_pub_key_path()
23
+ rsa_pub_key = File.file?(path_to_key) && File.open(path_to_key){|f|f.read}.chomp
24
+
25
+ post_body = {
26
+ id_field => module_id,
27
+ :access_rights => "r",
28
+ :action => "pull"
29
+ }
30
+ post_body.merge!(:version => version) if version
31
+ post_body.merge!(:rsa_pub_key => rsa_pub_key) if rsa_pub_key
32
+
33
+ response = post(rest_url("#{module_type}/get_remote_module_info"),post_body)
34
+ return response unless response.ok?
35
+
36
+ module_name = response.data(:full_module_name)
37
+
38
+ opts = {
39
+ :remote_repo_url => response.data(:remote_repo_url),
40
+ :remote_repo => response.data(:remote_repo),
41
+ :remote_branch => response.data(:remote_branch),
42
+ :local_branch => response.data(:workspace_branch)
43
+ }
44
+ version = response.data(:version)
45
+
46
+ # response = Helper(:git_repo).get_diffs(module_type,module_name,version,opts)
47
+ response = Helper(:git_repo).get_remote_diffs(module_type,module_name,version,opts)
48
+ return response unless response.ok?
49
+
50
+ added, deleted, modified = print_diffs(response.data(:status), remote)
51
+ diffs = response.data(:diffs)
52
+
53
+ raise DTK::Client::DtkValidationError, "There are no changes in current workspace!" if(added.empty? && deleted.empty? && modified.empty? && diffs.empty?)
54
+ puts "#{diffs}" unless (diffs||"").empty?
55
+
56
+ unless added.empty?
57
+ puts "\nNew file(s):"
58
+ added.each do |a|
59
+ puts "\t #{a.inspect}"
60
+ end
61
+ end
62
+
63
+ unless deleted.empty?
64
+ puts "\nDeleted file(s):"
65
+ deleted.each do |d|
66
+ puts "\t #{d.inspect}"
67
+ end
68
+ end
69
+ end
70
+
71
+ def list_remote_diffs_aux(module_type, module_id)
72
+ id_field = "#{module_type}_id"
73
+
74
+ post_body = {
75
+ id_field => module_id
76
+ }
77
+
78
+ response = post(rest_url("#{module_type}/list_remote_diffs"),post_body)
79
+ return response unless response.ok?
80
+
81
+ raise DTK::Client::DtkValidationError, "There are no diffs between module on server and remote repo!" if response.data.empty?
82
+ response
83
+ end
84
+
85
+ def list_component_module_diffs(module_id, assembly_name, workspace_branch, commit_sha, module_branch_id, repo_id)
86
+ post_body = {
87
+ :module_id => module_id,
88
+ :assembly_name => assembly_name,
89
+ :workspace_branch => workspace_branch,
90
+ :module_branch_id => module_branch_id,
91
+ :repo_id => repo_id
92
+ }
93
+
94
+ response = post(rest_url("assembly/list_component_module_diffs"),post_body)
95
+ return response unless response.ok?
96
+
97
+ raise DTK::Client::DtkValidationError, "There are no diffs between module in service instance and base module!" if response.data.empty?
98
+ response
99
+ end
100
+
101
+ def print_diffs(response, remote)
102
+ added = []
103
+ deleted = []
104
+ modified = []
105
+
106
+ unless response[:files_modified].nil?
107
+ response[:files_modified].each do |file|
108
+ modified << file[:path]
109
+ end
110
+ end
111
+
112
+ unless response[:files_deleted].nil?
113
+ response[:files_deleted].each do |file|
114
+ deleted << file[:path]
115
+ end
116
+ end
117
+
118
+ unless response[:files_added].nil?
119
+ response[:files_added].each do |file|
120
+ added << file[:path]
121
+ end
122
+ end
123
+
124
+ return added, deleted, modified
125
+ end
126
+
127
+ end
128
+ end
@@ -212,4 +212,4 @@ module DTK::Client
212
212
 
213
213
  end
214
214
  end
215
- end
215
+ end
@@ -384,9 +384,9 @@ module DTK::Client
384
384
  master_response = post rest_url("#{module_type}/prepare_for_install_module"), post_body
385
385
  return master_response unless master_response.ok?
386
386
 
387
- head_installed = master_response.data(:head_installed)
388
- latest_version = master_response.data(:latest_version)
389
- remote_module_name = context_params.retrieve_arguments([:option_1!], method_argument_names)
387
+ head_installed = master_response.data(:head_installed)
388
+ latest_version = master_response.data(:latest_version)
389
+ remote_module_name, param_version = context_params.retrieve_arguments([:option_1!, :option_2], method_argument_names)
390
390
 
391
391
  if version
392
392
  versions = master_response.data(:versions)
@@ -640,7 +640,20 @@ module DTK::Client
640
640
  module_name = context_params.retrieve_arguments(["#{module_type}_name".to_sym],method_argument_names)
641
641
  version = thor_options["version"]||options.version
642
642
  internal_trigger = true if thor_options['skip_edit']
643
- clone_aux(module_type.to_sym, module_id, version, internal_trigger, thor_options['omit_output'], :use_latest => true)
643
+ response = clone_aux(module_type.to_sym, module_id, version, internal_trigger, thor_options['omit_output'], :use_latest => true)
644
+
645
+ # if error message 'directory exist on client ...' returned print it here
646
+ # with forward_options[:service_importer] we know it is triggered from auto-importing dependencies so don't want to print
647
+ if !response.ok? && response.is_a?(Response::Error::Usage) && !forward_options[:service_importer]
648
+ if errors = response['errors']
649
+ if error_msg = errors.first['message']
650
+ OsUtil.print(errors.first['message'], :red)
651
+ return
652
+ end
653
+ end
654
+ end
655
+
656
+ response
644
657
  end
645
658
 
646
659
  def edit_module_aux(context_params)
@@ -995,4 +1008,4 @@ module DTK::Client
995
1008
  end
996
1009
 
997
1010
  end
998
- end
1011
+ end
@@ -50,4 +50,4 @@ module DTK::Client
50
50
  'amazon-linux' => 'ec2-user'
51
51
  }
52
52
  end
53
- end
53
+ end
@@ -62,4 +62,4 @@ module DTK::Client
62
62
  end
63
63
  end
64
64
  end
65
- end
65
+ end
@@ -25,4 +25,4 @@ module DTK::Client
25
25
  Helper(:git_repo).pull_changes(module_type,module_name,opts_pull)
26
26
  end
27
27
  end
28
- end
28
+ end
@@ -149,4 +149,4 @@ module DTK::Client
149
149
 
150
150
  end
151
151
  end
152
- end
152
+ end