dtk-client 0.6.6 → 0.6.7
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/lib/command_helpers/service_importer.rb +9 -5
- data/lib/commands/common/thor/assembly_workspace.rb +8 -1
- data/lib/commands/common/thor/module.rb +6 -3
- data/lib/commands/common/thor/pull_from_remote.rb +2 -0
- data/lib/commands/thor/account.rb +12 -3
- data/lib/commands/thor/component_module.rb +35 -71
- data/lib/commands/thor/component_template.rb +5 -1
- data/lib/commands/thor/service.rb +3 -2
- data/lib/commands/thor/service_module.rb +1 -1
- data/lib/commands/thor/workspace.rb +3 -2
- data/lib/core.rb +11 -2
- data/lib/dtk-client/version.rb +1 -1
- data/lib/parser/adapters/thor.rb +4 -0
- data/lib/shell/context.rb +32 -12
- data/lib/shell/message_queue.rb +44 -0
- data/lib/util/os_util.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YzJhNmY1YjNmMTQxNzRhMzI0NmZjOGYxYjczM2EwNDc3NjdiYTAxMg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YWZiMDcxNWJkYmEwMzI3NGIyMzMwY2FmZWQ4OTk1NWVmZmUzYWY5ZQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MWZlMTBiYTUwMGIwZjU5MzU0ZjNlNWY0NGVkMjcwOWZlNDk0ODU1YTM5ZWIy
|
10
|
+
NjY2NDQzOTBjMjFjNmQwM2U4YjQwMGFmMjU1OTVmYThiNzQ5MDZiZDg4MjY5
|
11
|
+
OTdkNDUwODBmMGUwZWZkMjA3Yjg4NzU1ZTI2OTdiM2NkOWZmYjg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MzUzOTVmMzhlYzg2MzcwMGVmMWZmY2M2NDg1ODhlNGQ4NWMwNWIzMTJlZTQ4
|
14
|
+
NTNmZWRlZWU4YmI5ZTExMGQwYmE3ZGU4ZDc3NGI3ZDgzMzNmZWQyODZhMThi
|
15
|
+
M2M1Yjg0YmYxNmFjNTkxNDUwNWQ5ZDhjOWZmZGQzZDY5MDAwYTQ=
|
@@ -25,7 +25,7 @@ module DTK::Client
|
|
25
25
|
module_name = full_module_name(r_module)
|
26
26
|
module_type = r_module['type']
|
27
27
|
|
28
|
-
print "Pulling
|
28
|
+
print "Pulling #{module_type.gsub('_',' ')} content for '#{module_name}' ... "
|
29
29
|
|
30
30
|
new_context_params = DTK::Shell::ContextParams.new
|
31
31
|
new_context_params.add_context_to_params(module_type, module_type)
|
@@ -35,10 +35,9 @@ module DTK::Client
|
|
35
35
|
response = ContextRouter.routeTask(module_type, "pull_dtkn", new_context_params, @conn)
|
36
36
|
|
37
37
|
raise DTK::Client::DtkError, response.error_message unless response.ok?
|
38
|
-
|
39
|
-
# in case there are diffs there was no ouput so we add 'Done'
|
40
|
-
puts 'Done.' unless response.data[:diffs].empty?
|
41
38
|
end
|
39
|
+
|
40
|
+
print "Resuming pull ... "
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
@@ -114,7 +113,12 @@ module DTK::Client
|
|
114
113
|
new_context_params = ::DTK::Shell::ContextParams.new
|
115
114
|
new_context_params.forward_options(thor_options)
|
116
115
|
new_context_params.add_context_to_params(formated_name, :"component-module", m['id'])
|
117
|
-
|
116
|
+
|
117
|
+
begin
|
118
|
+
response = ContextRouter.routeTask("component_module", "clone", new_context_params, @conn)
|
119
|
+
rescue DTK::Client::DtkValidationError => e
|
120
|
+
# ignoring this
|
121
|
+
end
|
118
122
|
# puts "Done."
|
119
123
|
end
|
120
124
|
end
|
@@ -153,7 +153,7 @@ module DTK::Client
|
|
153
153
|
|
154
154
|
edit_opts = {
|
155
155
|
:automatically_clone => true,
|
156
|
-
:pull_if_needed =>
|
156
|
+
:pull_if_needed => false,
|
157
157
|
:assembly_module => {
|
158
158
|
:assembly_name => assembly_name,
|
159
159
|
:version => version
|
@@ -727,6 +727,7 @@ module DTK::Client
|
|
727
727
|
}
|
728
728
|
|
729
729
|
response = post(rest_url("assembly/initiate_get_netstats"),post_body)
|
730
|
+
raise DTK::Client::DtkValidationError, response.data(:errors) if response.data(:errors)
|
730
731
|
return response unless response.ok?
|
731
732
|
|
732
733
|
action_results_id = response.data(:action_results_id)
|
@@ -836,6 +837,7 @@ module DTK::Client
|
|
836
837
|
}
|
837
838
|
|
838
839
|
response = post(rest_url("assembly/initiate_get_ps"),post_body)
|
840
|
+
raise DTK::Client::DtkValidationError, response.data(:errors) if response.data(:errors)
|
839
841
|
return response unless response.ok?
|
840
842
|
|
841
843
|
action_results_id = response.data(:action_results_id)
|
@@ -923,6 +925,7 @@ module DTK::Client
|
|
923
925
|
}
|
924
926
|
|
925
927
|
response = post rest_url("assembly/initiate_get_log"), post_body
|
928
|
+
raise DTK::Client::DtkValidationError, response.data(:errors) if response.data(:errors)
|
926
929
|
|
927
930
|
unless response.ok?
|
928
931
|
raise DTK::Client::DtkError, "Error while getting log from server, there was no successful response."
|
@@ -1029,6 +1032,7 @@ module DTK::Client
|
|
1029
1032
|
}
|
1030
1033
|
|
1031
1034
|
response = post rest_url("assembly/initiate_grep"), post_body
|
1035
|
+
raise DTK::Client::DtkValidationError, response.data(:errors) if response.data(:errors)
|
1032
1036
|
|
1033
1037
|
unless response.ok?
|
1034
1038
|
raise DTK::Client::DtkError, "Error while getting log from server. Message: #{response['errors'][0]['message'].nil? ? 'There was no successful response.' : response['errors'].first['message']}"
|
@@ -1138,6 +1142,9 @@ module DTK::Client
|
|
1138
1142
|
when "attributes"
|
1139
1143
|
data_type = (options.links? ? :workspace_attribute_w_link : :workspace_attribute)
|
1140
1144
|
edit_attr_format = context_params.get_forwarded_options()[:format] if context_params.get_forwarded_options()
|
1145
|
+
if tags = options.tags
|
1146
|
+
post_options.merge!(:tags => tags.split(','))
|
1147
|
+
end
|
1141
1148
|
if format = (options.format || edit_attr_format)
|
1142
1149
|
post_options.merge!(:format => format)
|
1143
1150
|
#dont need to compute links if using a format
|
@@ -345,7 +345,7 @@ module DTK::Client
|
|
345
345
|
|
346
346
|
# prompt to see if user is ready to continue with warnings/errors
|
347
347
|
if are_there_warnings
|
348
|
-
return false unless Console.confirmation_prompt("Do you want to
|
348
|
+
return false unless Console.confirmation_prompt("Do you still want to proceed with import"+'?')
|
349
349
|
end
|
350
350
|
|
351
351
|
# case when we need to import additional components
|
@@ -357,10 +357,13 @@ module DTK::Client
|
|
357
357
|
continue = trigger_module_auto_import(missing_components, required_components, module_opts)
|
358
358
|
return unless continue
|
359
359
|
|
360
|
-
|
360
|
+
print "Resuming DTK Network import for #{module_type} '#{remote_module_name}' ..."
|
361
361
|
# repeat import call for service
|
362
362
|
post_body.merge!(opts)
|
363
363
|
response = post rest_url("#{module_type}/import"), post_body
|
364
|
+
|
365
|
+
# we set skip cloning since it is already done by import
|
366
|
+
puts " Done"
|
364
367
|
end
|
365
368
|
|
366
369
|
return response if(!response.ok? || response.data(:does_not_exist))
|
@@ -489,7 +492,7 @@ module DTK::Client
|
|
489
492
|
|
490
493
|
module_location = OsUtil.module_location(module_type, module_name, version)
|
491
494
|
|
492
|
-
raise DTK::Client::DtkValidationError, "
|
495
|
+
raise DTK::Client::DtkValidationError, "#{module_type.gsub('_',' ').capitalize} '#{module_name}#{version && "-#{version}"}' already cloned!" if File.directory?(module_location)
|
493
496
|
clone_aux(module_type.to_sym, module_id, version, internal_trigger, thor_options['omit_output'])
|
494
497
|
end
|
495
498
|
|
@@ -134,14 +134,23 @@ module DTK::Client
|
|
134
134
|
response.ok? ? nil : response
|
135
135
|
end
|
136
136
|
|
137
|
-
desc "delete-ssh-key KEYPAIR-NAME ","Deletes the named ssh key from your user account"
|
137
|
+
desc "delete-ssh-key KEYPAIR-NAME [-y]","Deletes the named ssh key from your user account"
|
138
|
+
method_option :force, :aliases => '-y', :type => :boolean, :default => false
|
138
139
|
def delete_ssh_key(context_params)
|
139
140
|
name = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
140
|
-
post_body = { :username => name.chomp }
|
141
141
|
|
142
|
-
|
142
|
+
unless options.force?
|
143
|
+
is_go = Console.confirmation_prompt("Are you sure you want to delete SSH key '#{name}'"+"?")
|
144
|
+
return nil unless is_go
|
145
|
+
end
|
146
|
+
|
147
|
+
response = post rest_url("account/remove_user_direct_access"), { :username => name.chomp }
|
143
148
|
return response unless response.ok?
|
144
149
|
|
150
|
+
if response.ok? && !response.data(:unregistered_with_repoman)
|
151
|
+
OsUtil.print("Warning: We were not able to unregister your key with remote catalog!", :yellow)
|
152
|
+
end
|
153
|
+
|
145
154
|
OsUtil.print("SSH key '#{name}' removed successfully!", :yellow)
|
146
155
|
nil
|
147
156
|
end
|
@@ -9,14 +9,11 @@ module DTK::Client
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.valid_children()
|
12
|
-
# [:"component-template"]
|
13
12
|
[:component]
|
14
13
|
end
|
15
14
|
|
16
15
|
# this includes children of children - has to be sorted by n-level access
|
17
16
|
def self.all_children()
|
18
|
-
# [:"component-template", :attribute] # Amar: attribute context commented out per Rich suggeston
|
19
|
-
# [:"component-template"]
|
20
17
|
[:component]
|
21
18
|
end
|
22
19
|
|
@@ -39,9 +36,6 @@ module DTK::Client
|
|
39
36
|
["list","list","# List all component templates."],
|
40
37
|
["list-attributes","list-attributes", "# List all attributes for given component."]
|
41
38
|
]
|
42
|
-
#:attribute => [
|
43
|
-
# ['list',"list","List attributes for given component"]
|
44
|
-
#]
|
45
39
|
},
|
46
40
|
:identifier_only => {
|
47
41
|
:"component" => [
|
@@ -56,31 +50,6 @@ module DTK::Client
|
|
56
50
|
return :component_module, "component_module/list", nil
|
57
51
|
end
|
58
52
|
|
59
|
-
#TODO: in for testing; may remove
|
60
|
-
# desc "MODULE-NAME/ID test-generate-dsl", "Test generating DSL from implementation"
|
61
|
-
# def test_generate_dsl(context_params)
|
62
|
-
# component_module_id = context_params.retrieve_arguments([:module_id!],method_argument_names)
|
63
|
-
# post rest_url("component_module/test_generate_dsl"),{:component_module_id => component_module_id}
|
64
|
-
# end
|
65
|
-
|
66
|
-
# desc "MODULE-NAME/ID dsl-upgrade [UPGRADE-VERSION] [-v MODULE-VERSION]","Component module DSL upgrade"
|
67
|
-
# version_method_option
|
68
|
-
# def dsl_upgrade(context_params)
|
69
|
-
# component_module_id, dsl_version = context_params.retrieve_arguments([:module_id, :option_1],method_argument_names)
|
70
|
-
# dsl_version ||= MostRecentDSLVersion
|
71
|
-
# post_body = {
|
72
|
-
# :component_module_id => component_module_id,
|
73
|
-
# :dsl_version => dsl_version
|
74
|
-
# }
|
75
|
-
# post_body.merge!(:version => options["version"]) if options["version"]
|
76
|
-
# post rest_url("component_module/create_new_dsl_version"),post_body
|
77
|
-
# end
|
78
|
-
# MostRecentDSLVersion = 2
|
79
|
-
### end
|
80
|
-
|
81
|
-
#### create and delete commands ###
|
82
|
-
# desc "delete COMPONENT-MODULE-NAME [-v VERSION] [-y] [-p]", "Delete component module or component module version and all items contained in it. Optional parameter [-p] is to delete local directory."
|
83
|
-
# version_method_option
|
84
53
|
desc "delete COMPONENT-MODULE-NAME [-y] [-p]", "Delete component module and all items contained in it. Optional parameter [-p] is to delete local directory."
|
85
54
|
method_option :force, :aliases => '-y', :type => :boolean, :default => false
|
86
55
|
method_option :purge, :aliases => '-p', :type => :boolean, :default => false
|
@@ -91,29 +60,11 @@ module DTK::Client
|
|
91
60
|
response
|
92
61
|
end
|
93
62
|
|
94
|
-
|
95
63
|
desc "COMPONENT-MODULE-NAME/ID set-attribute ATTRIBUTE-ID VALUE", "Set value of component module attributes"
|
96
64
|
def set_attribute(context_params)
|
97
65
|
set_attribute_module_aux(context_params)
|
98
66
|
end
|
99
67
|
|
100
|
-
#### end: create and delete commands ###
|
101
|
-
|
102
|
-
=begin
|
103
|
-
TODO: might deprecate
|
104
|
-
#### list and info commands ###
|
105
|
-
desc "COMPONENT-MODULE-NAME/ID info", "Get information about given component module."
|
106
|
-
def info(context_params)
|
107
|
-
component_module_id = context_params.retrieve_arguments([:component_module_id!],method_argument_names)
|
108
|
-
|
109
|
-
post_body = {
|
110
|
-
:component_module_id => component_module_id
|
111
|
-
}
|
112
|
-
|
113
|
-
response = post rest_url("component_module/info"), post_body
|
114
|
-
response.render_custom_info("module")
|
115
|
-
end
|
116
|
-
=end
|
117
68
|
desc "list [--remote] [--diff] [-n NAMESPACE]", "List loaded or remote component modules. Use --diff to compare loaded and remote component modules."
|
118
69
|
method_option :remote, :type => :boolean, :default => false
|
119
70
|
method_option :diff, :type => :boolean, :default => false
|
@@ -132,27 +83,12 @@ TODO: might deprecate
|
|
132
83
|
post_body[:diff] = options.diff? ? options.diff : {}
|
133
84
|
post_body.merge!(:module_namespace => options.namespace) if options.namespace
|
134
85
|
|
135
|
-
response = post rest_url("component_module/#{action}"),post_body
|
86
|
+
response = post rest_url("component_module/#{action}"), post_body
|
136
87
|
|
137
88
|
return response unless response.ok?
|
138
89
|
response.render_table()
|
139
90
|
end
|
140
91
|
|
141
|
-
=begin
|
142
|
-
desc "COMPONENT-MODULE-NAME/ID list-versions","List all versions associated with this component module."
|
143
|
-
def list_versions(context_params)
|
144
|
-
component_module_id = context_params.retrieve_arguments([:component_module_id!],method_argument_names)
|
145
|
-
post_body = {
|
146
|
-
:component_module_id => component_module_id,
|
147
|
-
:detail_to_include => ["remotes"],
|
148
|
-
:rsa_pub_key => SSHUtil.rsa_pub_key_content()
|
149
|
-
}
|
150
|
-
response = post rest_url("component_module/versions"), post_body
|
151
|
-
|
152
|
-
response.render_table(:module_version)
|
153
|
-
end
|
154
|
-
=end
|
155
|
-
|
156
92
|
desc "COMPONENT-MODULE-NAME/ID list-components", "List all components for given component module."
|
157
93
|
def list_components(context_params)
|
158
94
|
module_info_about(context_params, :components, :component)
|
@@ -165,14 +101,9 @@ TODO: might deprecate
|
|
165
101
|
|
166
102
|
desc "COMPONENT-MODULE-NAME/ID list-instances", "List all instances for given component module."
|
167
103
|
def list_instances(context_params)
|
168
|
-
module_info_about(context_params, :instances, :
|
104
|
+
module_info_about(context_params, :instances, :component_instances)
|
169
105
|
end
|
170
106
|
|
171
|
-
#### end: list and info commands ###
|
172
|
-
|
173
|
-
#### commands to interact with remote repo ###
|
174
|
-
|
175
|
-
|
176
107
|
desc "import [NAMESPACE:]COMPONENT-MODULE-NAME", "Create new component module from local clone"
|
177
108
|
def import(context_params)
|
178
109
|
response = import_module_aux(context_params)
|
@@ -181,6 +112,25 @@ TODO: might deprecate
|
|
181
112
|
response
|
182
113
|
end
|
183
114
|
|
115
|
+
=begin
|
116
|
+
desc "import-puppet-forge PUPPET-MODULE-NAME [NAMESPACE:]COMPONENT-MODULE-NAME", "Install puppet module from puppet forge"
|
117
|
+
def import_puppet_forge(context_params)
|
118
|
+
pf_module_name, full_module_name = context_params.retrieve_arguments([:option_1!, :option_2!],method_argument_names)
|
119
|
+
namespace, module_name = get_namespace_and_name(full_module_name, ModuleUtil::NAMESPACE_SEPERATOR)
|
120
|
+
|
121
|
+
response = post rest_url("component_module/install_puppet_module"), {
|
122
|
+
:puppetf_module_name => pf_module_name,
|
123
|
+
:module_name => module_name,
|
124
|
+
:module_namespace => namespace
|
125
|
+
}
|
126
|
+
|
127
|
+
return response unless response.ok?
|
128
|
+
|
129
|
+
@@invalidate_map << :component_module
|
130
|
+
response
|
131
|
+
end
|
132
|
+
=end
|
133
|
+
|
184
134
|
#
|
185
135
|
# Creates component module from input git repo, removing .git dir to rid of pointing to user github, and creates component module
|
186
136
|
#
|
@@ -394,6 +344,20 @@ TODO: might deprecate
|
|
394
344
|
clone_aux(:component_module,component_module_id,version,internal_trigger,omit_output)
|
395
345
|
end
|
396
346
|
=end
|
347
|
+
=begin
|
348
|
+
desc "COMPONENT-MODULE-NAME/ID list-versions","List all versions associated with this component module."
|
349
|
+
def list_versions(context_params)
|
350
|
+
component_module_id = context_params.retrieve_arguments([:component_module_id!],method_argument_names)
|
351
|
+
post_body = {
|
352
|
+
:component_module_id => component_module_id,
|
353
|
+
:detail_to_include => ["remotes"],
|
354
|
+
:rsa_pub_key => SSHUtil.rsa_pub_key_content()
|
355
|
+
}
|
356
|
+
response = post rest_url("component_module/versions"), post_body
|
357
|
+
|
358
|
+
response.render_table(:module_version)
|
359
|
+
end
|
360
|
+
=end
|
397
361
|
|
398
362
|
##
|
399
363
|
#
|
@@ -27,7 +27,11 @@ module DTK::Client
|
|
27
27
|
component_module_id = context_params.retrieve_arguments([:component_module_id!])
|
28
28
|
res = get_cached_response(:component_template, "component_module/info_about", { :component_module_id => component_module_id, :about => :components})
|
29
29
|
else
|
30
|
-
|
30
|
+
post_body = {:subtype => 'template', :ignore => 'test_module'}
|
31
|
+
if assembly_id = context_params.retrieve_arguments([[:service_id, :workspace_id]])
|
32
|
+
post_body.merge!(:assembly_id => assembly_id)
|
33
|
+
end
|
34
|
+
get_cached_response(:component_template, "component/list", post_body)
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|
@@ -341,8 +341,9 @@ TODO: will put in dot release and will rename to 'extend'
|
|
341
341
|
list_components_aux(context_params)
|
342
342
|
end
|
343
343
|
|
344
|
-
desc "SERVICE-NAME/ID list-attributes [-f FORMAT] [--links]","List attributes associated with service."
|
345
|
-
method_option :format
|
344
|
+
desc "SERVICE-NAME/ID list-attributes [-f FORMAT] [-t TAG,..] [--links]","List attributes associated with service."
|
345
|
+
method_option :format, :aliases => '-f'
|
346
|
+
method_option :tags, :aliases => '-t'
|
346
347
|
method_option :links, :type => :boolean, :default => false, :aliases => '-l'
|
347
348
|
def list_attributes(context_params)
|
348
349
|
list_attributes_aux(context_params)
|
@@ -133,7 +133,7 @@ module DTK::Client
|
|
133
133
|
if about
|
134
134
|
case about
|
135
135
|
when "assembly"
|
136
|
-
data_type = :
|
136
|
+
data_type = :assembly_template_description
|
137
137
|
action = "list_assemblies"
|
138
138
|
when "modules"
|
139
139
|
data_type = options.remote? ? :component_remote : :component_module
|
@@ -383,8 +383,9 @@ module DTK::Client
|
|
383
383
|
end
|
384
384
|
end
|
385
385
|
|
386
|
-
desc "WORKSPACE-NAME/ID list-attributes [-f FORMAT] [--links]","List attributes associated with workspace."
|
387
|
-
method_option :format
|
386
|
+
desc "WORKSPACE-NAME/ID list-attributes [-f FORMAT] [-t TAG,..] [--links]","List attributes associated with workspace."
|
387
|
+
method_option :format, :aliases => '-f'
|
388
|
+
method_option :tags, :aliases => '-t'
|
388
389
|
method_option :links, :type => :boolean, :default => false, :aliases => '-l'
|
389
390
|
def list_attributes(context_params)
|
390
391
|
list_attributes_aux(context_params)
|
data/lib/core.rb
CHANGED
@@ -16,6 +16,7 @@ dtk_require_from_base('util/common_util')
|
|
16
16
|
dtk_require_from_base('util/permission_util')
|
17
17
|
dtk_require_from_base('util/remote_dependency_util')
|
18
18
|
dtk_require_from_base('util/module_util')
|
19
|
+
dtk_require_from_base('shell/message_queue')
|
19
20
|
|
20
21
|
dtk_require("config/configuration")
|
21
22
|
|
@@ -62,7 +63,6 @@ def top_level_execute_core(entity_name, method_name, context_params=nil, options
|
|
62
63
|
if print = response_ruby_obj.render_data()
|
63
64
|
print = [print] unless print.kind_of?(Array)
|
64
65
|
print.each do |el|
|
65
|
-
|
66
66
|
if el.kind_of?(String)
|
67
67
|
el.each_line{|l| STDOUT << l}
|
68
68
|
else
|
@@ -70,6 +70,10 @@ def top_level_execute_core(entity_name, method_name, context_params=nil, options
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
73
|
+
|
74
|
+
# process/print queued message from server
|
75
|
+
DTK::Shell::MessageQueue.print_messages()
|
76
|
+
|
73
77
|
rescue DTK::Client::DtkLoginRequiredError => e
|
74
78
|
# this error is handled in method above
|
75
79
|
raise e
|
@@ -377,7 +381,12 @@ module DTK
|
|
377
381
|
response = rest_method_func.call
|
378
382
|
end
|
379
383
|
|
380
|
-
Response.new(command_class, response)
|
384
|
+
response_obj = Response.new(command_class, response)
|
385
|
+
|
386
|
+
# queue messages from server to be displayed later
|
387
|
+
DTK::Shell::MessageQueue.process_response(response_obj)
|
388
|
+
|
389
|
+
response_obj
|
381
390
|
end
|
382
391
|
|
383
392
|
|
data/lib/dtk-client/version.rb
CHANGED
data/lib/parser/adapters/thor.rb
CHANGED
@@ -469,6 +469,10 @@ module DTK
|
|
469
469
|
namespace, name = [$1,$2]
|
470
470
|
|
471
471
|
return [nil, component_full_name] if (name.include?(':') && !name.include?('::'))
|
472
|
+
|
473
|
+
# to be robust to user putting in ns::x::y which splits to ns=ns name=:x::y
|
474
|
+
name.gsub!(/^:/,'')
|
475
|
+
|
472
476
|
component_full_name = name
|
473
477
|
end
|
474
478
|
|
data/lib/shell/context.rb
CHANGED
@@ -110,11 +110,7 @@ module DTK
|
|
110
110
|
begin
|
111
111
|
# check if we are doing switch context
|
112
112
|
if args.join("").match(/\A\-\Z/)
|
113
|
-
|
114
|
-
# swap 2 variables
|
115
|
-
@active_context, @previous_context = @previous_context, @active_context
|
116
|
-
end
|
117
|
-
load_context(active_context.last_context_name)
|
113
|
+
revert_context()
|
118
114
|
return
|
119
115
|
end
|
120
116
|
|
@@ -143,7 +139,10 @@ module DTK
|
|
143
139
|
|
144
140
|
load_context(active_context.last_context_name)
|
145
141
|
|
146
|
-
|
142
|
+
if error_message
|
143
|
+
revert_context()
|
144
|
+
raise DTK::Client::DtkValidationError, error_message
|
145
|
+
end
|
147
146
|
rescue DTK::Client::DtkValidationError => e
|
148
147
|
DTK::Client::OsUtil.print(e.message, :yellow)
|
149
148
|
rescue DTK::Shell::Error, Exception => e
|
@@ -213,12 +212,14 @@ module DTK
|
|
213
212
|
|
214
213
|
# TODO: this is hack used this to hide 'node' context and use just node_identifier
|
215
214
|
# we should rethink the design of shell context if we are about to use different behaviors like this
|
216
|
-
def self.check_invisible_context(acc, entries, is_root, line_buffer=[], args=[])
|
215
|
+
def self.check_invisible_context(acc, entries, is_root, line_buffer=[], args=[], current_context_clazz=nil)
|
216
|
+
check = nil
|
217
217
|
entries.reject! { |e| e.empty? }
|
218
218
|
goes_from_root = args.first.start_with?('/')
|
219
219
|
|
220
|
-
unless line_buffer.empty?
|
221
|
-
command = line_buffer.split(' ').first
|
220
|
+
unless (line_buffer.empty? && args.empty?)
|
221
|
+
command = line_buffer.empty? ? args.first : line_buffer.split(' ').first
|
222
|
+
# command = line_buffer.split(' ').first
|
222
223
|
current_c_name = acc.last_command_name
|
223
224
|
current_context = acc.last_context
|
224
225
|
clazz = DTK::Shell::Context.get_command_class(current_c_name)
|
@@ -229,12 +230,23 @@ module DTK
|
|
229
230
|
clazz_from_args = DTK::Shell::Context.get_command_class(command_from_args) if command_from_args
|
230
231
|
end
|
231
232
|
|
233
|
+
check = (command.eql?('cd') || command.eql?('cc') || command.eql?('popc') || command.eql?('pushc') || command.eql?('delete-node'))
|
234
|
+
# used when calling node commands from service or workspace context
|
235
|
+
# e.g. service/service_name>node1 info will display info about nodes instead of service instance
|
236
|
+
unless check
|
237
|
+
if current_c_name.eql?('service') || current_c_name.eql?('workspace')
|
238
|
+
context_hash_data, error_message, invalid_context = current_context_clazz.validate_value('node', command, acc)
|
239
|
+
check = true if context_hash_data && !error_message
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
232
243
|
# this delete-node is a hack because we need autocomplete when there is node with name 'node'
|
233
|
-
if (command.eql?('cd') || command.eql?('cc') || command.eql?('popc') || command.eql?('pushc') || command.eql?('delete-node'))
|
244
|
+
# if (command.eql?('cd') || command.eql?('cc') || command.eql?('popc') || command.eql?('pushc') || command.eql?('delete-node'))
|
245
|
+
if check
|
234
246
|
if is_root
|
235
247
|
if entries.size >= 3
|
236
248
|
node = entries[2]
|
237
|
-
if (node && clazz_from_args.respond_to?(:valid_child?))
|
249
|
+
if (node && clazz_from_args.respond_to?(:valid_child?) && !clazz_from_args.invisible_context_list.empty?)
|
238
250
|
unless clazz_from_args.valid_children().first.to_s.include?(node)
|
239
251
|
entries[2] = ["node", node]
|
240
252
|
entries.flatten!
|
@@ -281,7 +293,7 @@ module DTK
|
|
281
293
|
|
282
294
|
# transform alias to full path
|
283
295
|
entries = Context.check_for_sym_link(entries) if root?
|
284
|
-
entries = Context.check_invisible_context(active_context_copy, entries, root?, line_buffer, args)
|
296
|
+
entries = Context.check_invisible_context(active_context_copy, entries, root?, line_buffer, args, self)
|
285
297
|
|
286
298
|
# if only '/' or just cc skip validation
|
287
299
|
return active_context_copy if entries.empty?
|
@@ -535,6 +547,14 @@ module DTK
|
|
535
547
|
load_context()
|
536
548
|
end
|
537
549
|
|
550
|
+
def revert_context()
|
551
|
+
if @previous_context
|
552
|
+
# swap 2 variables
|
553
|
+
@active_context, @previous_context = @previous_context, @active_context
|
554
|
+
end
|
555
|
+
load_context(active_context.last_context_name)
|
556
|
+
end
|
557
|
+
|
538
558
|
# when e.g assembly is deleted we want it to be removed from list without
|
539
559
|
# exiting dtk-shell
|
540
560
|
def reload_cached_tasks(command_name)
|
@@ -0,0 +1,44 @@
|
|
1
|
+
dtk_require_from_base('util/os_util')
|
2
|
+
|
3
|
+
module DTK
|
4
|
+
module Shell
|
5
|
+
class MessageQueue
|
6
|
+
include Singleton
|
7
|
+
|
8
|
+
MESSAGE_TYPES = [:info, :warn, :error]
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@queue = {}
|
12
|
+
init_or_clear()
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.process_response(response_obj)
|
16
|
+
self.instance.process_response(response_obj)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.print_messages()
|
20
|
+
self.instance.print_messages()
|
21
|
+
end
|
22
|
+
|
23
|
+
def init_or_clear()
|
24
|
+
MESSAGE_TYPES.each { |msg_type| @queue[msg_type] = [] }
|
25
|
+
end
|
26
|
+
|
27
|
+
def print_messages()
|
28
|
+
@queue[:info].each { |msg| DTK::Client::OsUtil.print(msg, :white) }
|
29
|
+
@queue[:warn].each { |msg| DTK::Client::OsUtil.print(msg, :yellow) }
|
30
|
+
@queue[:error].each { |msg| DTK::Client::OsUtil.print(msg, :red) }
|
31
|
+
|
32
|
+
init_or_clear()
|
33
|
+
end
|
34
|
+
|
35
|
+
def process_response(response_obj)
|
36
|
+
MESSAGE_TYPES.each do |msg_type|
|
37
|
+
msg = response_obj[msg_type.to_s] || response_obj[msg_type]
|
38
|
+
@queue[msg_type] << msg if msg
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/util/os_util.rb
CHANGED
@@ -197,7 +197,7 @@ module DTK
|
|
197
197
|
component_module_dir = component_clone_location()
|
198
198
|
|
199
199
|
directories = Dir.entries(component_module_dir).map do |entry|
|
200
|
-
next if (entry =='.' || entry == '..' || entry.index('.') == 0)
|
200
|
+
next if (entry =='.' || entry == '..' || entry.index('.') == 0 || !File.directory?(entry))
|
201
201
|
|
202
202
|
Dir.entries("#{component_module_dir}/#{entry}").map do |m_entry|
|
203
203
|
next unless File.directory? File.join(component_module_dir,entry,m_entry)
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dtk-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rich PELAVIN
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - '>='
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.2.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - '>='
|
24
|
+
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.2.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -278,6 +278,7 @@ files:
|
|
278
278
|
- lib/shell/header_shell.rb
|
279
279
|
- lib/shell/help_monkey_patch.rb
|
280
280
|
- lib/shell/interactive_wizard.rb
|
281
|
+
- lib/shell/message_queue.rb
|
281
282
|
- lib/shell/parse_monkey_patch.rb
|
282
283
|
- lib/shell/status_monitor.rb
|
283
284
|
- lib/util/common_util.rb
|
@@ -328,12 +329,12 @@ require_paths:
|
|
328
329
|
- lib
|
329
330
|
required_ruby_version: !ruby/object:Gem::Requirement
|
330
331
|
requirements:
|
331
|
-
- - '>='
|
332
|
+
- - ! '>='
|
332
333
|
- !ruby/object:Gem::Version
|
333
334
|
version: '0'
|
334
335
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
335
336
|
requirements:
|
336
|
-
- - '>='
|
337
|
+
- - ! '>='
|
337
338
|
- !ruby/object:Gem::Version
|
338
339
|
version: '0'
|
339
340
|
requirements: []
|