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.
- checksums.yaml +13 -5
- data/dtk-client.gemspec +2 -2
- data/lib/auxiliary.rb +1 -1
- data/lib/client.rb +1 -1
- data/lib/command_helper.rb +1 -1
- data/lib/command_helpers/git_repo/merge.rb +1 -1
- data/lib/command_helpers/git_repo.rb +1 -1
- data/lib/command_helpers/jenkins_client/config_xml.rb +1 -1
- data/lib/command_helpers/jenkins_client.rb +1 -1
- data/lib/command_helpers/service_importer.rb +6 -2
- data/lib/command_helpers/service_link.rb +1 -1
- data/lib/command_helpers/test_module_creator.rb +1 -1
- data/lib/commands/common/thor/access_control.rb +1 -1
- data/lib/commands/common/thor/action_result_handler.rb +57 -57
- data/lib/commands/common/thor/assembly_template.rb +1 -1
- data/lib/commands/common/thor/assembly_workspace.rb +15 -5
- data/lib/commands/common/thor/base_command_helper.rb +1 -1
- data/lib/commands/common/thor/clone.rb +1 -1
- data/lib/commands/common/thor/common.rb +1 -1
- data/lib/commands/common/thor/common_base.rb +1 -1
- data/lib/commands/common/thor/create_target.rb +1 -1
- data/lib/commands/common/thor/edit.rb +1 -1
- data/lib/commands/common/thor/inventory_parser.rb +1 -1
- data/lib/commands/common/thor/list_diffs.rb +111 -111
- data/lib/commands/common/thor/module/import.rb +1 -1
- data/lib/commands/common/thor/module.rb +18 -5
- data/lib/commands/common/thor/node.rb +1 -1
- data/lib/commands/common/thor/poller.rb +1 -1
- data/lib/commands/common/thor/pull_clone_changes.rb +1 -1
- data/lib/commands/common/thor/pull_from_remote.rb +1 -1
- data/lib/commands/common/thor/puppet_forge.rb +1 -1
- data/lib/commands/common/thor/purge_clone.rb +1 -1
- data/lib/commands/common/thor/push_clone_changes.rb +1 -1
- data/lib/commands/common/thor/push_to_remote.rb +1 -1
- data/lib/commands/common/thor/remotes.rb +1 -1
- data/lib/commands/common/thor/reparse.rb +1 -1
- data/lib/commands/common/thor/set_required_attributes.rb +1 -1
- data/lib/commands/thor/account.rb +1 -1
- data/lib/commands/thor/assembly.rb +1 -1
- data/lib/commands/thor/attribute.rb +1 -1
- data/lib/commands/thor/component.rb +1 -1
- data/lib/commands/thor/component_module.rb +1 -1
- data/lib/commands/thor/component_template.rb +1 -1
- data/lib/commands/thor/dependency.rb +1 -1
- data/lib/commands/thor/developer.rb +127 -127
- data/lib/commands/thor/dtk.rb +1 -1
- data/lib/commands/thor/library.rb +1 -1
- data/lib/commands/thor/node.rb +1 -1
- data/lib/commands/thor/node_group.rb +1 -1
- data/lib/commands/thor/node_template.rb +1 -1
- data/lib/commands/thor/project.rb +17 -17
- data/lib/commands/thor/provider.rb +7 -5
- data/lib/commands/thor/remotes.rb +1 -1
- data/lib/commands/thor/service.rb +18 -3
- data/lib/commands/thor/service_module.rb +1 -1
- data/lib/commands/thor/target.rb +233 -231
- data/lib/commands/thor/task.rb +1 -1
- data/lib/commands/thor/test_module.rb +1 -1
- data/lib/commands/thor/workspace.rb +22 -3
- data/lib/commands.rb +40 -40
- data/lib/config/configuration.rb +1 -1
- data/lib/config/disk_cacher.rb +1 -1
- data/lib/configurator.rb +1 -1
- data/lib/context_router.rb +1 -1
- data/lib/core.rb +1 -1
- data/lib/domain/git_adapter.rb +395 -395
- data/lib/domain/git_error_handler.rb +47 -47
- data/lib/domain/response/error_handler.rb +13 -4
- data/lib/domain/response.rb +1 -1
- data/lib/dtk-client/version.rb +3 -3
- data/lib/dtk_client.rb +1 -1
- data/lib/dtk_constants.rb +1 -1
- data/lib/dtk_error.rb +1 -1
- data/lib/dtk_logger.rb +96 -96
- data/lib/error.rb +1 -1
- data/lib/execute/cli_pure/cli_rerouter.rb +1 -1
- data/lib/execute/command/api_call/map.rb +1 -1
- data/lib/execute/command/api_call/service.rb +1 -1
- data/lib/execute/command/api_call/translation_term.rb +1 -1
- data/lib/execute/command/api_call.rb +1 -1
- data/lib/execute/command/rest_call.rb +1 -1
- data/lib/execute/command.rb +1 -1
- data/lib/execute/command_processor/rest_call.rb +1 -1
- data/lib/execute/command_processor.rb +1 -1
- data/lib/execute/execute_context/result_store.rb +1 -1
- data/lib/execute/execute_context.rb +1 -1
- data/lib/execute/script/add_tenant.rb +1 -1
- data/lib/execute/script.rb +1 -1
- data/lib/execute.rb +1 -1
- data/lib/parser/adapters/option_parser.rb +1 -1
- data/lib/parser/adapters/thor/common_option_defs.rb +1 -1
- data/lib/parser/adapters/thor.rb +1 -1
- data/lib/require_first.rb +87 -87
- data/lib/search_hash.rb +1 -1
- data/lib/shell/context.rb +1 -1
- data/lib/shell/context_aux.rb +1 -1
- data/lib/shell/domain/active_context.rb +1 -1
- data/lib/shell/domain/context_entity.rb +1 -1
- data/lib/shell/domain/context_params.rb +1 -1
- data/lib/shell/domain/override_tasks.rb +1 -1
- data/lib/shell/domain/shadow_entity.rb +1 -1
- data/lib/shell/header_shell.rb +1 -1
- data/lib/shell/help_monkey_patch.rb +1 -1
- data/lib/shell/interactive_wizard.rb +1 -1
- data/lib/shell/message_queue.rb +1 -1
- data/lib/shell/parse_monkey_patch.rb +1 -1
- data/lib/shell/status_monitor.rb +107 -107
- data/lib/shell.rb +1 -1
- data/lib/task_status/refresh_mode.rb +1 -1
- data/lib/task_status/snapshot_mode.rb +1 -1
- data/lib/task_status/stream_mode/element/format.rb +1 -1
- data/lib/task_status/stream_mode/element/hierarchical_task/result/action.rb +1 -1
- data/lib/task_status/stream_mode/element/hierarchical_task/result.rb +1 -1
- data/lib/task_status/stream_mode/element/hierarchical_task/steps/action.rb +1 -1
- data/lib/task_status/stream_mode/element/hierarchical_task/steps/components.rb +1 -1
- data/lib/task_status/stream_mode/element/hierarchical_task/steps/node_level.rb +1 -1
- data/lib/task_status/stream_mode/element/hierarchical_task/steps.rb +1 -1
- data/lib/task_status/stream_mode/element/hierarchical_task.rb +1 -1
- data/lib/task_status/stream_mode/element/render.rb +1 -1
- data/lib/task_status/stream_mode/element/stage/render.rb +1 -1
- data/lib/task_status/stream_mode/element/stage.rb +1 -1
- data/lib/task_status/stream_mode/element/task_end.rb +1 -1
- data/lib/task_status/stream_mode/element/task_start.rb +1 -1
- data/lib/task_status/stream_mode/element.rb +1 -1
- data/lib/task_status/stream_mode.rb +1 -1
- data/lib/task_status.rb +1 -1
- data/lib/util/common_util.rb +1 -1
- data/lib/util/console.rb +1 -1
- data/lib/util/dtk_puppet.rb +1 -1
- data/lib/util/module_util.rb +1 -1
- data/lib/util/os_util.rb +6 -2
- data/lib/util/permission_util.rb +1 -1
- data/lib/util/remote_dependency_util.rb +1 -1
- data/lib/util/ssh_util.rb +77 -77
- data/lib/view_processor/augmented_simple_list.rb +1 -1
- data/lib/view_processor/hash_pretty_print.rb +1 -1
- data/lib/view_processor/simple_list.rb +1 -1
- data/lib/view_processor/table_print.rb +1 -1
- data/lib/view_processor.rb +1 -1
- data/spec/lib/spec_helper.rb +1 -1
- data/spec/lib/spec_thor.rb +1 -1
- data/spec/node_template_spec.rb +1 -1
- data/spec/table_print_spec.rb +1 -1
- data/spec/target_spec.rb +1 -1
- data/spec/task_spec.rb +1 -1
- metadata +20 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: !binary |-
|
|
4
|
+
ZGY4MjY3MzI0Mzg2MzVlYWQ5YmE0N2YzZjU1NjNiODA5NzU1MTU5Yw==
|
|
5
|
+
data.tar.gz: !binary |-
|
|
6
|
+
ZThiYjk4YThmM2I4OTg2YTRlNzZhNTVlNjkxNWJlY2Q2YjI3Y2YwMQ==
|
|
5
7
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
|
|
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 = ["
|
|
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.
|
|
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
data/lib/client.rb
CHANGED
data/lib/command_helper.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
|
@@ -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
|
|
@@ -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)
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
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
|
|
@@ -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
|
|
@@ -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
|
|
388
|
-
latest_version
|
|
389
|
-
remote_module_name = context_params.retrieve_arguments([:option_1
|
|
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
|