dtk-client 0.7.1.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/Gemfile +1 -1
- data/Gemfile_dev +1 -0
- data/bin/dtk-execute +1 -18
- data/dtk-client.gemspec +1 -1
- data/lib/client.rb +0 -5
- data/lib/command_helpers/git_repo.rb +43 -12
- data/lib/commands/common/thor/assembly_workspace.rb +3 -3
- data/lib/commands/common/thor/module.rb +81 -7
- data/lib/commands/common/thor/module/import.rb +14 -4
- data/lib/commands/common/thor/pull_from_remote.rb +2 -0
- data/lib/commands/common/thor/push_clone_changes.rb +1 -1
- data/lib/commands/common/thor/push_to_remote.rb +18 -4
- data/lib/commands/common/thor/remotes.rb +54 -0
- data/lib/commands/common/thor/{set_required_params.rb → set_required_attributes.rb} +1 -1
- data/lib/commands/thor/component.rb +2 -2
- data/lib/commands/thor/component_module.rb +56 -7
- data/lib/commands/thor/dtk.rb +7 -7
- data/lib/commands/thor/node.rb +4 -4
- data/lib/commands/thor/node_group.rb +4 -4
- data/lib/commands/thor/remotes.rb +32 -0
- data/lib/commands/thor/service.rb +9 -5
- data/lib/commands/thor/service_module.rb +41 -5
- data/lib/commands/thor/test_module.rb +43 -3
- data/lib/commands/thor/workspace.rb +8 -4
- data/lib/core.rb +3 -0
- data/lib/domain/git_adapter.rb +15 -8
- data/lib/domain/response.rb +39 -26
- data/lib/dtk-client/version.rb +1 -1
- data/lib/execute.rb +1 -1
- data/lib/execute/command/api_call/service.rb +1 -0
- data/lib/execute/script.rb +50 -0
- data/lib/execute/script/add_tenant.rb +91 -0
- data/lib/execute/script/add_tenant_without_router.rb +87 -0
- data/lib/shell/context.rb +15 -9
- data/lib/shell/domain/context_params.rb +2 -0
- data/lib/shell/help_monkey_patch.rb +4 -0
- data/lib/util/os_util.rb +2 -1
- metadata +27 -24
- data/lib/execute/examples.rb +0 -3
- data/lib/execute/examples/add_tenant.rb +0 -42
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NDJjZDIyMmVkYjY2ZDdlOGY2ZjY1ODljYWI2YzBhMDA1NzVjMDUyNQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d7b720c50b249bbf6c309691e139bce76d5ce56a
|
4
|
+
data.tar.gz: 9decd8f03d3b2fed899f7b30f5e77c43b3934271
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MzRiMDVlZTBmZjUwODhlYjE5NjNlYTE0OTZmMGRhMDNmNDYzM2Y0YTkxMTc5
|
11
|
-
NTY4MmU3NmFmNzhmNjVkYzY1NjY2MTBmZTQ0Y2M3OTlmY2IxMzM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZDllMmIyYjQ2NGMyY2ZlYzc4MDM2Y2M5YzM1MTI1MmE0NTYyOTljOGY2YmRl
|
14
|
-
ODRlYzg5ZTM4MTVjNWNmODI3ODNlZTgxNWU2ZWJkMzQ0ODVhZGViYjYzNzE1
|
15
|
-
MjUyMDAyNGViNjkyMWY1YjI2M2YwNjBmYjdjM2I1OWE3MWY0OGQ=
|
6
|
+
metadata.gz: 020f067a80f545dd864ca53b5a4cfd7b5f5dd59305f469d9c581081f2d8411db6da95e4e3246897e4ca557afb57c36f686b16fea6db497e3f02725ec6f8af96d
|
7
|
+
data.tar.gz: 9e39ec3fa3e2c5d8e06b1c4c9b5eb27e364df7f744e0a3cb028eaef3f532e72eee829a3806d39392adb4893f09be6a6b0278825424d07b25fd0309d7d35949e6
|
data/Gemfile
CHANGED
data/Gemfile_dev
CHANGED
data/bin/dtk-execute
CHANGED
@@ -12,21 +12,4 @@ Configurator.check_config_exists
|
|
12
12
|
conn = Session.get_connection()
|
13
13
|
exit if validate_connection(conn)
|
14
14
|
|
15
|
-
|
16
|
-
banner = "Usage: dtk-execute add-tenant TENANT-NAME"
|
17
|
-
tenant_name = nil
|
18
|
-
if ARGV.size == 2
|
19
|
-
if ARGV[0] == 'add-tenant'
|
20
|
-
tenant_name = ARGV[1]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
unless tenant_name
|
24
|
-
# forces usage then exit
|
25
|
-
ARGV[0] = '--help'
|
26
|
-
end
|
27
|
-
options = {}
|
28
|
-
OptionParser.new do |opts|
|
29
|
-
opts.banner = banner
|
30
|
-
end.parse!
|
31
|
-
|
32
|
-
Execute.add_tenant(tenant_name)
|
15
|
+
Execute::Script.execute()
|
data/dtk-client.gemspec
CHANGED
@@ -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.7.
|
32
|
+
gem.add_dependency 'dtk-common-core','0.7.1'
|
33
33
|
gem.add_dependency 'git','~> 1.2.6'
|
34
34
|
gem.add_dependency 'colorize','~> 0.5.8'
|
35
35
|
gem.add_dependency 'highline', '1.6.16'
|
data/lib/client.rb
CHANGED
@@ -14,11 +14,6 @@ begin
|
|
14
14
|
# Monkey Patching bundler to support loading specific Gemfile from dtk-client project's root - Ticket: DTK-585
|
15
15
|
dtk_require("config/configuration")
|
16
16
|
|
17
|
-
|
18
|
-
if DTK::Configuration.get(:debug_grit)
|
19
|
-
# INSERT NEW CODE HERE
|
20
|
-
end
|
21
|
-
|
22
17
|
# we don't need Bundler.setup but will leave it commented just in case
|
23
18
|
# TODO: This is temp solution which will not use bundler.setup when in dev mode
|
24
19
|
# thus allowing us to use system gems and not just the ones specified in Gemfile
|
@@ -75,11 +75,11 @@ module DTK; module Client; class CommandHelper
|
|
75
75
|
# :local_branch
|
76
76
|
# :no_fetch
|
77
77
|
#
|
78
|
-
def push_changes(type,full_module_name,version,opts={})
|
78
|
+
def push_changes(type, full_module_name, version, opts={})
|
79
79
|
Response.wrap_helper_actions() do
|
80
|
-
repo_dir = local_repo_dir(type,full_module_name,version,opts)
|
80
|
+
repo_dir = local_repo_dir(type, full_module_name, version, opts)
|
81
81
|
repo = create(repo_dir,opts[:local_branch])
|
82
|
-
push_repo_changes_aux(repo,opts)
|
82
|
+
push_repo_changes_aux(repo, opts)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
@@ -160,7 +160,7 @@ module DTK; module Client; class CommandHelper
|
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
163
|
-
def check_local_dir_exists_with_content(type,module_name,version=nil,module_namespace=nil)
|
163
|
+
def check_local_dir_exists_with_content(type, module_name, version=nil, module_namespace=nil)
|
164
164
|
full_module_name = ModuleUtil.join_name(module_name, module_namespace)
|
165
165
|
Response.wrap_helper_actions() do
|
166
166
|
ret = Hash.new
|
@@ -189,6 +189,28 @@ module DTK; module Client; class CommandHelper
|
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
192
|
+
def cp_r_to_new_namespace(type, module_name, src_namespace, dest_namespace, version = nil)
|
193
|
+
full_name_src = ModuleUtil.join_name(module_name, src_namespace)
|
194
|
+
full_name_dest = ModuleUtil.join_name(module_name, dest_namespace)
|
195
|
+
|
196
|
+
local_src_dir = local_repo_dir(type, full_name_src, version)
|
197
|
+
local_dest_dir = local_repo_dir(type, full_name_dest, version)
|
198
|
+
|
199
|
+
Response.wrap_helper_actions() do
|
200
|
+
if File.directory?(local_src_dir) && !(Dir["#{local_src_dir}/*"].empty?)
|
201
|
+
raise ErrorUsage.new("Directory (#{local_dest_dir}) already exist with content.",:log_error=>false) if File.directory?(local_dest_dir) && !(Dir["#{local_dest_dir}/*"].empty?)
|
202
|
+
|
203
|
+
# create namespace directory if does not exist, and copy source to destination module directory
|
204
|
+
namespace_dir = local_repo_dir(type, dest_namespace, version)
|
205
|
+
FileUtils.mkdir_p(namespace_dir)
|
206
|
+
FileUtils.cp_r(local_src_dir, local_dest_dir)
|
207
|
+
else
|
208
|
+
raise ErrorUsage.new("The content for module (#{full_name_src}) should be put in directory (#{local_src_dir})",:log_error=>false)
|
209
|
+
end
|
210
|
+
{"module_directory" => local_dest_dir}
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
192
214
|
def rename_and_initialize_clone_and_push(type, module_name, new_module_name, branch, repo_url, local_repo_dir, version = nil)
|
193
215
|
# check to see if the new dir has proper naming e.g. (~/dtk/component_modules/dtk::java)
|
194
216
|
unless local_repo_dir.match(/\/#{new_module_name.gsub(ModuleUtil::NAMESPACE_SEPERATOR,'/')}$/)
|
@@ -283,7 +305,7 @@ module DTK; module Client; class CommandHelper
|
|
283
305
|
#returns hash with keys
|
284
306
|
#: diffs - hash with diffs
|
285
307
|
# commit_sha - sha of currenet_commit
|
286
|
-
def push_repo_changes_aux(repo,opts={})
|
308
|
+
def push_repo_changes_aux(repo, opts={})
|
287
309
|
diffs = DiffSummary.new()
|
288
310
|
|
289
311
|
# adding untracked files (newly added files)
|
@@ -308,31 +330,40 @@ module DTK; module Client; class CommandHelper
|
|
308
330
|
|
309
331
|
#check if merge needed
|
310
332
|
commit_shas = Hash.new
|
311
|
-
merge_rel
|
312
|
-
commit_sha
|
333
|
+
merge_rel = repo.merge_relationship(:remote_branch,remote_branch_ref, :ret_commit_shas => commit_shas)
|
334
|
+
commit_sha = nil
|
335
|
+
diffs = DiffSummary.new_version(repo)
|
336
|
+
|
313
337
|
if merge_rel == :equal
|
314
338
|
commit_sha = commit_shas[:other_sha]
|
315
339
|
elsif [:branchpoint,:local_behind].include?(merge_rel)
|
316
|
-
|
340
|
+
if opts[:force]
|
341
|
+
diffs = DiffSummary.diff(repo,local_branch, remote_branch_ref)
|
342
|
+
if diffs.any_diffs?()
|
343
|
+
repo.push(remote_branch_ref, {:force => opts[:force]})
|
344
|
+
end
|
345
|
+
commit_sha = repo.find_remote_sha(remote_branch_ref)
|
346
|
+
else
|
347
|
+
where = opts[:where]||'server'
|
348
|
+
raise ErrorUsage.new("Merge needed before module (#{pp_module(repo)}) can be pushed to #{where}. If you want to force push use '--force' option.")
|
349
|
+
end
|
317
350
|
elsif merge_rel == :no_remote_ref
|
318
351
|
repo.push(remote_branch_ref)
|
319
|
-
diffs = DiffSummary.new_version(repo)
|
320
352
|
commit_sha = commit_shas[:local_sha]
|
321
353
|
elsif merge_rel == :local_ahead
|
322
354
|
# see if any diffs between fetched remote and local branch
|
323
355
|
# this has be done after commit
|
324
|
-
|
325
356
|
diffs = DiffSummary.diff(repo,local_branch, remote_branch_ref)
|
326
357
|
|
327
|
-
|
328
358
|
if diffs.any_diffs?()
|
329
|
-
repo.push(remote_branch_ref)
|
359
|
+
repo.push(remote_branch_ref, {:force => opts[:force]})
|
330
360
|
end
|
331
361
|
|
332
362
|
commit_sha = repo.find_remote_sha(remote_branch_ref)
|
333
363
|
else
|
334
364
|
raise Error.new("Unexpected merge_rel (#{merge_rel})")
|
335
365
|
end
|
366
|
+
|
336
367
|
{"diffs" => diffs, "commit_sha" => commit_sha, "repo_obj" => repo}
|
337
368
|
end
|
338
369
|
|
@@ -5,7 +5,7 @@ dtk_require_from_base("dtk_logger")
|
|
5
5
|
dtk_require_from_base("util/os_util")
|
6
6
|
dtk_require_from_base("command_helper")
|
7
7
|
dtk_require_common_commands('thor/task_status')
|
8
|
-
dtk_require_common_commands('thor/
|
8
|
+
dtk_require_common_commands('thor/set_required_attributes')
|
9
9
|
dtk_require_common_commands('thor/edit')
|
10
10
|
dtk_require_common_commands('thor/purge_clone')
|
11
11
|
dtk_require_common_commands('thor/list_diffs')
|
@@ -1022,9 +1022,9 @@ module DTK::Client
|
|
1022
1022
|
response.render_table(:ps_data)
|
1023
1023
|
end
|
1024
1024
|
|
1025
|
-
def
|
1025
|
+
def set_required_attributes(context_params)
|
1026
1026
|
assembly_or_workspace_id = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID],method_argument_names)
|
1027
|
-
|
1027
|
+
set_required_attributes_aux(assembly_or_workspace_id,:assembly,:instance)
|
1028
1028
|
end
|
1029
1029
|
|
1030
1030
|
def tail_aux(context_params)
|
@@ -9,6 +9,7 @@ dtk_require_common_commands('thor/edit')
|
|
9
9
|
dtk_require_common_commands('thor/reparse')
|
10
10
|
dtk_require_common_commands('thor/purge_clone')
|
11
11
|
dtk_require_common_commands('thor/common')
|
12
|
+
dtk_require_common_commands('thor/remotes')
|
12
13
|
|
13
14
|
dtk_require_from_base('configurator')
|
14
15
|
dtk_require_from_base('command_helpers/service_importer')
|
@@ -44,14 +45,19 @@ module DTK::Client
|
|
44
45
|
# TODO: when we do this for other areas we can move these things up and use as common classes
|
45
46
|
# helpers
|
46
47
|
def retrieve_arguments(mapping, method_info = nil)
|
47
|
-
@context_params.retrieve_arguments(mapping, method_info
|
48
|
+
@context_params.retrieve_arguments(mapping, method_info || @command.method_argument_names)
|
48
49
|
end
|
50
|
+
|
49
51
|
def get_namespace_and_name(*args)
|
50
52
|
@command.get_namespace_and_name(*args)
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
54
56
|
module ModuleMixin
|
57
|
+
|
58
|
+
REQ_MODULE_ID = [:service_module_id!, :component_module_id!, :test_module_id!]
|
59
|
+
REQ_MODULE_NAME = [:service_module_name!, :component_module_name!, :test_module_name!]
|
60
|
+
|
55
61
|
include PuppetForgeMixin
|
56
62
|
include CloneMixin
|
57
63
|
include PushToRemoteMixin
|
@@ -63,9 +69,7 @@ module DTK::Client
|
|
63
69
|
include ListDiffsMixin
|
64
70
|
include ServiceImporter
|
65
71
|
include AccessControlMixin
|
66
|
-
|
67
|
-
REQ_MODULE_ID = [:service_module_id!, :component_module_id!, :test_module_id!]
|
68
|
-
REQ_MODULE_NAME = [:service_module_name!, :component_module_name!, :test_module_name!]
|
72
|
+
include RemotesMixin
|
69
73
|
|
70
74
|
def get_module_type(context_params)
|
71
75
|
forwarded_type = context_params.get_forwarded_options() ? context_params.get_forwarded_options()[:module_type] : nil
|
@@ -427,6 +431,53 @@ module DTK::Client
|
|
427
431
|
edit_aux(module_type.to_sym, module_id, module_name, version, opts)
|
428
432
|
end
|
429
433
|
|
434
|
+
def push_remote_module_aux(context_params)
|
435
|
+
module_id, module_name, remote_name = context_params.retrieve_arguments([REQ_MODULE_ID, REQ_MODULE_NAME, :option_1],method_argument_names)
|
436
|
+
version = options["version"]
|
437
|
+
module_type = get_module_type(context_params)
|
438
|
+
|
439
|
+
post_body = {
|
440
|
+
"#{module_type}_id".to_sym => module_id
|
441
|
+
}
|
442
|
+
|
443
|
+
response = post rest_url("#{module_type}/info_git_remote"), post_body
|
444
|
+
remotes_list = response.data
|
445
|
+
|
446
|
+
# vital information, abort if it does not exist
|
447
|
+
raise DtkError, "There are no registered remotes, aborting action" if remotes_list.empty?
|
448
|
+
|
449
|
+
# check if there is provided remote
|
450
|
+
if remote_name
|
451
|
+
target_remote = remotes_list.find { |r| remote_name.eql?(r['display_name']) }
|
452
|
+
raise DtkError, "Not able to find remote '#{remote_name}'" unless target_remote
|
453
|
+
end
|
454
|
+
|
455
|
+
# if only one take it, else raise ambiguous error
|
456
|
+
unless target_remote
|
457
|
+
if remotes_list.size == 1
|
458
|
+
target_remote = remotes_list.first
|
459
|
+
else
|
460
|
+
remote_names = remotes_list.collect { |r| r['display_name'] }
|
461
|
+
raise DtkError, "Call is ambiguous, please provide remote name. Remotes: #{remote_names.join(', ')} "
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
# clone if necessry
|
466
|
+
module_location = OsUtil.module_location(resolve_module_type(), module_name, version)
|
467
|
+
unless File.directory?(module_location)
|
468
|
+
response = clone_aux(module_type.to_sym, module_id, version, true, true)
|
469
|
+
return response unless response.ok?
|
470
|
+
end
|
471
|
+
|
472
|
+
|
473
|
+
OsUtil.print("Pushing local content to remote #{target_remote['repo_url']} ... ", :yellow)
|
474
|
+
push_to_git_remote_aux(module_name, module_type.to_sym, version, {
|
475
|
+
:remote_repo_url => target_remote['repo_url'],
|
476
|
+
:remote_branch => 'master',
|
477
|
+
:remote_repo => "#{target_remote['display_name']}--remote"
|
478
|
+
}, options.force?)
|
479
|
+
end
|
480
|
+
|
430
481
|
def push_dtkn_module_aux(context_params, internal_trigger=false)
|
431
482
|
module_id, module_name = context_params.retrieve_arguments([REQ_MODULE_ID, REQ_MODULE_NAME],method_argument_names)
|
432
483
|
catalog = 'dtkn'
|
@@ -439,8 +490,6 @@ module DTK::Client
|
|
439
490
|
reparse_aux(module_location) unless internal_trigger
|
440
491
|
local_namespace, local_module_name = get_namespace_and_name(module_name,':')
|
441
492
|
|
442
|
-
# if catalog.to_s.eql?("origin")
|
443
|
-
# push_clone_changes_aux(:component_module,component_module_id,version,options["message"]||DEFAULT_COMMIT_MSG,internal_trigger)
|
444
493
|
if catalog.to_s.eql?("dtkn")
|
445
494
|
module_refs_content = RemoteDependencyUtil.module_ref_content(module_location)
|
446
495
|
remote_module_info = get_remote_module_info_aux(module_type.to_sym, module_id, options["namespace"], version, module_refs_content, local_namespace)
|
@@ -457,11 +506,12 @@ module DTK::Client
|
|
457
506
|
return response
|
458
507
|
end
|
459
508
|
|
460
|
-
push_to_remote_aux(remote_module_info, module_type.to_sym)
|
509
|
+
push_to_remote_aux(remote_module_info, module_type.to_sym, options.force?)
|
461
510
|
else
|
462
511
|
raise DtkValidationError, "You have to provide valid catalog to push changes to! Valid catalogs: #{PushCatalogs}"
|
463
512
|
end
|
464
513
|
end
|
514
|
+
|
465
515
|
PushCatalogs = ["origin", "dtkn"]
|
466
516
|
|
467
517
|
def list_diffs_module_aux(context_params)
|
@@ -558,6 +608,30 @@ module DTK::Client
|
|
558
608
|
response.render_table(:assembly)
|
559
609
|
end
|
560
610
|
|
611
|
+
def fork_aux(context_params)
|
612
|
+
module_type = get_module_type(context_params)
|
613
|
+
module_id, fork_namespace = context_params.retrieve_arguments([REQ_MODULE_ID, :option_1!], method_argument_names)
|
614
|
+
|
615
|
+
raise DtkValidationError, "Namespace '#{fork_namespace}' contains invalid characters. Valid characters are letters, numbers, dash and underscore." unless fork_namespace.to_s =~ /^[0-9a-zA-Z\_\-]*$/
|
616
|
+
|
617
|
+
module_name = context_params.retrieve_arguments(["#{module_type}_name".to_sym],method_argument_names)
|
618
|
+
namespace, name = get_namespace_and_name(module_name,':')
|
619
|
+
response = Helper(:git_repo).cp_r_to_new_namespace(module_type, name, namespace, fork_namespace)
|
620
|
+
return response unless response.ok?
|
621
|
+
|
622
|
+
new_context_params = DTK::Shell::ContextParams.new
|
623
|
+
new_context_params.add_context_to_params(module_type, module_type)
|
624
|
+
new_context_params.method_arguments = ["#{fork_namespace}:#{name}"]
|
625
|
+
|
626
|
+
create_response = CommonModule::Import.new(self, new_context_params).from_file()
|
627
|
+
unless create_response.ok?
|
628
|
+
FileUtils.rm_rf("#{response['data']['module_directory']}")
|
629
|
+
return create_response
|
630
|
+
end
|
631
|
+
|
632
|
+
Response::Ok.new()
|
633
|
+
end
|
634
|
+
|
561
635
|
def print_ambiguous(ambiguous)
|
562
636
|
end
|
563
637
|
|
@@ -13,10 +13,10 @@ module DTK::Client
|
|
13
13
|
def from_git()
|
14
14
|
git_repo_url, module_name = retrieve_arguments([:option_1!, :option_2!])
|
15
15
|
namespace, local_module_name = get_namespace_and_name(module_name, ModuleUtil::NAMESPACE_SEPERATOR)
|
16
|
-
|
16
|
+
|
17
17
|
module_type = @command.get_module_type(@context_params)
|
18
18
|
thor_options = { :git_import => true}
|
19
|
-
|
19
|
+
|
20
20
|
unless namespace
|
21
21
|
namespace_response = post rest_url("namespace/default_namespace_name")
|
22
22
|
return namespace_response unless namespace_response.ok?
|
@@ -29,6 +29,7 @@ module DTK::Client
|
|
29
29
|
:namespace => namespace,
|
30
30
|
:branch => @options['branch']
|
31
31
|
}
|
32
|
+
|
32
33
|
response = Helper(:git_repo).create_clone_from_optional_branch(module_type.to_sym, local_module_name, git_repo_url, opts)
|
33
34
|
return response unless response.ok?
|
34
35
|
|
@@ -102,11 +103,18 @@ module DTK::Client
|
|
102
103
|
private
|
103
104
|
|
104
105
|
def from_git_or_file()
|
106
|
+
|
105
107
|
default_ns = @context_params.get_forwarded_options()[:default_namespace]
|
106
108
|
git_import = @context_params.get_forwarded_options()[:git_import]
|
107
109
|
|
108
110
|
name_option = git_import ? :option_2! : :option_1!
|
109
|
-
|
111
|
+
|
112
|
+
if git_import
|
113
|
+
module_git_url, module_name = @context_params.retrieve_arguments([:option_1!, :option_2!])
|
114
|
+
else
|
115
|
+
module_name, module_git_url = @context_params.retrieve_arguments([:option_1!, :option_2!])
|
116
|
+
end
|
117
|
+
|
110
118
|
module_type = @command.get_module_type(@context_params)
|
111
119
|
version = @options["version"]
|
112
120
|
|
@@ -125,8 +133,10 @@ module DTK::Client
|
|
125
133
|
# first make call to server to create an empty repo
|
126
134
|
post_body = {
|
127
135
|
:module_name => local_module_name,
|
128
|
-
:module_namespace => namespace
|
136
|
+
:module_namespace => namespace,
|
137
|
+
:module_git_url => module_git_url
|
129
138
|
}
|
139
|
+
|
130
140
|
response = post(rest_url("#{module_type}/create"), post_body)
|
131
141
|
return response unless response.ok?
|
132
142
|
|
@@ -28,6 +28,8 @@ module DTK::Client
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# check whether a local module exists to determine whether pull from local clone or try to pull from server
|
31
|
+
OsUtil.print("Pulling changes to remote: #{remote_params[:remote_repo]} @ #{remote_params[:remote_repo_url]}")
|
32
|
+
|
31
33
|
if Helper(:git_repo).local_clone_dir_exists?(module_type,module_name,:full_module_name=>full_module_name,:version=>version)
|
32
34
|
unless rsa_pub_key
|
33
35
|
raise DtkError,"No File found at (#{path_to_key}). Path is wrong or it is necessary to generate the public rsa key (e.g., run ssh-keygen -t rsa)"
|
@@ -23,7 +23,7 @@ module DTK::Client
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
push_opts = opts.merge(:commit_msg => commit_msg, :local_branch => branch)
|
26
|
+
push_opts = opts.merge(:commit_msg => commit_msg, :local_branch => branch, :where => 'server')
|
27
27
|
response = Helper(:git_repo).push_changes(module_type, full_module_name, version, push_opts)
|
28
28
|
return response unless response.ok?
|
29
29
|
|
@@ -2,7 +2,20 @@ dtk_require_common_commands('thor/common')
|
|
2
2
|
module DTK::Client
|
3
3
|
module PushToRemoteMixin
|
4
4
|
|
5
|
-
def
|
5
|
+
def push_to_git_remote_aux(full_module_name, module_type, version, opts, force = false)
|
6
|
+
opts.merge!(:force => force)
|
7
|
+
|
8
|
+
response = Helper(:git_repo).push_changes(module_type, full_module_name, version, opts)
|
9
|
+
|
10
|
+
return response unless response.ok?
|
11
|
+
if response.data(:diffs).empty?
|
12
|
+
raise DtkError, "No changes to push"
|
13
|
+
end
|
14
|
+
|
15
|
+
Response::Ok.new()
|
16
|
+
end
|
17
|
+
|
18
|
+
def push_to_remote_aux(remote_module_info, module_type, force = false)
|
6
19
|
full_module_name = remote_module_info.data(:full_module_name)
|
7
20
|
version = remote_module_info.data(:version)
|
8
21
|
|
@@ -10,10 +23,11 @@ module DTK::Client
|
|
10
23
|
:remote_repo_url => remote_module_info.data(:remote_repo_url),
|
11
24
|
:remote_repo => remote_module_info.data(:remote_repo),
|
12
25
|
:remote_branch => remote_module_info.data(:remote_branch),
|
13
|
-
:local_branch => remote_module_info.data(:workspace_branch)
|
26
|
+
:local_branch => remote_module_info.data(:workspace_branch),
|
27
|
+
:where => 'catalog',
|
28
|
+
:force => force
|
14
29
|
}
|
15
|
-
|
16
|
-
response = Helper(:git_repo).push_changes(module_type,full_module_name,version,opts)
|
30
|
+
response = Helper(:git_repo).push_changes(module_type, full_module_name, version, opts)
|
17
31
|
return response unless response.ok?
|
18
32
|
if response.data(:diffs).empty?
|
19
33
|
raise DtkError, "No changes to push"
|