dtk-client 0.7.2.1 → 0.7.3
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 +4 -4
- data/Gemfile +1 -1
- data/dtk-client.gemspec +2 -2
- data/lib/command_helpers/git_repo.rb +26 -12
- data/lib/commands/common/thor/assembly_workspace.rb +55 -0
- data/lib/commands/common/thor/common_base.rb +32 -0
- data/lib/commands/common/thor/create_target.rb +50 -0
- data/lib/commands/common/thor/edit.rb +1 -1
- data/lib/commands/common/thor/module/import.rb +1 -1
- data/lib/commands/common/thor/module.rb +37 -13
- data/lib/commands/common/thor/pull_from_remote.rb +2 -2
- data/lib/commands/common/thor/puppet_forge.rb +1 -1
- data/lib/commands/common/thor/push_clone_changes.rb +2 -0
- data/lib/commands/common/thor/push_to_remote.rb +35 -0
- data/lib/commands/thor/account.rb +3 -3
- data/lib/commands/thor/component_module.rb +9 -5
- data/lib/commands/thor/provider.rb +41 -48
- data/lib/commands/thor/service.rb +12 -0
- data/lib/commands/thor/service_module.rb +13 -4
- data/lib/commands/thor/target.rb +45 -45
- data/lib/commands/thor/test_module.rb +12 -6
- data/lib/commands/thor/workspace.rb +12 -0
- data/lib/core.rb +1 -1
- data/lib/domain/git_adapter.rb +4 -0
- data/lib/domain/response.rb +0 -8
- data/lib/dtk-client/version.rb +1 -1
- data/lib/execute/script/add_tenant.rb +26 -13
- data/lib/execute/script.rb +0 -2
- data/lib/shell/context.rb +14 -0
- data/lib/shell/domain/context_params.rb +1 -2
- data/lib/util/console.rb +19 -0
- data/lib/util/module_util.rb +4 -0
- data/lib/util/os_util.rb +4 -0
- metadata +10 -9
- data/lib/execute/script/add_tenant_without_router.rb +0 -87
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f5b684856babcaa9d925ad089f311461b8ea4c6
|
4
|
+
data.tar.gz: 952f5d25a660b8c17936cdc20ef80d1cd1c13ec7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12d06bf9def6875592c3bbf2daf4c31c175d426875672854d4c1c4d8ad25bb14b2f0db998e45cd4c906ef24ad96352b76d1daeb769bde35bcb637bd0acdf1840
|
7
|
+
data.tar.gz: 6dfd454ecc21eeba533d4ccb1ac130dfa9d7235055f133551bd320ff5d24366ad3f197da1b3a3eab572745bf11ba4352a36c63ae6f9e3653b5f645a4cea14467
|
data/Gemfile
CHANGED
data/dtk-client.gemspec
CHANGED
@@ -29,8 +29,8 @@ 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.
|
33
|
-
gem.add_dependency 'git','
|
32
|
+
gem.add_dependency 'dtk-common-core','0.7.2'
|
33
|
+
gem.add_dependency 'git','1.2.8'
|
34
34
|
gem.add_dependency 'colorize','~> 0.5.8'
|
35
35
|
gem.add_dependency 'highline', '1.6.16'
|
36
36
|
gem.add_dependency 'awesome_print', '1.1.0'
|
@@ -9,7 +9,7 @@ module DTK; module Client; class CommandHelper
|
|
9
9
|
class GitRepo < self; class << self
|
10
10
|
|
11
11
|
def create(repo_dir,branch=nil,opts={})
|
12
|
-
GitAdapter.new(repo_dir,branch)
|
12
|
+
GitAdapter.new(repo_dir, branch)
|
13
13
|
end
|
14
14
|
|
15
15
|
def create_clone_from_optional_branch(type, module_name, repo_url, opts={})
|
@@ -18,6 +18,7 @@ module DTK; module Client; class CommandHelper
|
|
18
18
|
namespace = opts[:namespace]
|
19
19
|
create_clone_with_branch(type,module_name,repo_url,branch,version,namespace,{:track_remote_branch => true}.merge(opts))
|
20
20
|
end
|
21
|
+
|
21
22
|
# TODO: should we deprecate below for above, subsituting the body of below for above ?
|
22
23
|
def create_clone_with_branch(type, module_name, repo_url, branch=nil, version=nil, module_namespace=nil, opts={})
|
23
24
|
Response.wrap_helper_actions do
|
@@ -40,7 +41,7 @@ module DTK; module Client; class CommandHelper
|
|
40
41
|
|
41
42
|
begin
|
42
43
|
opts_clone = (opts[:track_remote_branch] ? {:track_remote_branch => true} : {})
|
43
|
-
GitAdapter.clone(repo_url, target_repo_dir, branch,opts_clone)
|
44
|
+
GitAdapter.clone(repo_url, target_repo_dir, branch, opts_clone)
|
44
45
|
rescue => e
|
45
46
|
# Handling Git error messages with more user friendly messages
|
46
47
|
e = GitErrorHandler.handle(e)
|
@@ -73,12 +74,13 @@ module DTK; module Client; class CommandHelper
|
|
73
74
|
# :remote_branch
|
74
75
|
# :remote_repo_url
|
75
76
|
# :local_branch
|
77
|
+
# :override_repo_dir_location
|
76
78
|
# :no_fetch
|
77
79
|
#
|
78
80
|
def push_changes(type, full_module_name, version, opts={})
|
79
81
|
Response.wrap_helper_actions() do
|
80
|
-
repo_dir = local_repo_dir(type, full_module_name, version, opts)
|
81
|
-
repo = create(repo_dir,opts[:local_branch])
|
82
|
+
repo_dir = opts[:override_repo_dir_location] ? opts[:override_repo_dir_location] : local_repo_dir(type, full_module_name, version, opts)
|
83
|
+
repo = create(repo_dir, opts[:local_branch])
|
82
84
|
push_repo_changes_aux(repo, opts)
|
83
85
|
end
|
84
86
|
end
|
@@ -128,6 +130,16 @@ module DTK; module Client; class CommandHelper
|
|
128
130
|
end
|
129
131
|
end
|
130
132
|
|
133
|
+
def hard_reset_branch_to_sha(type, module_name, opts={})
|
134
|
+
Response.wrap_helper_actions() do
|
135
|
+
full_module_name = full_module_name(module_name,opts)
|
136
|
+
repo_dir = local_repo_dir(type, full_module_name, opts[:version], opts)
|
137
|
+
repo = create(repo_dir, opts[:local_branch])
|
138
|
+
current_branch_sha = opts[:current_branch_sha]
|
139
|
+
repo.reset_hard(current_branch_sha)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
131
143
|
# opts can have the following keys
|
132
144
|
#
|
133
145
|
# :version
|
@@ -135,7 +147,7 @@ module DTK; module Client; class CommandHelper
|
|
135
147
|
# :namespace
|
136
148
|
def local_clone_dir_exists?(type,module_name,opts={})
|
137
149
|
full_module_name = full_module_name(module_name,opts)
|
138
|
-
ret = local_repo_dir(type,full_module_name,opts[:version])
|
150
|
+
ret = local_repo_dir(type, full_module_name, opts[:version], opts)
|
139
151
|
File.directory?(ret) && ret
|
140
152
|
end
|
141
153
|
|
@@ -436,10 +448,14 @@ module DTK; module Client; class CommandHelper
|
|
436
448
|
|
437
449
|
def pull_repo_changes_aux(repo,opts={})
|
438
450
|
diffs = DiffSummary.new()
|
451
|
+
hard_reset = opts[:hard_reset] || opts[:force]
|
452
|
+
|
453
|
+
# default commit in case it is needed
|
454
|
+
repo.stage_and_commit("Commit prior to pull from remote") if repo.changed?
|
439
455
|
|
440
456
|
if commit_sha = opts[:commit_sha]
|
441
457
|
#no op if at commit_sha
|
442
|
-
return diffs if commit_sha == repo.head_commit_sha()
|
458
|
+
return diffs if (commit_sha == repo.head_commit_sha()) && !hard_reset
|
443
459
|
end
|
444
460
|
|
445
461
|
if opts[:remote_repo] and opts[:remote_repo_url]
|
@@ -447,24 +463,21 @@ module DTK; module Client; class CommandHelper
|
|
447
463
|
end
|
448
464
|
|
449
465
|
repo.fetch(remote(opts[:remote_repo]))
|
450
|
-
|
451
466
|
local_branch = repo.local_branch_name
|
452
467
|
remote_branch_ref = remote_branch_ref(local_branch,opts)
|
453
468
|
|
454
|
-
if
|
469
|
+
if hard_reset
|
455
470
|
diffs = DiffSummary.diff(repo,local_branch, remote_branch_ref)
|
456
471
|
repo.merge_theirs(remote_branch_ref)
|
457
472
|
return({:diffs => diffs, :commit_sha => repo.head_commit_sha()})
|
458
473
|
end
|
459
474
|
|
460
|
-
# default commit in case it is needed
|
461
|
-
repo.stage_and_commit("Commit prior to pull from remote") if repo.changed?
|
462
|
-
|
463
475
|
#check if merge needed
|
464
476
|
merge_rel = repo.merge_relationship(:remote_branch,remote_branch_ref)
|
465
477
|
if merge_rel == :equal
|
466
478
|
{ :diffs => diffs, :commit_sha => repo.head_commit_sha() }
|
467
479
|
elsif [:branchpoint,:local_ahead].include?(merge_rel)
|
480
|
+
raise ErrorUsage.new("Unable to do fast-forward merge. You can use --force but all changes in the service instance will be lost") unless opts[:force]
|
468
481
|
# TODO: right now just wiping out what is in repo
|
469
482
|
diffs = DiffSummary.diff(repo,local_branch, remote_branch_ref)
|
470
483
|
repo.merge_theirs(remote_branch_ref)
|
@@ -494,6 +507,7 @@ module DTK; module Client; class CommandHelper
|
|
494
507
|
def remote(remote_repo=nil)
|
495
508
|
remote_repo||"origin"
|
496
509
|
end
|
510
|
+
|
497
511
|
def remote_branch_ref(local_branch,opts={})
|
498
512
|
"#{remote(opts[:remote_repo])}/#{opts[:remote_branch]||opts[:local_branch]||local_branch}"
|
499
513
|
end
|
@@ -514,7 +528,7 @@ module DTK; module Client; class CommandHelper
|
|
514
528
|
end
|
515
529
|
|
516
530
|
def local_repo_dir(type,full_module_name,version=nil,opts={})
|
517
|
-
OsUtil.module_location(type,full_module_name,version,opts)
|
531
|
+
OsUtil.module_location(type, full_module_name, version, opts)
|
518
532
|
end
|
519
533
|
|
520
534
|
def backup_dir(type, full_module_name, opts={})
|
@@ -173,6 +173,7 @@ module DTK::Client
|
|
173
173
|
edit_opts = {
|
174
174
|
:automatically_clone => true,
|
175
175
|
:pull_if_needed => false,
|
176
|
+
:service_instance_module => true,
|
176
177
|
:assembly_module => {
|
177
178
|
:assembly_name => assembly_name,
|
178
179
|
:version => version
|
@@ -280,6 +281,60 @@ module DTK::Client
|
|
280
281
|
Response::Ok.new()
|
281
282
|
end
|
282
283
|
|
284
|
+
def pull_base_component_module_aux(context_params)
|
285
|
+
assembly_or_workspace_id, component_module_name = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID,:option_1!],method_argument_names)
|
286
|
+
post_body = {
|
287
|
+
:assembly_id => assembly_or_workspace_id,
|
288
|
+
:module_name => component_module_name,
|
289
|
+
:module_type => 'component_module'
|
290
|
+
}
|
291
|
+
post_body.merge!(:force => true) if options.force?
|
292
|
+
response = post(rest_url("assembly/get_component_module_info"),post_body)
|
293
|
+
return response unless response.ok?
|
294
|
+
|
295
|
+
if dsl_parsing_errors = response.data(:dsl_parsing_errors)
|
296
|
+
error_message = "Module '#{component_module_name}' parsing errors found:\n#{dsl_parsing_errors}\nYou can fix errors using 'edit' command from module context and invoke promote-module-updates again.\n"
|
297
|
+
OsUtil.print(error_message, :red)
|
298
|
+
return Response::Error.new()
|
299
|
+
end
|
300
|
+
|
301
|
+
assembly_name, module_id, module_name, version, base_module_branch, branch_head_sha, local_branch, namespace, repo_url, current_branch_sha = response.data(:assembly_name, :module_id, :full_module_name, :version, :workspace_branch, :branch_head_sha, :local_branch, :module_namespace, :repo_url, :current_branch_sha)
|
302
|
+
edit_opts = {
|
303
|
+
:assembly_module => {
|
304
|
+
:assembly_name => assembly_name,
|
305
|
+
:version => version
|
306
|
+
},
|
307
|
+
:workspace_branch_info => {
|
308
|
+
:repo_url => repo_url,
|
309
|
+
:branch => local_branch,
|
310
|
+
:module_name => module_name,
|
311
|
+
:commit_sha => branch_head_sha
|
312
|
+
},
|
313
|
+
:remote_branch => base_module_branch,
|
314
|
+
:commit_sha => branch_head_sha,
|
315
|
+
:current_branch_sha => current_branch_sha,
|
316
|
+
:full_module_name => module_name
|
317
|
+
}
|
318
|
+
opts = {:local_branch => local_branch, :namespace => namespace}
|
319
|
+
|
320
|
+
opts.merge!(:hard_reset => true) if options.revert?
|
321
|
+
opts.merge!(:force => true) if options.force?
|
322
|
+
|
323
|
+
response = Helper(:git_repo).pull_changes?(:component_module, module_name, edit_opts.merge!(opts))
|
324
|
+
return response unless response.ok?()
|
325
|
+
|
326
|
+
edit_opts.merge!(:force_parse => true, :update_from_includes => true, :print_dependencies => true)
|
327
|
+
response = push_clone_changes_aux(:component_module, module_id, nil, "Pull base module updates", true, edit_opts)
|
328
|
+
|
329
|
+
unless response.ok?()
|
330
|
+
# if parsing error on assembly module (components/attributes/link_defs integrity violations) do git reset --hard
|
331
|
+
Helper(:git_repo).hard_reset_branch_to_sha(:component_module, module_name, edit_opts)
|
332
|
+
return response
|
333
|
+
end
|
334
|
+
|
335
|
+
Response::Ok.new()
|
336
|
+
end
|
337
|
+
|
283
338
|
def workflow_info_aux(context_params)
|
284
339
|
assembly_or_workspace_id = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID],method_argument_names)
|
285
340
|
post_body = {
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module DTK::Client
|
2
|
+
module Commands
|
3
|
+
module Common
|
4
|
+
class Base
|
5
|
+
def initialize(command_base,context_params)
|
6
|
+
@command_base = command_base
|
7
|
+
@context_params = context_params
|
8
|
+
end
|
9
|
+
private
|
10
|
+
def retrieve_arguments(mapping)
|
11
|
+
@context_params.retrieve_arguments(mapping,@command_base.method_argument_names())
|
12
|
+
end
|
13
|
+
|
14
|
+
def retrieve_option_hash(option_list)
|
15
|
+
ret = Hash.new
|
16
|
+
option_values = @context_params.retrieve_thor_options(option_list,@command_base.options)
|
17
|
+
option_values.each_with_index do |val,i|
|
18
|
+
unless val.nil?
|
19
|
+
key = option_list[i].to_s.gsub(/\!$/,'').to_sym
|
20
|
+
ret.merge!(key => val)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
ret
|
24
|
+
end
|
25
|
+
|
26
|
+
def post(url_path,body=nil)
|
27
|
+
@command_base.post(@command_base.rest_url(url_path),body)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
dtk_require('common_base')
|
2
|
+
module DTK; module Client; module Commands::Common
|
3
|
+
class CreateTarget < Base
|
4
|
+
# option_list is of form [:provider!, :region, :keypair, :security_group!] indcating what is optional and what is required
|
5
|
+
def execute(type,option_list)
|
6
|
+
# we use :target_id but that will return provider_id (another name for target template ID)
|
7
|
+
target_name = retrieve_arguments([:option_1])
|
8
|
+
iaas_properties = iaas_properties(type,option_list)
|
9
|
+
provider = iaas_properties.delete(:provider)
|
10
|
+
post_body = {
|
11
|
+
:type => type.to_s,
|
12
|
+
:provider_id => provider,
|
13
|
+
:iaas_properties => iaas_properties
|
14
|
+
}
|
15
|
+
post_body.merge!(:target_name => target_name) if target_name
|
16
|
+
post 'target/create', post_body
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def iaas_properties(type,option_list)
|
21
|
+
iaas_properties = retrieve_option_hash(option_list)
|
22
|
+
special_processing_security_groups!(iaas_properties)
|
23
|
+
special_processing_region!(iaas_properties)
|
24
|
+
iaas_properties
|
25
|
+
end
|
26
|
+
|
27
|
+
def special_processing_region!(iaas_properties)
|
28
|
+
if region = iaas_properties[:region]
|
29
|
+
Shell::InteractiveWizard.validate_region(region)
|
30
|
+
end
|
31
|
+
iaas_properties
|
32
|
+
end
|
33
|
+
|
34
|
+
def special_processing_security_groups!(iaas_properties)
|
35
|
+
if security_group = iaas_properties[:security_group]
|
36
|
+
if security_group.end_with?(',')
|
37
|
+
raise DtkValidationError.new("Multiple security groups should be separated with ',' and without spaces between them (e.g. --security_groups gr1,gr2,gr3,...) ")
|
38
|
+
end
|
39
|
+
security_groups = security_group.split(',')
|
40
|
+
|
41
|
+
unless security_groups.empty? || security_groups.size==1
|
42
|
+
iaas_properties.delete(:security_group)
|
43
|
+
iaas_properties.merge!(:security_group_set => security_groups)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
iaas_properties
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end; end; end
|
@@ -82,7 +82,7 @@ module DTK::Client
|
|
82
82
|
else
|
83
83
|
"Would you like to commit ALL the changes?"
|
84
84
|
end
|
85
|
-
confirmed_ok = Console.
|
85
|
+
confirmed_ok = Console.confirmation_prompt_simple(confirm_msg)
|
86
86
|
end
|
87
87
|
if (auto_commit || confirmed_ok)
|
88
88
|
if auto_commit
|
@@ -59,7 +59,7 @@ module DTK::Client
|
|
59
59
|
print_external_dependencies(external_dependencies, 'in the git repo')
|
60
60
|
end
|
61
61
|
|
62
|
-
|
62
|
+
OsUtil.print("Successfully installed #{ModuleUtil.module_name(module_type)} '#{ModuleUtil.join_name(@module_name, @module_namespace)}' from git.", :green)
|
63
63
|
end
|
64
64
|
|
65
65
|
def from_file()
|
@@ -36,9 +36,9 @@ module DTK::Client
|
|
36
36
|
inconsistent = external_dependencies["inconsistent"]||[]
|
37
37
|
possibly_missing = external_dependencies["possibly_missing"]||[]
|
38
38
|
|
39
|
-
OsUtil.print("There are inconsistent module dependencies mentioned
|
40
|
-
OsUtil.print("There are missing module dependencies mentioned
|
41
|
-
OsUtil.print("There are ambiguous module dependencies mentioned
|
39
|
+
OsUtil.print("There are inconsistent module dependencies mentioned #{location}: #{inconsistent.join(', ')}", :red) unless inconsistent.empty?
|
40
|
+
OsUtil.print("There are missing module dependencies mentioned #{location}: #{possibly_missing.join(', ')}", :yellow) unless possibly_missing.empty?
|
41
|
+
OsUtil.print("There are ambiguous module dependencies mentioned #{location}: '#{amb_sorted.join(', ')}'. One of the namespaces should be selected by editing the module_refs file", :yellow) if ambiguous && !ambiguous.empty?
|
42
42
|
end
|
43
43
|
|
44
44
|
private
|
@@ -222,6 +222,7 @@ module DTK::Client
|
|
222
222
|
end
|
223
223
|
|
224
224
|
def import_git_module_aux(context_params)
|
225
|
+
OsUtil.print('Retrieving git module data, please wait ...')
|
225
226
|
CommonModule::Import.new(self, context_params).from_git()
|
226
227
|
end
|
227
228
|
|
@@ -348,7 +349,7 @@ module DTK::Client
|
|
348
349
|
module_id, module_name = context_params.retrieve_arguments([REQ_MODULE_ID,REQ_MODULE_NAME,:option_1],method_argument_names)
|
349
350
|
|
350
351
|
catalog = 'dtkn'
|
351
|
-
version = options
|
352
|
+
version = options.version
|
352
353
|
module_type = get_module_type(context_params)
|
353
354
|
skip_recursive_pull = context_params.get_forwarded_options()[:skip_recursive_pull]
|
354
355
|
|
@@ -358,7 +359,12 @@ module DTK::Client
|
|
358
359
|
|
359
360
|
if catalog.to_s.eql?("dtkn")
|
360
361
|
clone_aux(module_type.to_sym, module_id, version, true, true) unless File.directory?(module_location)
|
361
|
-
opts = {
|
362
|
+
opts = {
|
363
|
+
:force => options.force?,
|
364
|
+
:version => version,
|
365
|
+
:remote_namespace => options.namespace,
|
366
|
+
:skip_recursive_pull => skip_recursive_pull
|
367
|
+
}
|
362
368
|
|
363
369
|
response = pull_from_remote_aux(module_type.to_sym, module_id, opts)
|
364
370
|
return response unless response.ok?
|
@@ -469,13 +475,22 @@ module DTK::Client
|
|
469
475
|
return response unless response.ok?
|
470
476
|
end
|
471
477
|
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
478
|
+
if target_remote['base_git_location']
|
479
|
+
OsUtil.print("Pushing local content to remote #{target_remote['base_git_url']} in folder #{target_remote['base_git_location']} ...")
|
480
|
+
return push_to_git_remote_location_aux(module_name, module_type.to_sym, version, {
|
481
|
+
:remote_repo_url => target_remote['base_git_url'],
|
482
|
+
:remote_repo_location => target_remote['base_git_location'],
|
483
|
+
:remote_branch => 'master',
|
484
|
+
:remote_repo => "#{target_remote['display_name']}--remote"
|
485
|
+
}, options.force?)
|
486
|
+
else
|
487
|
+
OsUtil.print("Pushing local content to remote #{target_remote['repo_url']} ... ", :yellow)
|
488
|
+
return push_to_git_remote_aux(module_name, module_type.to_sym, version, {
|
489
|
+
:remote_repo_url => target_remote['repo_url'],
|
490
|
+
:remote_branch => 'master',
|
491
|
+
:remote_repo => "#{target_remote['display_name']}--remote"
|
492
|
+
}, options.force?)
|
493
|
+
end
|
479
494
|
end
|
480
495
|
|
481
496
|
def push_dtkn_module_aux(context_params, internal_trigger=false)
|
@@ -616,6 +631,15 @@ module DTK::Client
|
|
616
631
|
|
617
632
|
module_name = context_params.retrieve_arguments(["#{module_type}_name".to_sym],method_argument_names)
|
618
633
|
namespace, name = get_namespace_and_name(module_name,':')
|
634
|
+
|
635
|
+
module_location = OsUtil.module_location(module_type, module_name, nil)
|
636
|
+
unless File.directory?(module_location)
|
637
|
+
if Console.confirmation_prompt("Module '#{module_name}' has not been cloned. Would you like to clone module now"+'?')
|
638
|
+
response = clone_aux(module_type.to_sym, module_id, nil, true)
|
639
|
+
return response unless response.ok?
|
640
|
+
end
|
641
|
+
end
|
642
|
+
|
619
643
|
response = Helper(:git_repo).cp_r_to_new_namespace(module_type, name, namespace, fork_namespace)
|
620
644
|
return response unless response.ok?
|
621
645
|
|
@@ -623,7 +647,7 @@ module DTK::Client
|
|
623
647
|
new_context_params.add_context_to_params(module_type, module_type)
|
624
648
|
new_context_params.method_arguments = ["#{fork_namespace}:#{name}"]
|
625
649
|
|
626
|
-
create_response =
|
650
|
+
create_response = DTK::Client::ContextRouter.routeTask(module_type, "import", new_context_params, @conn)
|
627
651
|
unless create_response.ok?
|
628
652
|
FileUtils.rm_rf("#{response['data']['module_directory']}")
|
629
653
|
return create_response
|
@@ -28,13 +28,13 @@ 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
|
31
|
+
OsUtil.print("Pulling changes from remote: #{remote_params[:remote_repo]} @ #{remote_params[:remote_repo_url]}")
|
32
32
|
|
33
33
|
if Helper(:git_repo).local_clone_dir_exists?(module_type,module_name,:full_module_name=>full_module_name,:version=>version)
|
34
34
|
unless rsa_pub_key
|
35
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)"
|
36
36
|
end
|
37
|
-
opts_perform_locally = remote_params.merge(:full_module_name => full_module_name)
|
37
|
+
opts_perform_locally = remote_params.merge(:full_module_name => full_module_name, :force => opts[:force])
|
38
38
|
PullFromRemote.perform_locally(self,module_type,module_id,module_name,opts_perform_locally)
|
39
39
|
else
|
40
40
|
# TODO: see if this works correctly
|
@@ -14,7 +14,7 @@ module DTK::Client
|
|
14
14
|
raise DtkError, "Puppet forge module name should be in format USERNAME-NAME" unless pf_module_name.match(NAME_REGEX)
|
15
15
|
|
16
16
|
response = poller_response do
|
17
|
-
post rest_url("component_module/install_puppet_forge_modules"),PostBody.new(post_body_hash)
|
17
|
+
post rest_url("component_module/install_puppet_forge_modules"), PostBody.new(post_body_hash)
|
18
18
|
end
|
19
19
|
|
20
20
|
return response unless response.ok?
|
@@ -35,6 +35,8 @@ module DTK::Client
|
|
35
35
|
post_body.merge!(:modification_type => opts[:modification_type]) if opts[:modification_type]
|
36
36
|
post_body.merge!(:force_parse => true) if options['force-parse'] || opts[:force_parse]
|
37
37
|
post_body.merge!(:update_from_includes => true) if opts[:update_from_includes]
|
38
|
+
post_body.merge!(:service_instance_module => true) if opts[:service_instance_module]
|
39
|
+
post_body.merge!(:current_branch_sha => opts[:current_branch_sha]) if opts[:current_branch_sha]
|
38
40
|
|
39
41
|
if opts[:set_parsed_false]
|
40
42
|
post_body.merge!(:set_parsed_false => true)
|
@@ -1,4 +1,7 @@
|
|
1
1
|
dtk_require_common_commands('thor/common')
|
2
|
+
dtk_require("../../../domain/git_adapter")
|
3
|
+
|
4
|
+
|
2
5
|
module DTK::Client
|
3
6
|
module PushToRemoteMixin
|
4
7
|
|
@@ -15,6 +18,38 @@ module DTK::Client
|
|
15
18
|
Response::Ok.new()
|
16
19
|
end
|
17
20
|
|
21
|
+
def push_to_git_remote_location_aux(full_module_name, module_type, version, opts, force = false)
|
22
|
+
opts.merge!(:force => force)
|
23
|
+
|
24
|
+
# staging dir which will be removed
|
25
|
+
temp_stage_dir = OsUtil.temp_git_remote_location()
|
26
|
+
content_dir = File::join(temp_stage_dir, opts[:remote_repo_location])
|
27
|
+
|
28
|
+
begin
|
29
|
+
# clone desired repo
|
30
|
+
::DTK::Client::GitAdapter.clone(opts[:remote_repo_url], temp_stage_dir, opts[:remote_branch])
|
31
|
+
# make sure that content dir exist
|
32
|
+
FileUtils.mkdir_p(content_dir)
|
33
|
+
# copy content of module to new dir (overriding everything in process)
|
34
|
+
module_location = OsUtil.module_location(module_type, full_module_name, version)
|
35
|
+
FileUtils.cp_r(File.join(module_location, '/.'), content_dir)
|
36
|
+
# remove git folder
|
37
|
+
FileUtils.rm_rf(File.join(content_dir, '.git'))
|
38
|
+
# now we push it
|
39
|
+
opts.merge!(:override_repo_dir_location => temp_stage_dir)
|
40
|
+
response = Helper(:git_repo).push_changes(module_type, full_module_name, version, opts)
|
41
|
+
return response unless response.ok?
|
42
|
+
|
43
|
+
if response.data(:diffs).empty?
|
44
|
+
raise DtkError, "No changes to push"
|
45
|
+
end
|
46
|
+
|
47
|
+
Response::Ok.new()
|
48
|
+
ensure
|
49
|
+
FileUtils.rm_rf(temp_stage_dir)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
18
53
|
def push_to_remote_aux(remote_module_info, module_type, force = false)
|
19
54
|
full_module_name = remote_module_info.data(:full_module_name)
|
20
55
|
version = remote_module_info.data(:version)
|
@@ -33,7 +33,7 @@ module DTK::Client
|
|
33
33
|
[response, key_exists_already]
|
34
34
|
end
|
35
35
|
|
36
|
-
def self.add_key(path_to_key, name=
|
36
|
+
def self.add_key(path_to_key, name='dtk-client')
|
37
37
|
match, matched_username = nil, nil
|
38
38
|
|
39
39
|
unless File.file?(path_to_key)
|
@@ -120,7 +120,7 @@ module DTK::Client
|
|
120
120
|
response, matched, matched_username = Account.add_key(path_to_key, name)
|
121
121
|
|
122
122
|
if matched
|
123
|
-
DTK::Client::OsUtil.print("Provided
|
123
|
+
DTK::Client::OsUtil.print("Provided SSH pub key has already been added.", :yellow)
|
124
124
|
elsif matched_username
|
125
125
|
DTK::Client::OsUtil.print("User ('#{matched_username}') already exists.", :yellow)
|
126
126
|
else
|
@@ -128,7 +128,7 @@ module DTK::Client
|
|
128
128
|
end
|
129
129
|
|
130
130
|
if response.ok? && !response.data(:registered_with_repoman)
|
131
|
-
OsUtil.print("Warning: We were not able to register your key with remote catalog!", :yellow)
|
131
|
+
OsUtil.print("Warning: We were not able to register your key with remote catalog! Contact DTK team for more infromation.", :yellow)
|
132
132
|
end
|
133
133
|
|
134
134
|
response.ok? ? nil : response
|
@@ -127,6 +127,7 @@ module DTK::Client
|
|
127
127
|
namespace, module_name = get_namespace_and_name(full_module_name, ModuleUtil::NAMESPACE_SEPERATOR)
|
128
128
|
module_type = get_module_type(context_params)
|
129
129
|
|
130
|
+
OsUtil.print('Retrieving puppet module metadata, please wait ...')
|
130
131
|
response = puppet_forge_install_aux(context_params, pf_module_name, module_name, namespace, nil, module_type)
|
131
132
|
|
132
133
|
@@invalidate_map << :component_module
|
@@ -262,16 +263,19 @@ module DTK::Client
|
|
262
263
|
publish_module_aux(context_params)
|
263
264
|
end
|
264
265
|
|
265
|
-
desc "COMPONENT-MODULE-NAME/ID pull-dtkn [-n NAMESPACE]", "Update local component module from remote repository."
|
266
|
-
method_option
|
267
|
-
:type
|
266
|
+
desc "COMPONENT-MODULE-NAME/ID pull-dtkn [-n NAMESPACE] [--force]", "Update local component module from remote repository."
|
267
|
+
method_option :namespace,:aliases => '-n',
|
268
|
+
:type => :string,
|
268
269
|
:banner => "NAMESPACE",
|
269
|
-
:desc
|
270
|
+
:desc => "Remote namespace"
|
271
|
+
method_option :force,:aliases => '-f',
|
272
|
+
:type => :boolean,
|
273
|
+
:desc => "Force pull",
|
274
|
+
:default => false
|
270
275
|
def pull_dtkn(context_params)
|
271
276
|
pull_dtkn_aux(context_params)
|
272
277
|
end
|
273
278
|
|
274
|
-
|
275
279
|
=begin
|
276
280
|
desc "COMPONENT-MODULE-NAME/ID chown REMOTE-USER", "Set remote module owner"
|
277
281
|
method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|