dtk-client 0.6.8 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/bin/dtk +5 -1
- data/lib/auxiliary.rb +0 -1
- data/lib/commands/common/thor/assembly_workspace.rb +20 -1
- data/lib/commands/common/thor/inventory_parser.rb +1 -1
- data/lib/commands/common/thor/module/import.rb +41 -106
- data/lib/commands/common/thor/module.rb +13 -226
- data/lib/commands/common/thor/poller.rb +48 -0
- data/lib/commands/common/thor/puppet_forge.rb +7 -1
- data/lib/commands/common/thor/purge_clone.rb +2 -1
- data/lib/commands/common/thor/task_status.rb +15 -14
- data/lib/commands/common/thor/test_action_agent.rb +39 -0
- data/lib/commands/thor/component_module.rb +2 -2
- data/lib/commands/thor/node.rb +55 -14
- data/lib/commands/thor/node_group.rb +2 -26
- data/lib/commands/thor/service.rb +31 -11
- data/lib/commands/thor/service_module.rb +3 -1
- data/lib/commands/thor/workspace.rb +13 -3
- data/lib/core.rb +16 -6
- data/lib/domain/git_adapter.rb +0 -3
- data/lib/domain/response.rb +25 -13
- data/lib/dtk-client/version.rb +1 -1
- data/lib/parser/adapters/thor.rb +8 -5
- data/lib/shell/context.rb +8 -19
- data/lib/shell/domain/active_context.rb +169 -0
- data/lib/shell/domain/context_entity.rb +72 -0
- data/lib/shell/domain/context_params.rb +202 -0
- data/lib/shell/domain/override_tasks.rb +71 -0
- data/lib/shell/domain/shadow_entity.rb +59 -0
- data/lib/shell/help_monkey_patch.rb +76 -71
- data/lib/shell/message_queue.rb +2 -0
- data/lib/shell/status_monitor.rb +5 -3
- data/lib/shell.rb +4 -2
- data/lib/util/dtk_puppet.rb +8 -6
- data/lib/util/os_util.rb +5 -1
- data/lib/view_processor/table_print.rb +67 -12
- data/spec/lib/spec_thor.rb +5 -2
- metadata +9 -3
- data/lib/shell/domain.rb +0 -492
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODdhNDYxZmYwMjY5YjVlODJhNzA4YjAzNGZlYTJiMWUzNDU4ZTQ3MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWU3YjdjMjgxNjk4MDMwZDJkMjM5NjhkM2QxNmUwNjQxYTQyMWFiNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjgxYTk4MWM2ODA2OWNiNjI5NjQwYjJlZGI0MWY5MTMzNjgzMGUyZjExZTZi
|
10
|
+
OWUxMmQwMjFlYmEyMWI0ZGE1OWQ1YmMyOTI0MzljMDU4MDI0YzM2NmY0ZWEw
|
11
|
+
ZjY0YTliNzRmMGZjMmMzYzg4YzM5ZDFiNzNkZTBiNWY1OTM3NjQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDMyYzU2YWZmYzc4NjQ0YTI2YTIzN2E2OTllMjRhMDZlM2Q5ODU2ZGY1ZTI5
|
14
|
+
M2Q2OTY3NWY5ODJiOGMxZWY3MzZiZDdhZWViZTZiNGMyYzNlM2Q0YmQ0ODkx
|
15
|
+
N2NlNzZhYWE5Y2UzYWIzOGJjZDc3ZWUzYzFmZDcyYmNhNzdkMTM=
|
data/bin/dtk
CHANGED
@@ -7,7 +7,11 @@ require File.expand_path('../lib/client', File.dirname(__FILE__))
|
|
7
7
|
require File.expand_path('../lib/configurator', File.dirname(__FILE__))
|
8
8
|
require File.expand_path('../lib/parser/adapters/thor', File.dirname(__FILE__))
|
9
9
|
require File.expand_path('../lib/shell/context', File.dirname(__FILE__))
|
10
|
-
require File.expand_path('../lib/shell/domain', File.dirname(__FILE__))
|
10
|
+
require File.expand_path('../lib/shell/domain/context_entity', File.dirname(__FILE__))
|
11
|
+
require File.expand_path('../lib/shell/domain/active_context', File.dirname(__FILE__))
|
12
|
+
require File.expand_path('../lib/shell/domain/context_params', File.dirname(__FILE__))
|
13
|
+
require File.expand_path('../lib/shell/domain/override_tasks', File.dirname(__FILE__))
|
14
|
+
require File.expand_path('../lib/shell/domain/shadow_entity', File.dirname(__FILE__))
|
11
15
|
require File.expand_path('../lib/commands/thor/account', File.dirname(__FILE__))
|
12
16
|
require File.expand_path('../lib/shell/parse_monkey_patch', File.dirname(__FILE__))
|
13
17
|
require File.expand_path('../lib/shell/help_monkey_patch', File.dirname(__FILE__))
|
data/lib/auxiliary.rb
CHANGED
@@ -78,6 +78,7 @@ module DTK::Client
|
|
78
78
|
|
79
79
|
post_body.merge!(:assembly_template_name => assembly_template_name) if assembly_template_name
|
80
80
|
post_body.merge!(:use_module_namespace => true) if opts[:use_module_namespace]
|
81
|
+
post_body.merge!(:description => opts[:description]) if opts[:description]
|
81
82
|
response = post rest_url("assembly/promote_to_template"), post_body
|
82
83
|
return response unless response.ok?()
|
83
84
|
|
@@ -103,6 +104,11 @@ module DTK::Client
|
|
103
104
|
response.render_table(:violation)
|
104
105
|
end
|
105
106
|
|
107
|
+
def print_includes_aux(context_params)
|
108
|
+
assembly_or_workspace_id = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID],method_argument_names)
|
109
|
+
response = post rest_url("assembly/print_includes"),:assembly_id => assembly_or_workspace_id
|
110
|
+
end
|
111
|
+
|
106
112
|
def converge_aux(context_params)
|
107
113
|
assembly_or_workspace_id = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID],method_argument_names)
|
108
114
|
|
@@ -270,7 +276,7 @@ module DTK::Client
|
|
270
276
|
|
271
277
|
def task_status_aw_aux(context_params)
|
272
278
|
assembly_or_workspace_id = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID],method_argument_names)
|
273
|
-
response = task_status_aux(assembly_or_workspace_id,:assembly
|
279
|
+
response = task_status_aux(assembly_or_workspace_id,:assembly,:wait => options.wait?,:summarize => options.summarize?)
|
274
280
|
|
275
281
|
# TODO: Hack which is necessery for the specific problem (DTK-725), we don't get proper error message when there is a timeout doing converge
|
276
282
|
unless response == true
|
@@ -285,6 +291,15 @@ module DTK::Client
|
|
285
291
|
response
|
286
292
|
end
|
287
293
|
|
294
|
+
def task_action_detail_aw_aux(context_params)
|
295
|
+
assembly_or_workspace_id, message_id = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID, :option_1!], method_argument_names)
|
296
|
+
post_body = {
|
297
|
+
:assembly_id => assembly_or_workspace_id,
|
298
|
+
:message_id => message_id
|
299
|
+
}
|
300
|
+
post rest_url("assembly/task_action_detail"), post_body
|
301
|
+
end
|
302
|
+
|
288
303
|
def link_attributes_aux(context_params)
|
289
304
|
assembly_id, target_attr_term, source_attr_term = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID,:option_1!,:option_2!],method_argument_names)
|
290
305
|
post_body = {
|
@@ -521,6 +536,9 @@ module DTK::Client
|
|
521
536
|
assembly_or_workspace_id, node_id, component_id, attribute_id = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID, :node_id, :component_id, :attribute_id],method_argument_names)
|
522
537
|
is_json_return = context_params.get_forwarded_options[:json_return] || false
|
523
538
|
|
539
|
+
# return only node group info if triggered from node group
|
540
|
+
is_node_group = true if context_params.shadow_entity_name == 'node_group'
|
541
|
+
|
524
542
|
post_body = {
|
525
543
|
:assembly_id => assembly_or_workspace_id,
|
526
544
|
:node_id => node_id,
|
@@ -530,6 +548,7 @@ module DTK::Client
|
|
530
548
|
:json_return => is_json_return
|
531
549
|
}
|
532
550
|
|
551
|
+
post_body.merge!(:only_node_group_info => true) if is_node_group
|
533
552
|
resp = post rest_url("assembly/info"), post_body
|
534
553
|
|
535
554
|
# if waiting for json response we do not need to render rest of data
|
@@ -17,7 +17,7 @@ module DTK::Client
|
|
17
17
|
ssh_credentials = data["ssh_credentials"]||defaults["ssh_credentials"]
|
18
18
|
|
19
19
|
raise DtkValidationError, "Credentials for '#{ssh_credentials}' does not exist in credentials file '#{ssh_creds_path}'" unless ssh_creds_data.include?(ssh_credentials)
|
20
|
-
|
20
|
+
|
21
21
|
ref = "physical--#{display_name}"
|
22
22
|
row = ret[ref] = {
|
23
23
|
:display_name => display_name,
|
@@ -1,13 +1,4 @@
|
|
1
1
|
dtk_require_from_base("util/os_util")
|
2
|
-
|
3
|
-
# For Aldin: dont thing these are needed although this may be stylistic, which is fine; just putting here to make where the include
|
4
|
-
# include ReparseMixin
|
5
|
-
# ..
|
6
|
-
# are comming from
|
7
|
-
dtk_require_common_commands('thor/push_clone_changes')
|
8
|
-
dtk_require_common_commands('thor/reparse')
|
9
|
-
dtk_require_common_commands('thor/common')
|
10
|
-
|
11
2
|
dtk_require_from_base('commands')
|
12
3
|
dtk_require_from_base("command_helper")
|
13
4
|
|
@@ -19,7 +10,6 @@ module DTK::Client
|
|
19
10
|
include PushCloneChangesMixin
|
20
11
|
include ReparseMixin
|
21
12
|
|
22
|
-
# For Rich: this is used for import-git
|
23
13
|
def from_git()
|
24
14
|
git_repo_url, module_name = retrieve_arguments([:option_1!, :option_2!])
|
25
15
|
namespace, local_module_name = get_namespace_and_name(module_name, ModuleUtil::NAMESPACE_SEPERATOR)
|
@@ -48,11 +38,6 @@ module DTK::Client
|
|
48
38
|
@context_params.forward_options(thor_options)
|
49
39
|
create_response = from_git_or_file()
|
50
40
|
|
51
|
-
if create_response.ok?
|
52
|
-
module_name, module_namespace, repo_url, branch, not_ok_response = workspace_branch_info(module_type, create_response.data['module_id'], create_response.data['version'])
|
53
|
-
create_response = not_ok_response if not_ok_response
|
54
|
-
end
|
55
|
-
|
56
41
|
unless create_response.ok?
|
57
42
|
delete_dir = namespace.nil? ? local_module_name : "#{namespace}/#{local_module_name}"
|
58
43
|
full_module_name = create_response.data[:full_module_name]
|
@@ -63,10 +48,10 @@ module DTK::Client
|
|
63
48
|
end
|
64
49
|
|
65
50
|
opts_pull = {
|
66
|
-
:local_branch => branch,
|
67
|
-
:namespace
|
51
|
+
:local_branch => @branch,
|
52
|
+
:namespace => @module_namespace
|
68
53
|
}
|
69
|
-
pull_response = Helper(:git_repo).pull_changes(module_type, module_name, opts_pull)
|
54
|
+
pull_response = Helper(:git_repo).pull_changes(module_type, @module_name, opts_pull)
|
70
55
|
return pull_response unless pull_response.ok?
|
71
56
|
|
72
57
|
if external_dependencies = create_response.data(:external_dependencies)
|
@@ -76,93 +61,46 @@ module DTK::Client
|
|
76
61
|
Response::Ok.new()
|
77
62
|
end
|
78
63
|
|
79
|
-
# For Rich: this is for import
|
80
64
|
def from_file()
|
81
65
|
module_type = @command.get_module_type(@context_params)
|
82
66
|
module_name = retrieve_arguments([:option_1!])
|
67
|
+
opts = {}
|
83
68
|
namespace, local_module_name = get_namespace_and_name(module_name, ModuleUtil::NAMESPACE_SEPERATOR)
|
84
|
-
opts = {}
|
85
69
|
|
86
70
|
response = from_git_or_file()
|
87
71
|
return response unless response.ok?
|
88
72
|
|
89
|
-
repo_obj = response.data['repo_obj']
|
90
|
-
module_final_dir = repo_obj.repo_dir
|
91
|
-
old_dir = response.data['old_dir']
|
92
|
-
new_module_name = response.data['new_module_name']
|
93
|
-
|
94
|
-
module_name, module_namespace, repo_url, branch, not_ok_response = workspace_branch_info(module_type, response.data['module_id'], response.data['version'])
|
95
|
-
return not_ok_response if not_ok_response
|
96
|
-
|
97
73
|
opts_pull = {
|
98
|
-
:local_branch => branch,
|
99
|
-
:namespace
|
74
|
+
:local_branch => @branch,
|
75
|
+
:namespace => @module_namespace
|
100
76
|
}
|
77
|
+
resp = Helper(:git_repo).pull_changes(module_type, @module_name, opts_pull)
|
78
|
+
return resp unless resp.ok?
|
101
79
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
dsl_updated_info = response.data(:dsl_updated_info)
|
107
|
-
if dsl_updated_info and !dsl_updated_info.empty?
|
108
|
-
new_commit_sha = dsl_updated_info[:commit_sha]
|
109
|
-
unless new_commit_sha and new_commit_sha == commit_sha
|
110
|
-
resp = Helper(:git_repo).pull_changes(module_type, module_name, opts_pull)
|
111
|
-
return resp unless resp.ok?
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
# For Aldin; wil update the server side to have dsl_created_info not have content when that is added on server side
|
116
|
-
# so setting acondition wrt to this and casing on this, i.e., whether need to commit file and then do push
|
117
|
-
# after we make sure working we can remove code that commits dsl file on client side
|
118
|
-
push_needed = false
|
119
|
-
if dsl_created_info and !dsl_created_info.empty?
|
120
|
-
path = dsl_created_info["path"]
|
121
|
-
msg = "A #{path} file has been created for you, located at #{module_final_dir}"
|
122
|
-
if content = dsl_created_info["content"]
|
123
|
-
resp = Helper(:git_repo).add_file(repo_obj, path, content, msg)
|
124
|
-
return resp unless resp.ok?
|
125
|
-
push_needed = true
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
##### code that does push that can be removed once we always do commit of dsl on server side
|
130
|
-
if push_needed
|
131
|
-
if external_dependencies
|
132
|
-
ambiguous = external_dependencies['ambiguous']||[]
|
133
|
-
possibly_missing = external_dependencies["possibly_missing"]||[]
|
134
|
-
opts.merge!(:set_parsed_false => true, :skip_module_ref_update => true) unless ambiguous.empty? && possibly_missing.empty?
|
135
|
-
end
|
136
|
-
|
137
|
-
@context_params.add_context_to_params(local_module_name, module_type.to_s.gsub!(/\_/,'-').to_sym, response.data['module_id'])
|
138
|
-
response = push_module_aux(@context_params, true, opts)
|
139
|
-
|
140
|
-
unless response.ok?
|
141
|
-
# remove new directory and leave the old one if import without namespace failed
|
142
|
-
if old_dir and (old_dir != module_final_dir)
|
143
|
-
FileUtils.rm_rf(module_final_dir) unless namespace
|
144
|
-
end
|
145
|
-
return response
|
146
|
-
end
|
80
|
+
if error = response.data(:dsl_parse_error)
|
81
|
+
dsl_parsed_message = ServiceImporter.error_message(module_name, error)
|
82
|
+
DTK::Client::OsUtil.print(dsl_parsed_message, :red)
|
147
83
|
end
|
148
|
-
##### end: code that does push
|
149
84
|
|
150
85
|
# remove source directory if no errors while importing
|
151
|
-
|
152
|
-
|
86
|
+
module_final_dir = @repo_obj.repo_dir
|
87
|
+
if @old_dir and (@old_dir != module_final_dir)
|
88
|
+
FileUtils.rm_rf(@old_dir) unless namespace
|
153
89
|
end
|
154
90
|
|
155
|
-
if external_dependencies
|
91
|
+
if external_dependencies = response.data(:external_dependencies)
|
156
92
|
print_external_dependencies(external_dependencies, 'dtk.model.yaml includes')
|
157
93
|
end
|
158
94
|
|
159
95
|
# if user do import from default directory (e.g. import ntp - without namespace) print message
|
160
|
-
DTK::Client::OsUtil.print("Module '#{new_module_name}' has been created and module directory moved to #{module_final_dir}",:yellow) unless namespace
|
96
|
+
DTK::Client::OsUtil.print("Module '#{@new_module_name}' has been created and module directory moved to #{module_final_dir}",:yellow) unless namespace
|
161
97
|
|
162
98
|
Response::Ok.new()
|
163
99
|
end
|
164
100
|
|
165
|
-
|
101
|
+
|
102
|
+
private
|
103
|
+
|
166
104
|
def from_git_or_file()
|
167
105
|
default_ns = @context_params.get_forwarded_options()[:default_namespace]
|
168
106
|
git_import = @context_params.get_forwarded_options()[:git_import]
|
@@ -171,7 +109,6 @@ module DTK::Client
|
|
171
109
|
module_name = @context_params.retrieve_arguments([name_option])
|
172
110
|
module_type = @command.get_module_type(@context_params)
|
173
111
|
version = @options["version"]
|
174
|
-
create_response = {}
|
175
112
|
|
176
113
|
# extract namespace and module_name from full name (r8:maven will result in namespace = r8 & name = maven)
|
177
114
|
namespace, local_module_name = get_namespace_and_name(module_name, ModuleUtil::NAMESPACE_SEPERATOR)
|
@@ -193,57 +130,55 @@ module DTK::Client
|
|
193
130
|
response = post(rest_url("#{module_type}/create"), post_body)
|
194
131
|
return response unless response.ok?
|
195
132
|
|
196
|
-
repo_url,repo_id,module_id,branch,new_module_name = response.data(:repo_url, :repo_id, :module_id, :workspace_branch, :full_module_name)
|
197
|
-
response = Helper(:git_repo).rename_and_initialize_clone_and_push(module_type.to_sym, local_module_name, new_module_name, branch, repo_url, module_directory)
|
133
|
+
repo_url, repo_id, @module_id, branch, @new_module_name = response.data(:repo_url, :repo_id, :module_id, :workspace_branch, :full_module_name)
|
134
|
+
response = Helper(:git_repo).rename_and_initialize_clone_and_push(module_type.to_sym, local_module_name, @new_module_name, branch, repo_url, module_directory)
|
198
135
|
return response unless (response && response.ok?)
|
199
136
|
|
200
|
-
repo_obj, commit_sha = response.data(:repo_obj, :commit_sha)
|
201
|
-
module_final_dir
|
202
|
-
old_dir = response.data[:old_dir]
|
137
|
+
@repo_obj, commit_sha = response.data(:repo_obj, :commit_sha)
|
138
|
+
module_final_dir = @repo_obj.repo_dir
|
139
|
+
@old_dir = response.data[:old_dir]
|
203
140
|
|
204
141
|
post_body = {
|
205
142
|
:repo_id => repo_id,
|
206
143
|
:commit_sha => commit_sha,
|
207
144
|
:commit_dsl => true,
|
208
145
|
:scaffold_if_no_dsl => true,
|
209
|
-
"#{module_type}_id".to_sym => module_id
|
146
|
+
"#{module_type}_id".to_sym => @module_id
|
210
147
|
}
|
148
|
+
|
149
|
+
# For Rich: DTK-1925
|
150
|
+
# we need to send :update_from_includes that will be used on server in /Users/aldin/Reactor8/server/application/model/module/base_module/update_module.rb:111
|
151
|
+
#
|
152
|
+
# this line bellow
|
211
153
|
post_body.merge!(:git_import => true) if git_import
|
154
|
+
# should be changed with this code:
|
155
|
+
# if git_import
|
156
|
+
# post_body.merge!(:git_import => true)
|
157
|
+
# else
|
158
|
+
# post_body.merge!(:update_from_includes => true)
|
159
|
+
# end
|
212
160
|
response = post(rest_url("#{module_type}/update_from_initial_create"), post_body)
|
213
161
|
|
214
162
|
unless response.ok?
|
215
|
-
response.set_data_hash({ :full_module_name => new_module_name })
|
163
|
+
response.set_data_hash({ :full_module_name => @new_module_name })
|
216
164
|
# remove new directory and leave the old one if import without namespace failed
|
217
|
-
if old_dir and (old_dir != module_final_dir)
|
165
|
+
if @old_dir and (@old_dir != module_final_dir)
|
218
166
|
FileUtils.rm_rf(module_final_dir) unless (namespace && git_import)
|
219
167
|
end
|
220
168
|
return response
|
221
169
|
end
|
222
170
|
|
223
|
-
dsl_updated_info
|
224
|
-
dsl_created_info
|
225
|
-
external_dependencies = response.data(:external_dependencies)
|
171
|
+
dsl_updated_info = response.data(:dsl_updated_info)
|
172
|
+
dsl_created_info = response.data(:dsl_created_info)
|
226
173
|
DTK::Client::OsUtil.print("A module_refs.yaml file has been created for you, located at #{module_final_dir}", :yellow) if dsl_updated_info && !dsl_updated_info.empty?
|
227
174
|
DTK::Client::OsUtil.print("A #{dsl_created_info["path"]} file has been created for you, located at #{module_final_dir}", :yellow) if dsl_created_info && !dsl_created_info.empty?
|
228
175
|
|
229
|
-
module_name, module_namespace, repo_url, branch, not_ok_response = workspace_branch_info(module_type, module_id, version)
|
176
|
+
@module_name, @module_namespace, repo_url, @branch, not_ok_response = workspace_branch_info(module_type, @module_id, version)
|
230
177
|
return not_ok_response if not_ok_response
|
231
178
|
|
232
|
-
# For Rich: did not have time today, but should find better way to pass these arguments to from_git and from_file methods
|
233
|
-
# For Aldin: are all these values needed in teh calling fns. ANyways anotehr way to do it is to just set instance vars so from here
|
234
|
-
# @module_id = module_id
|
235
|
-
# then calling fn coudl just use @module_id
|
236
|
-
response.add_data_value!(:module_id, module_id)
|
237
|
-
response.add_data_value!(:version, version)
|
238
|
-
response.add_data_value!(:repo_obj, repo_obj)
|
239
|
-
response.add_data_value!(:old_dir, old_dir)
|
240
|
-
response.add_data_value!(:new_module_name, new_module_name)
|
241
|
-
|
242
179
|
response
|
243
180
|
end
|
244
181
|
|
245
|
-
private
|
246
|
-
# ... the methods that represent the basic steps of from_git and from_git_or_file
|
247
182
|
end
|
248
183
|
end
|
249
184
|
end
|
@@ -21,8 +21,6 @@ PULL_CATALOGS = ["dtkn"]
|
|
21
21
|
|
22
22
|
module DTK::Client
|
23
23
|
class CommonModule
|
24
|
-
# TODO: For Aldin; looking to use nested file structure if helpers just relate to one file in common;
|
25
|
-
# example here is import which is helper for module.rb
|
26
24
|
dtk_require_common_commands('thor/module/import')
|
27
25
|
|
28
26
|
def initialize(command,context_params)
|
@@ -130,6 +128,15 @@ module DTK::Client
|
|
130
128
|
return nil unless is_go
|
131
129
|
end
|
132
130
|
|
131
|
+
post_body = {
|
132
|
+
"#{module_type}_id".to_sym => module_id
|
133
|
+
}
|
134
|
+
action = (version ? "delete_version" : "delete")
|
135
|
+
post_body[:version] = version if version
|
136
|
+
|
137
|
+
response = post(rest_url("#{module_type}/#{action}"), post_body)
|
138
|
+
return response unless response.ok?
|
139
|
+
|
133
140
|
response =
|
134
141
|
if options.purge? || method_opts[:purge]
|
135
142
|
opts = {:module_name => module_name}
|
@@ -143,15 +150,6 @@ module DTK::Client
|
|
143
150
|
|
144
151
|
return response unless response.ok?
|
145
152
|
|
146
|
-
post_body = {
|
147
|
-
"#{module_type}_id".to_sym => module_id
|
148
|
-
}
|
149
|
-
action = (version ? "delete_version" : "delete")
|
150
|
-
post_body[:version] = version if version
|
151
|
-
|
152
|
-
response = post(rest_url("#{module_type}/#{action}"), post_body)
|
153
|
-
return response unless response.ok?
|
154
|
-
|
155
153
|
unless method_opts[:no_error_msg]
|
156
154
|
msg = "Module '#{module_name}' "
|
157
155
|
if version then msg << "version #{version} has been deleted"
|
@@ -220,221 +218,11 @@ module DTK::Client
|
|
220
218
|
end
|
221
219
|
|
222
220
|
def import_git_module_aux(context_params)
|
223
|
-
|
224
|
-
# This would now be one top level call
|
225
|
-
# uncomment this out to se simple example
|
226
|
-
# CommonModule::Import.new(self,context_params).from_git()
|
227
|
-
|
228
|
-
git_repo_url, module_name = context_params.retrieve_arguments([:option_1!, :option_2!], method_argument_names)
|
229
|
-
namespace, local_module_name = get_namespace_and_name(module_name, ModuleUtil::NAMESPACE_SEPERATOR)
|
230
|
-
|
231
|
-
module_type = get_module_type(context_params)
|
232
|
-
thor_options = { :git_import => true}
|
233
|
-
|
234
|
-
unless namespace
|
235
|
-
resp = post rest_url("namespace/default_namespace_name")
|
236
|
-
return resp unless resp.ok?
|
237
|
-
|
238
|
-
namespace = resp.data
|
239
|
-
thor_options[:default_namespace] = namespace
|
240
|
-
end
|
241
|
-
|
242
|
-
opts = {
|
243
|
-
:namespace => namespace,
|
244
|
-
:branch => options['branch']
|
245
|
-
}
|
246
|
-
response = Helper(:git_repo).create_clone_from_optional_branch(module_type.to_sym, local_module_name, git_repo_url, opts)
|
247
|
-
return response unless response.ok?
|
248
|
-
|
249
|
-
# Remove .git directory to rid of git pointing to user's github
|
250
|
-
FileUtils.rm_rf("#{response['data']['module_directory']}/.git")
|
251
|
-
|
252
|
-
context_params.forward_options(thor_options)
|
253
|
-
create_response = import_module_aux(context_params)
|
254
|
-
|
255
|
-
if create_response.ok?
|
256
|
-
if external_dependencies = create_response.data(:external_dependencies)
|
257
|
-
inconsistent = external_dependencies["inconsistent"]||[]
|
258
|
-
possibly_missing = external_dependencies["possibly_missing"]||[]
|
259
|
-
ambiguous = external_dependencies["ambiguous"]||[]
|
260
|
-
amb_sorted = ambiguous.map { |k,v| "#{k.split('/').last} (#{v.join(', ')})" }
|
261
|
-
OsUtil.print("There are inconsistent module dependencies mentioned in the git repo: #{inconsistent.join(', ')}", :red) unless inconsistent.empty?
|
262
|
-
OsUtil.print("There are missing module dependencies mentioned in the git repo: #{possibly_missing.join(', ')}", :yellow) unless possibly_missing.empty?
|
263
|
-
OsUtil.print("There are ambiguous module dependencies mentioned in the git repo: '#{amb_sorted.join(', ')}'. One of the namespaces should be selected by editing the module_refs file", :yellow) if ambiguous && !ambiguous.empty?
|
264
|
-
end
|
265
|
-
else
|
266
|
-
delete_dir = namespace.nil? ? local_module_name : "#{namespace}/#{local_module_name}"
|
267
|
-
full_module_name = create_response.data[:full_module_name]
|
268
|
-
local_module_name = full_module_name.nil? ? delete_dir : full_module_name
|
269
|
-
delete_module_sub_aux(context_params, local_module_name, :force_delete => true, :no_error_msg => true, :purge => true)
|
270
|
-
return create_response
|
271
|
-
end
|
272
|
-
|
273
|
-
Response::Ok.new()
|
221
|
+
CommonModule::Import.new(self, context_params).from_git()
|
274
222
|
end
|
275
|
-
def import_module_aux(context_params)
|
276
|
-
# CommonModule::Import.new(self,context_params).from_file()
|
277
|
-
if context_params.get_forwarded_options()
|
278
|
-
default_ns = context_params.get_forwarded_options()[:default_namespace]
|
279
|
-
git_import = context_params.get_forwarded_options()[:git_import]
|
280
|
-
end
|
281
|
-
|
282
|
-
name_option = git_import ? :option_2! : :option_1!
|
283
|
-
module_name = context_params.retrieve_arguments([name_option],method_argument_names)
|
284
|
-
module_type = get_module_type(context_params)
|
285
|
-
version = options["version"]
|
286
|
-
opts = {}
|
287
|
-
|
288
|
-
# extract namespace and module_name from full name (r8:maven will result in namespace = r8 & name = maven)
|
289
|
-
namespace, local_module_name = get_namespace_and_name(module_name, ModuleUtil::NAMESPACE_SEPERATOR)
|
290
|
-
namespace = default_ns if default_ns && namespace.nil?
|
291
223
|
|
292
|
-
|
293
|
-
|
294
|
-
return response unless response.ok?
|
295
|
-
|
296
|
-
#check for yaml/json parsing errors before import
|
297
|
-
module_directory = response.data(:module_directory)
|
298
|
-
reparse_aux(module_directory)
|
299
|
-
|
300
|
-
# first make call to server to create an empty repo
|
301
|
-
post_body = {
|
302
|
-
:module_name => local_module_name,
|
303
|
-
:module_namespace => namespace
|
304
|
-
}
|
305
|
-
response = post(rest_url("#{module_type}/create"), post_body)
|
306
|
-
return response unless response.ok?
|
307
|
-
|
308
|
-
repo_url,repo_id,module_id,branch,new_module_name = response.data(:repo_url, :repo_id, :module_id, :workspace_branch, :full_module_name)
|
309
|
-
response = Helper(:git_repo).rename_and_initialize_clone_and_push(module_type.to_sym, local_module_name, new_module_name, branch, repo_url, module_directory)
|
310
|
-
return response unless (response && response.ok?)
|
311
|
-
|
312
|
-
repo_obj, commit_sha = response.data(:repo_obj, :commit_sha)
|
313
|
-
module_final_dir = repo_obj.repo_dir
|
314
|
-
old_dir = response.data[:old_dir]
|
315
|
-
|
316
|
-
post_body = {
|
317
|
-
:repo_id => repo_id,
|
318
|
-
:commit_sha => commit_sha,
|
319
|
-
:commit_dsl => true,
|
320
|
-
:scaffold_if_no_dsl => true,
|
321
|
-
"#{module_type}_id".to_sym => module_id
|
322
|
-
}
|
323
|
-
post_body.merge!(:git_import => true) if git_import
|
324
|
-
response = post(rest_url("#{module_type}/update_from_initial_create"), post_body)
|
325
|
-
|
326
|
-
if error = response.data(:dsl_parse_error)
|
327
|
-
dsl_parsed_message = ServiceImporter.error_message(module_name, error)
|
328
|
-
DTK::Client::OsUtil.print(dsl_parsed_message, :red)
|
329
|
-
end
|
330
|
-
|
331
|
-
unless response.ok?
|
332
|
-
response.set_data_hash({ :full_module_name => new_module_name })
|
333
|
-
# remove new directory and leave the old one if import without namespace failed
|
334
|
-
if old_dir and (old_dir != module_final_dir)
|
335
|
-
FileUtils.rm_rf(module_final_dir) unless (namespace && git_import)
|
336
|
-
end
|
337
|
-
return response
|
338
|
-
end
|
339
|
-
|
340
|
-
dsl_updated_info = response.data(:dsl_updated_info)
|
341
|
-
dsl_created_info = response.data(:dsl_created_info)
|
342
|
-
external_dependencies = response.data(:external_dependencies)
|
343
|
-
DTK::Client::OsUtil.print("A module_refs.yaml file has been created for you, located at #{module_final_dir}", :yellow) if dsl_updated_info && !dsl_updated_info.empty?
|
344
|
-
DTK::Client::OsUtil.print("A #{dsl_created_info["path"]} file has been created for you, located at #{module_final_dir}", :yellow) if dsl_created_info && !dsl_created_info.empty?
|
345
|
-
|
346
|
-
module_name, module_namespace, repo_url, branch, not_ok_response = workspace_branch_info(module_type, module_id, version)
|
347
|
-
return not_ok_response if not_ok_response
|
348
|
-
|
349
|
-
opts_pull = {
|
350
|
-
:local_branch => branch,
|
351
|
-
:namespace => module_namespace
|
352
|
-
}
|
353
|
-
|
354
|
-
# if import-git then always pull changes because files are created on server side
|
355
|
-
if git_import
|
356
|
-
resp = Helper(:git_repo).pull_changes(module_type, module_name, opts_pull)
|
357
|
-
return resp unless resp.ok?
|
358
|
-
response[:module_id] = module_id
|
359
|
-
else
|
360
|
-
# For Aldin; I think all code below this is just for import for file; so think we reorganize to have evrything above this be a common
|
361
|
-
# routine called by both; and then put in new method for 'import from file' that calss common , whcih passes back response
|
362
|
-
# and then calls the rest in the 'import from file' body
|
363
|
-
|
364
|
-
# since we are creating module_refs and dtk,,odel.yaml files on server need to pull
|
365
|
-
dsl_updated_info = response.data(:dsl_updated_info)
|
366
|
-
if dsl_updated_info and !dsl_updated_info.empty?
|
367
|
-
new_commit_sha = dsl_updated_info[:commit_sha]
|
368
|
-
unless new_commit_sha and new_commit_sha == commit_sha
|
369
|
-
resp = Helper(:git_repo).pull_changes(module_type, module_name, opts_pull)
|
370
|
-
return resp unless resp.ok?
|
371
|
-
end
|
372
|
-
end
|
373
|
-
|
374
|
-
# For Aldin; wil update the server side to have dsl_created_info not have content when that is added on server side
|
375
|
-
# so setting acondition wrt to this and casing on this, i.e., whether need to commit file and then do push
|
376
|
-
# after we make sure working we can remove code that commits dsl file on client side
|
377
|
-
push_needed = false
|
378
|
-
if dsl_created_info and !dsl_created_info.empty?
|
379
|
-
path = dsl_created_info["path"]
|
380
|
-
msg = "A #{path} file has been created for you, located at #{module_final_dir}"
|
381
|
-
if content = dsl_created_info["content"]
|
382
|
-
resp = Helper(:git_repo).add_file(repo_obj, path, content, msg)
|
383
|
-
return resp unless resp.ok?
|
384
|
-
push_needed = true
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
|
-
##### code that does push that can be removed once we always do commit of dsl on server side
|
389
|
-
if push_needed
|
390
|
-
if external_dependencies
|
391
|
-
ambiguous = external_dependencies['ambiguous']||[]
|
392
|
-
possibly_missing = external_dependencies["possibly_missing"]||[]
|
393
|
-
opts.merge!(:set_parsed_false => true, :skip_module_ref_update => true) unless ambiguous.empty? && possibly_missing.empty?
|
394
|
-
end
|
395
|
-
|
396
|
-
context_params.add_context_to_params(local_module_name, module_type.to_s.gsub!(/\_/,'-').to_sym, module_id)
|
397
|
-
response = push_module_aux(context_params, true, opts)
|
398
|
-
|
399
|
-
if error = response.data(:dsl_parse_error)
|
400
|
-
dsl_parsed_message = ServiceImporter.error_message(module_name, error)
|
401
|
-
DTK::Client::OsUtil.print(dsl_parsed_message, :red)
|
402
|
-
end
|
403
|
-
|
404
|
-
unless response.ok?
|
405
|
-
# remove new directory and leave the old one if import without namespace failed
|
406
|
-
if old_dir and (old_dir != module_final_dir)
|
407
|
-
FileUtils.rm_rf(module_final_dir) unless namespace
|
408
|
-
end
|
409
|
-
return response
|
410
|
-
end
|
411
|
-
end
|
412
|
-
##### end: code that does push
|
413
|
-
|
414
|
-
response = Response::Ok.new()
|
415
|
-
|
416
|
-
# remove source directory if no errors while importing
|
417
|
-
if old_dir and (old_dir != module_final_dir)
|
418
|
-
FileUtils.rm_rf(old_dir) unless namespace
|
419
|
-
end
|
420
|
-
|
421
|
-
# For Aldin: need to also check to see if any parsing errors by looking at what is now in response under dsl_parse_error
|
422
|
-
# (it was just renamed from dsl_parse_info)
|
423
|
-
|
424
|
-
if external_dependencies
|
425
|
-
ambiguous = external_dependencies["ambiguous"]||[]
|
426
|
-
amb_sorted = ambiguous.map { |k,v| "#{k.split('/').last} (#{v.join(', ')})" }
|
427
|
-
possibly_missing = external_dependencies["possibly_missing"]||[]
|
428
|
-
OsUtil.print("There are missing module dependencies in dtk.model.yaml includes: #{possibly_missing.join(', ')}", :yellow) unless possibly_missing.empty?
|
429
|
-
OsUtil.print("There are ambiguous module dependencies in dtk.model.yaml includes: '#{amb_sorted.join(', ')}'. One of the namespaces should be selected by editing the module_refs file", :yellow) unless ambiguous.empty?
|
430
|
-
end
|
431
|
-
|
432
|
-
# if user do import from default directory (e.g. import ntp - without namespace) print message
|
433
|
-
# module directory moved from (~/dtk/component_module/<module_name>) to (~/dtk/component_module/<default_namespace>/<module_name>)
|
434
|
-
DTK::Client::OsUtil.print("Module '#{new_module_name}' has been created and module directory moved to #{module_final_dir}",:yellow) unless namespace
|
435
|
-
end
|
436
|
-
|
437
|
-
response
|
224
|
+
def import_module_aux(context_params)
|
225
|
+
CommonModule::Import.new(self,context_params).from_file()
|
438
226
|
end
|
439
227
|
|
440
228
|
def install_module_aux(context_params)
|
@@ -654,7 +442,7 @@ module DTK::Client
|
|
654
442
|
# if catalog.to_s.eql?("origin")
|
655
443
|
# push_clone_changes_aux(:component_module,component_module_id,version,options["message"]||DEFAULT_COMMIT_MSG,internal_trigger)
|
656
444
|
if catalog.to_s.eql?("dtkn")
|
657
|
-
module_refs_content = RemoteDependencyUtil.module_ref_content(module_location) if module_type ==
|
445
|
+
module_refs_content = RemoteDependencyUtil.module_ref_content(module_location) if module_type == 'service_module'
|
658
446
|
remote_module_info = get_remote_module_info_aux(module_type.to_sym, module_id, options["namespace"], version, module_refs_content, local_namespace)
|
659
447
|
return remote_module_info unless remote_module_info.ok?
|
660
448
|
|
@@ -733,7 +521,6 @@ module DTK::Client
|
|
733
521
|
assembly_template_location = "#{module_location}/assemblies/#{assembly_template_name}"
|
734
522
|
base_file = "#{module_location}/assemblies/#{assembly_template_name}.dtk.assembly"
|
735
523
|
|
736
|
-
# Aldin: could not find better solution, leaving as is for now
|
737
524
|
assembly_file_location =
|
738
525
|
if File.exists?("#{base_file}.yaml")
|
739
526
|
"#{base_file}.yaml"
|