dtk-client 0.5.17 → 0.5.18
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 +8 -8
- data/lib/command_helpers/git_repo.rb +82 -48
- data/lib/command_helpers/service_importer.rb +26 -17
- data/lib/command_helpers/test_module_creator.rb +6 -5
- data/lib/commands/common/thor/access_control.rb +5 -4
- data/lib/commands/common/thor/assembly_template.rb +75 -0
- data/lib/commands/common/thor/assembly_workspace.rb +86 -71
- data/lib/commands/common/thor/clone.rb +9 -7
- data/lib/commands/common/thor/common.rb +17 -10
- data/lib/commands/common/thor/edit.rb +65 -6
- data/lib/commands/common/thor/list_diffs.rb +4 -3
- data/lib/commands/common/thor/module.rb +86 -89
- data/lib/commands/common/thor/pull_clone_changes.rb +3 -2
- data/lib/commands/common/thor/pull_from_remote.rb +9 -5
- data/lib/commands/common/thor/purge_clone.rb +2 -2
- data/lib/commands/common/thor/push_clone_changes.rb +39 -16
- data/lib/commands/common/thor/push_to_remote.rb +3 -3
- data/lib/commands/thor/account.rb +16 -4
- data/lib/commands/thor/assembly.rb +66 -89
- data/lib/commands/thor/component_module.rb +40 -24
- data/lib/commands/thor/node.rb +7 -0
- data/lib/commands/thor/provider.rb +45 -23
- data/lib/commands/thor/service.rb +4 -7
- data/lib/commands/thor/service_module.rb +45 -20
- data/lib/commands/thor/test_module.rb +36 -22
- data/lib/commands/thor/workspace.rb +6 -6
- data/lib/core.rb +18 -17
- data/lib/domain/git_adapter.rb +30 -9
- data/lib/dtk-client/version.rb +1 -1
- data/lib/parser/adapters/thor.rb +47 -25
- data/lib/shell/context.rb +10 -2
- data/lib/shell.rb +18 -12
- data/lib/util/module_util.rb +41 -0
- data/lib/util/os_util.rb +25 -7
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Y2MwM2Q0NGFmOTdhNmZiYzUzMWNjMGNkMTg4YzM1YWFlN2Y2ZjJlMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTY2OWU3ODA4OGFlZTAwMDZlNmUwOGNiMDA3MzVjZWJlYTk4ZjlmNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmIxYjQ4ZGVhMDRlYjViODI5YzdjOTgzNjlmYTI5M2Y1NTdkOTc3YTEzZjk3
|
10
|
+
YmM2ZjRhYjVkODFmNjQwODRmMjdkZjRmMzY1ZmYyZGMxYzg4ZWM5MWE3MWIy
|
11
|
+
ZjdlODEyMTIwOWFmM2ViYTUyMzZkMTFmNDU4ZGQ5MGU2ZDg1NTQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZWZkYjM2MzIzNmU5NGNlOTA0YTU3Zjk4NzU1MWU0ZDZlOGRmMTllYTFlM2U5
|
14
|
+
NjVlYjEzNzZkZTJjMzllYzg5ZWQzMmFmYThmM2U4MTM3MGNhYmE2M2UxMWYz
|
15
|
+
NTViYjlmNjAyOGViMjUyOTVmMjMyNGRhOWU3ZDNjMTNiZTdjZDg=
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# This code is predciated on assumption that they is only one local branch (with with documented exceptions)
|
2
|
+
# so checkout branch is not done in most cases
|
3
|
+
#TODO : make sure all functions that use local_repo_dir( inside pass in full_moudle_name, not just module_name
|
1
4
|
require 'fileutils'
|
2
5
|
dtk_require("../domain/git_adapter")
|
3
6
|
dtk_require("../domain/git_error_handler")
|
@@ -6,17 +9,20 @@ module DTK; module Client; class CommandHelper
|
|
6
9
|
class GitRepo < self; class << self
|
7
10
|
|
8
11
|
def create(repo_dir,branch=nil,opts={})
|
9
|
-
GitAdapter.new(repo_dir,branch
|
12
|
+
GitAdapter.new(repo_dir,branch)
|
10
13
|
end
|
11
14
|
|
12
|
-
def create_clone_with_branch(type, module_name, repo_url, branch=nil, version=nil, opts={})
|
15
|
+
def create_clone_with_branch(type, module_name, repo_url, branch=nil, version=nil, module_namespace=nil, opts={})
|
13
16
|
Response.wrap_helper_actions do
|
14
|
-
|
17
|
+
full_name = module_namespace ? ModuleUtil.resolve_name(module_name, module_namespace) : module_name
|
18
|
+
|
19
|
+
modules_dir = modules_dir(type,full_name,version,opts)
|
15
20
|
FileUtils.mkdir_p(modules_dir) unless File.directory?(modules_dir)
|
16
|
-
target_repo_dir = local_repo_dir(type,
|
21
|
+
target_repo_dir = local_repo_dir(type,full_name,version,opts)
|
22
|
+
|
17
23
|
opts = {}
|
18
24
|
opts = { :branch => branch } if branch
|
19
|
-
begin
|
25
|
+
begin
|
20
26
|
GitAdapter.clone(repo_url, target_repo_dir, opts[:branch])
|
21
27
|
rescue => e
|
22
28
|
# Handling Git error messages with more user friendly messages
|
@@ -27,7 +33,7 @@ module DTK; module Client; class CommandHelper
|
|
27
33
|
error_msg = "Clone to directory (#{target_repo_dir}) failed"
|
28
34
|
|
29
35
|
DtkLogger.instance.error_pp(e.message, e.backtrace)
|
30
|
-
|
36
|
+
|
31
37
|
raise ErrorUsage.new(error_msg,:log_error=>false)
|
32
38
|
end
|
33
39
|
{"module_directory" => target_repo_dir}
|
@@ -44,16 +50,6 @@ module DTK; module Client; class CommandHelper
|
|
44
50
|
end
|
45
51
|
end
|
46
52
|
|
47
|
-
def local_clone_dir_exists?(type,module_name,version=nil)
|
48
|
-
ret = local_repo_dir(type,module_name,version)
|
49
|
-
File.directory?(ret) && ret
|
50
|
-
end
|
51
|
-
def local_clone_exists?(type,module_name,version=nil)
|
52
|
-
repo_dir = local_repo_dir(type,module_name,version)
|
53
|
-
ret = "#{repo_dir}/.git"
|
54
|
-
File.directory?(ret) && ret
|
55
|
-
end
|
56
|
-
|
57
53
|
#opts can have the following keys
|
58
54
|
#
|
59
55
|
#:remote_repo
|
@@ -62,9 +58,9 @@ module DTK; module Client; class CommandHelper
|
|
62
58
|
#:local_branch
|
63
59
|
#:no_fetch
|
64
60
|
#
|
65
|
-
def push_changes(type,
|
61
|
+
def push_changes(type,full_module_name,version,opts={})
|
66
62
|
Response.wrap_helper_actions() do
|
67
|
-
repo_dir = local_repo_dir(type,
|
63
|
+
repo_dir = local_repo_dir(type,full_module_name,version,opts)
|
68
64
|
repo = create(repo_dir,opts[:local_branch])
|
69
65
|
push_repo_changes_aux(repo,opts)
|
70
66
|
end
|
@@ -78,33 +74,51 @@ module DTK; module Client; class CommandHelper
|
|
78
74
|
end
|
79
75
|
end
|
80
76
|
|
81
|
-
#opts can have the following keys
|
82
|
-
#
|
83
|
-
#:remote_repo
|
84
|
-
#:remote_branch
|
85
|
-
#:remote_repo_url
|
86
|
-
#:local_branch
|
87
|
-
#:version
|
88
|
-
#:commit_sha
|
77
|
+
# opts can have the following keys
|
89
78
|
#
|
79
|
+
# :remote_repo
|
80
|
+
# :remote_branch
|
81
|
+
# :remote_repo_url
|
82
|
+
# :local_branch
|
83
|
+
# :version
|
84
|
+
# :commit_sha
|
85
|
+
# :full_module_name
|
86
|
+
# :namespace
|
90
87
|
# returns:
|
91
88
|
# { :diffs => , :commit_sha => }
|
92
89
|
def pull_changes(type,module_name,opts={})
|
93
90
|
Response.wrap_helper_actions() do
|
94
|
-
|
91
|
+
full_module_name = full_module_name(module_name,opts)
|
92
|
+
repo_dir = local_repo_dir(type,full_module_name,opts[:version],opts)
|
95
93
|
repo = create(repo_dir,opts[:local_branch])
|
96
94
|
response = pull_repo_changes_aux(repo,opts)
|
97
95
|
response
|
98
96
|
end
|
99
97
|
end
|
100
98
|
def pull_changes?(type,module_name,opts={})
|
101
|
-
if
|
99
|
+
if local_clone_dir_exists?(type,module_name,opts)
|
102
100
|
pull_changes(type,module_name,opts)
|
103
101
|
else
|
104
|
-
Response.wrap_helper_actions()
|
102
|
+
Response.wrap_helper_actions()
|
105
103
|
end
|
106
104
|
end
|
107
105
|
|
106
|
+
# opts can have the following keys
|
107
|
+
#
|
108
|
+
# :version
|
109
|
+
# :full_module_name
|
110
|
+
# :namespace
|
111
|
+
def local_clone_dir_exists?(type,module_name,opts={})
|
112
|
+
full_module_name = full_module_name(module_name,opts)
|
113
|
+
ret = local_repo_dir(type,full_module_name,opts[:version])
|
114
|
+
File.directory?(ret) && ret
|
115
|
+
end
|
116
|
+
|
117
|
+
def full_module_name(module_name,opts)
|
118
|
+
opts[:full_module_name] || ModuleUtil.resolve_name(module_name, opts[:namespace])
|
119
|
+
end
|
120
|
+
private :full_module_name
|
121
|
+
|
108
122
|
def synchronize_clone(type,module_name,commit_sha,opts={})
|
109
123
|
pull_changes?(type,module_name,{:commit_sha => commit_sha}.merge(opts))
|
110
124
|
Response::Ok.new()
|
@@ -121,13 +135,14 @@ module DTK; module Client; class CommandHelper
|
|
121
135
|
end
|
122
136
|
end
|
123
137
|
|
124
|
-
def check_local_dir_exists_with_content(type,module_name,version=nil)
|
138
|
+
def check_local_dir_exists_with_content(type,module_name,version=nil,module_namespace=nil)
|
139
|
+
full_module_name = ModuleUtil.join_name(module_name, module_namespace)
|
125
140
|
Response.wrap_helper_actions() do
|
126
141
|
ret = Hash.new
|
127
|
-
local_repo_dir = local_repo_dir(type,
|
128
|
-
|
142
|
+
local_repo_dir = local_repo_dir(type,full_module_name,version)
|
143
|
+
|
129
144
|
unless File.directory?(local_repo_dir)
|
130
|
-
raise ErrorUsage.new("The content for module (#{
|
145
|
+
raise ErrorUsage.new("The content for module (#{full_module_name}) should be put in directory (#{local_repo_dir})")
|
131
146
|
end
|
132
147
|
|
133
148
|
# transfered this part to initialize_client_clone_and_push because if we remove .git folder and
|
@@ -143,14 +158,33 @@ module DTK; module Client; class CommandHelper
|
|
143
158
|
# end
|
144
159
|
|
145
160
|
if Dir["#{local_repo_dir}/*"].empty?
|
146
|
-
raise ErrorUsage.new("Directory (#{local_repo_dir}) must have ths initial content for module (#{
|
161
|
+
raise ErrorUsage.new("Directory (#{local_repo_dir}) must have ths initial content for module (#{full_module_name})")
|
147
162
|
end
|
148
163
|
{"module_directory" => local_repo_dir}
|
149
164
|
end
|
150
165
|
end
|
151
166
|
|
167
|
+
def rename_and_initialize_clone_and_push(type, module_name, new_module_name, branch, repo_url, local_repo_dir, version = nil)
|
168
|
+
|
169
|
+
# check to see if the new dir has proper naming e.g. (~/dtk/component_modules/dtk::java)
|
170
|
+
unless local_repo_dir.match(/\/#{new_module_name.gsub(ModuleUtil::NAMESPACE_SEPERATOR,'/')}$/)
|
171
|
+
old_dir = local_repo_dir
|
172
|
+
new_dir = local_repo_dir.gsub(/#{module_name}$/, new_module_name.split(ModuleUtil::NAMESPACE_SEPERATOR).join('/'))
|
173
|
+
|
174
|
+
# creates directory if missing
|
175
|
+
parent_path = new_dir.gsub(/(\/\w+)$/,'')
|
176
|
+
FileUtils::mkdir_p(parent_path) unless File.directory?(parent_path)
|
177
|
+
FileUtils.mv(old_dir, new_dir)
|
178
|
+
else
|
179
|
+
new_dir = local_repo_dir
|
180
|
+
end
|
181
|
+
|
182
|
+
# Continue push
|
183
|
+
initialize_client_clone_and_push(type, new_module_name, branch, repo_url, new_dir, version)
|
184
|
+
end
|
185
|
+
|
152
186
|
# makes repo_dir (determined from type and module_name) into a git dir, pulls, adds, content and then pushes
|
153
|
-
def initialize_client_clone_and_push(type,module_name,branch,repo_url,local_repo_dir,version=nil)
|
187
|
+
def initialize_client_clone_and_push(type, module_name, branch, repo_url, local_repo_dir, version=nil)
|
154
188
|
# moved this part from 'check_local_dir_exists_with_content' to this method since this only deletes .git folder
|
155
189
|
# which can cause us problems if import fails
|
156
190
|
if File.directory?("#{local_repo_dir}/.git")
|
@@ -161,7 +195,7 @@ module DTK; module Client; class CommandHelper
|
|
161
195
|
end
|
162
196
|
# we return to normal flow, since .git dir is removed
|
163
197
|
end
|
164
|
-
|
198
|
+
|
165
199
|
Response.wrap_helper_actions() do
|
166
200
|
ret = Hash.new
|
167
201
|
repo_dir = local_repo_dir(type,module_name)
|
@@ -186,7 +220,7 @@ module DTK; module Client; class CommandHelper
|
|
186
220
|
def self.new_version(repo)
|
187
221
|
new(repo.new_version())
|
188
222
|
end
|
189
|
-
|
223
|
+
|
190
224
|
def self.diff(repo,local_branch,remote_reference)
|
191
225
|
new(repo.diff_summary(local_branch,remote_reference))
|
192
226
|
end
|
@@ -206,7 +240,7 @@ module DTK; module Client; class CommandHelper
|
|
206
240
|
changes
|
207
241
|
end
|
208
242
|
end
|
209
|
-
|
243
|
+
|
210
244
|
#returns hash with keys
|
211
245
|
#: diffs - hash with diffs
|
212
246
|
# commit_sha - sha of currenet_commit
|
@@ -215,7 +249,7 @@ module DTK; module Client; class CommandHelper
|
|
215
249
|
|
216
250
|
# adding untracked files (newly added files)
|
217
251
|
repo.stage_changes()
|
218
|
-
|
252
|
+
|
219
253
|
# commit if there has been changes
|
220
254
|
if repo.changed?
|
221
255
|
repo.commit(opts[:commit_msg]||"Pushing changes from client") #TODO: make more descriptive
|
@@ -224,12 +258,12 @@ module DTK; module Client; class CommandHelper
|
|
224
258
|
if opts[:remote_repo] and opts[:remote_repo_url]
|
225
259
|
repo.add_remote(opts[:remote_repo],opts[:remote_repo_url])
|
226
260
|
end
|
227
|
-
|
261
|
+
|
228
262
|
unless opts[:no_fetch]
|
229
263
|
repo.fetch(remote(opts[:remote_repo]))
|
230
264
|
end
|
231
265
|
|
232
|
-
local_branch = repo.
|
266
|
+
local_branch = repo.local_branch_name
|
233
267
|
|
234
268
|
remote_branch_ref = remote_branch_ref(local_branch, opts)
|
235
269
|
|
@@ -251,7 +285,7 @@ module DTK; module Client; class CommandHelper
|
|
251
285
|
|
252
286
|
diffs = DiffSummary.diff(repo,local_branch, remote_branch_ref)
|
253
287
|
|
254
|
-
|
288
|
+
|
255
289
|
if diffs.any_diffs?()
|
256
290
|
repo.push(remote_branch_ref)
|
257
291
|
end
|
@@ -277,14 +311,14 @@ module DTK; module Client; class CommandHelper
|
|
277
311
|
repo.fetch(remote(opts[:remote_repo]))
|
278
312
|
end
|
279
313
|
|
280
|
-
local_branch = repo.
|
314
|
+
local_branch = repo.local_branch_name
|
281
315
|
|
282
316
|
remote_branch_ref = remote_branch_ref(local_branch, opts)
|
283
317
|
|
284
318
|
commit_shas = Hash.new
|
285
319
|
merge_rel = repo.merge_relationship(:remote_branch,remote_branch_ref, :ret_commit_shas => commit_shas)
|
286
320
|
commit_sha = nil
|
287
|
-
|
321
|
+
|
288
322
|
if merge_rel == :equal
|
289
323
|
commit_sha = commit_shas[:other_sha]
|
290
324
|
elsif merge_rel == :no_remote_ref
|
@@ -295,7 +329,7 @@ module DTK; module Client; class CommandHelper
|
|
295
329
|
# diffs = DiffSummary.diff_remote(repo,"remotes/#{remote_branch_ref}")
|
296
330
|
diffs = DiffSummary.diff(repo,local_branch, remote_branch_ref)
|
297
331
|
commit_sha = repo.find_remote_sha(remote_branch_ref)
|
298
|
-
|
332
|
+
|
299
333
|
{"diffs" => diffs, "commit_sha" => commit_sha, "repo_obj" => repo, "status" => repo.local_summary() }
|
300
334
|
end
|
301
335
|
|
@@ -313,7 +347,7 @@ module DTK; module Client; class CommandHelper
|
|
313
347
|
|
314
348
|
repo.fetch(remote(opts[:remote_repo]))
|
315
349
|
|
316
|
-
local_branch = repo.
|
350
|
+
local_branch = repo.local_branch_name
|
317
351
|
remote_branch_ref = remote_branch_ref(local_branch,opts)
|
318
352
|
|
319
353
|
if opts[:hard_reset]
|
@@ -377,8 +411,8 @@ module DTK; module Client; class CommandHelper
|
|
377
411
|
end
|
378
412
|
end
|
379
413
|
|
380
|
-
def local_repo_dir(type,
|
381
|
-
OsUtil.module_location(type,
|
414
|
+
def local_repo_dir(type,full_module_name,version=nil,opts={})
|
415
|
+
OsUtil.module_location(type,full_module_name,version,opts)
|
382
416
|
end
|
383
417
|
|
384
418
|
def adapter_class()
|
@@ -1,9 +1,9 @@
|
|
1
1
|
dtk_require_from_base('configurator')
|
2
2
|
module DTK::Client
|
3
3
|
#
|
4
|
-
# Main purpose of this module is to recognize which local modules are missing based on
|
4
|
+
# Main purpose of this module is to recognize which local modules are missing based on
|
5
5
|
# name, namespace, version and for those missing component module module will call
|
6
|
-
# module#clone and module#import_dtkn method to get missing component modules
|
6
|
+
# module#clone and module#import_dtkn method to get missing component modules
|
7
7
|
#
|
8
8
|
module ServiceImporter
|
9
9
|
def create_missing_clone_dirs()
|
@@ -18,7 +18,7 @@ module DTK::Client
|
|
18
18
|
##
|
19
19
|
# Method will trigger import for each missing module component
|
20
20
|
#
|
21
|
-
def trigger_module_component_import(missing_component_list,opts={})
|
21
|
+
def trigger_module_component_import(missing_component_list, required_components, opts={})
|
22
22
|
puts "Auto-importing missing component module(s)"
|
23
23
|
does_not_exist, modules_to_import = validate_missing_components(missing_component_list)
|
24
24
|
|
@@ -27,7 +27,13 @@ module DTK::Client
|
|
27
27
|
OsUtil.print("You do no have access to component modules '#{module_names}' required by service module, or they do not exist on repo manager and will not be imported!", :yellow)
|
28
28
|
return false unless Console.confirmation_prompt("Do you want to continue with import of available component modules and service module"+'?')
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
|
+
required_components.each do |r_module|
|
32
|
+
module_name = "#{r_module['namespace']}/#{r_module['name']}"
|
33
|
+
module_name += "-#{r_module['version']}" if r_module['version']
|
34
|
+
print "Using component module '#{module_name}'\n"
|
35
|
+
end
|
36
|
+
|
31
37
|
modules_to_import.each do |m_module|
|
32
38
|
module_name = "#{m_module['namespace']}/#{m_module['name']}"
|
33
39
|
module_name += "-#{m_module['version']}" if m_module['version']
|
@@ -38,9 +44,9 @@ module DTK::Client
|
|
38
44
|
|
39
45
|
response = ContextRouter.routeTask("component_module", "install", new_context_params, @conn)
|
40
46
|
puts(response.data(:does_not_exist) ? response.data(:does_not_exist) : "Done.")
|
41
|
-
raise DTK::Client::DtkError, response.error_message unless response.ok?
|
47
|
+
raise DTK::Client::DtkError, response.error_message unless response.ok?
|
42
48
|
end
|
43
|
-
|
49
|
+
|
44
50
|
Response::Ok.new()
|
45
51
|
end
|
46
52
|
|
@@ -78,21 +84,24 @@ module DTK::Client
|
|
78
84
|
def resolve_missing_components(service_module_id, service_module_name, namespace_to_use, force_clone=false)
|
79
85
|
# Get dependency component modules and cross reference them with local component modules
|
80
86
|
module_component_list = post rest_url("service_module/list_component_modules"), { :service_module_id => service_module_id }
|
87
|
+
|
81
88
|
local_modules, needed_modules = OsUtil.local_component_module_list(), Array.new
|
82
89
|
|
83
90
|
if module_component_list
|
84
|
-
module_component_list.data.each do |
|
85
|
-
|
86
|
-
|
91
|
+
module_component_list.data.each do |cmp_module|
|
92
|
+
with_namespace = ModuleUtil.resolve_name(cmp_module["display_name"],cmp_module["namespace_name"])
|
93
|
+
formated_name = add_version?(with_namespace, cmp_module['version'])
|
94
|
+
unless local_modules.include?(formated_name)
|
95
|
+
needed_modules << cmp_module.merge({'formated_name' => formated_name})
|
87
96
|
end
|
88
97
|
end
|
89
98
|
end
|
90
99
|
|
91
100
|
unless needed_modules.empty?
|
92
|
-
puts "Service '#{service_module_name}'
|
93
|
-
needed_modules.each { |m| puts " - #{m['formated_name']}" }
|
101
|
+
# puts "Service '#{service_module_name}' does not have the following component modules dependencies on the client machine: \n\n"
|
102
|
+
# needed_modules.each { |m| puts " - #{m['formated_name']}" }
|
94
103
|
is_install_dependencies = true
|
95
|
-
is_install_dependencies = Console.confirmation_prompt("\nDo you want to clone missing component
|
104
|
+
# is_install_dependencies = Console.confirmation_prompt("\nDo you want to clone these missing component modules to the client machine?") unless force_clone
|
96
105
|
|
97
106
|
# we get list of modules available on server
|
98
107
|
|
@@ -101,7 +110,7 @@ module DTK::Client
|
|
101
110
|
if is_install_dependencies
|
102
111
|
needed_modules.each do |m|
|
103
112
|
formated_name = m['formated_name']
|
104
|
-
print "Cloning component module '#{formated_name}' from server ... "
|
113
|
+
# print "Cloning component module '#{formated_name}' from server ... "
|
105
114
|
thor_options = {}
|
106
115
|
thor_options["version"] = m['version']
|
107
116
|
thor_options["skip_edit"] = true
|
@@ -109,9 +118,9 @@ module DTK::Client
|
|
109
118
|
thor_options.merge!(:module_type => 'component-module')
|
110
119
|
new_context_params = ::DTK::Shell::ContextParams.new
|
111
120
|
new_context_params.forward_options(thor_options)
|
112
|
-
new_context_params.add_context_to_params(formated_name, :"component-module", m['id'])
|
121
|
+
new_context_params.add_context_to_params(formated_name, :"component-module", m['id'])
|
113
122
|
response = ContextRouter.routeTask("component_module", "clone", new_context_params, @conn)
|
114
|
-
puts "Done."
|
123
|
+
# puts "Done."
|
115
124
|
end
|
116
125
|
end
|
117
126
|
end
|
@@ -125,13 +134,13 @@ module DTK::Client
|
|
125
134
|
def resolve_module_names(e)
|
126
135
|
versions = (e['version'] ? e['version'].split(',') : ['CURRENT'])
|
127
136
|
|
128
|
-
versions.collect { |version|
|
137
|
+
versions.collect { |version| add_version?(e['display_name'], version)}
|
129
138
|
end
|
130
139
|
|
131
140
|
# Resolves local module name
|
132
141
|
#
|
133
142
|
# Returns: String
|
134
|
-
def
|
143
|
+
def add_version?(display_name, version)
|
135
144
|
version = nil if 'CURRENT'.eql?(version)
|
136
145
|
(version ? "#{display_name}-#{version.strip}" : "#{display_name}")
|
137
146
|
end
|
@@ -8,14 +8,15 @@ module DTK::Client
|
|
8
8
|
Response.wrap_helper_actions do
|
9
9
|
modules_dir = OsUtil.test_clone_location()
|
10
10
|
FileUtils.mkdir_p(modules_dir) unless File.directory?(modules_dir)
|
11
|
+
module_name = ModuleUtil.filter_module_name(module_name)
|
11
12
|
target_repo_dir = OsUtil.module_location(type,module_name)
|
12
13
|
begin
|
13
|
-
FileUtils.mkdir(target_repo_dir)
|
14
|
+
FileUtils.mkdir(target_repo_dir)
|
14
15
|
generate_model(module_name, target_repo_dir)
|
15
|
-
generate_serverspec_files(module_name, target_repo_dir)
|
16
|
+
generate_serverspec_files(module_name, target_repo_dir)
|
16
17
|
rescue => e
|
17
18
|
error_msg = "Create of directory (#{target_repo_dir}) failed."
|
18
|
-
additional_error_msg = "Directory already exists" if e.message.include? "File exists"
|
19
|
+
additional_error_msg = "Directory already exists" if e.message.include? "File exists"
|
19
20
|
raise DTK::ErrorUsage.new(error_msg + " " + additional_error_msg,:log_error=>false)
|
20
21
|
end
|
21
22
|
{"module_directory" => target_repo_dir}
|
@@ -41,8 +42,8 @@ module DTK::Client
|
|
41
42
|
File.open(target_repo_dir + "/serverspec/spec/localhost/temp_component_spec.rb", "w") { |f| f.write(spec_template) }
|
42
43
|
rescue => e
|
43
44
|
error_msg = "Generating serverspec files failed."
|
44
|
-
DtkLogger.instance.error_pp(e.message, e.backtrace)
|
45
|
-
raise DTK::ErrorUsage.new(error_msg,:log_error=>false)
|
45
|
+
DtkLogger.instance.error_pp(e.message, e.backtrace)
|
46
|
+
raise DTK::ErrorUsage.new(error_msg,:log_error=>false)
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|
@@ -49,13 +49,14 @@ module DTK::Client
|
|
49
49
|
def resolve_module_type
|
50
50
|
case self
|
51
51
|
when DTK::Client::ComponentModule
|
52
|
-
return
|
52
|
+
return :component_module
|
53
|
+
when DTK::Client::ServiceModule
|
54
|
+
return :service_module
|
53
55
|
when DTK::Client::TestModule
|
54
|
-
return
|
56
|
+
return :test_module
|
55
57
|
else
|
56
|
-
|
58
|
+
raise DtkError, "Module type cannot be resolved for this class (#{self})"
|
57
59
|
end
|
58
|
-
# self.class == DTK::Client::ComponentModule ? 'component_module' : 'service_module'
|
59
60
|
end
|
60
61
|
|
61
62
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module DTK::Client
|
2
|
+
module AssemblyTemplateMixin
|
3
|
+
def get_assembly_name(assembly_id)
|
4
|
+
name = nil
|
5
|
+
3.times do
|
6
|
+
name = get_name_from_id_helper(assembly_id)
|
7
|
+
break if name
|
8
|
+
end
|
9
|
+
|
10
|
+
name
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_assembly_stage_name(assembly_list,assembly_template_name)
|
14
|
+
name = nil
|
15
|
+
current_list = assembly_list.select{|e| e.include?(assembly_template_name)}
|
16
|
+
|
17
|
+
if current_list.empty?
|
18
|
+
name = assembly_template_name
|
19
|
+
else
|
20
|
+
numbers = []
|
21
|
+
base_name = nil
|
22
|
+
|
23
|
+
assembly_list.each do |assembly|
|
24
|
+
match = assembly.match(/#{assembly_template_name}(-)(\d*)/)
|
25
|
+
base_name = assembly_template_name if assembly_template_name.include?(assembly)
|
26
|
+
numbers << match[2].to_i if match
|
27
|
+
end
|
28
|
+
|
29
|
+
unless base_name
|
30
|
+
name = assembly_template_name
|
31
|
+
else
|
32
|
+
highest = numbers.max||1
|
33
|
+
new_highest = highest+1
|
34
|
+
|
35
|
+
all = (2..new_highest).to_a
|
36
|
+
nums = all - numbers
|
37
|
+
name = assembly_template_name + "-#{nums.first}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
name
|
42
|
+
end
|
43
|
+
|
44
|
+
# the form should be
|
45
|
+
# SETTINGS := SETTING[;...SETTING]
|
46
|
+
# SETTING := ATOM || ATOM(ATTR=VAL,...)
|
47
|
+
def parse_service_settings(settings)
|
48
|
+
settings && settings.split(';').map{|setting|ServiceSetting.parse(setting)}
|
49
|
+
end
|
50
|
+
|
51
|
+
module ServiceSetting
|
52
|
+
def self.parse(setting)
|
53
|
+
if setting =~ /(^[^\(]+)\((.+)\)$/
|
54
|
+
name = $1
|
55
|
+
param_string = $2
|
56
|
+
{:name => name, :parameters => parse_params(param_string)}
|
57
|
+
else
|
58
|
+
{:name => setting}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
private
|
62
|
+
def self.parse_params(param_string)
|
63
|
+
param_string.split(',').inject(Hash.new) do |h,av_pair|
|
64
|
+
if av_pair =~ /(^[^=]+)=(.+$)/
|
65
|
+
attr = $1
|
66
|
+
val = $2
|
67
|
+
h.merge(attr => val)
|
68
|
+
else
|
69
|
+
raise DtkError,"[ERROR] Settings param string is ill-formed"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|