dtk-client 0.11.1 → 0.11.2

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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cli/command/module/clone.rb +27 -3
  3. data/lib/cli/command/module/stage.rb +5 -4
  4. data/lib/cli/command/service/link.rb +3 -2
  5. data/lib/cli/command/service/list_components.rb +1 -1
  6. data/lib/cli/command/service/pull.rb +3 -1
  7. data/lib/cli/command/service/push.rb +4 -1
  8. data/lib/cli/command/service/set_attribute.rb +5 -2
  9. data/lib/cli/command/service/set_default_target.rb +2 -2
  10. data/lib/cli/command/token.rb +5 -2
  11. data/lib/cli/version.rb +1 -1
  12. data/lib/client/load_source/component_info.rb +8 -1
  13. data/lib/client/load_source.rb +2 -2
  14. data/lib/client/operation/client_module_dir/git_repo/internal.rb +5 -3
  15. data/lib/client/operation/module/clone_module.rb +20 -1
  16. data/lib/client/operation/module/install/dependent_modules/component_dependency_tree/resolve_modules.rb +5 -4
  17. data/lib/client/operation/module/install/dependent_modules/component_dependency_tree.rb +2 -2
  18. data/lib/client/operation/module/install/dependent_modules.rb +1 -1
  19. data/lib/client/operation/module/pull_dtkn.rb +4 -3
  20. data/lib/client/operation/module/push.rb +9 -6
  21. data/lib/client/operation/module/push_dtkn/convert_source.rb +10 -0
  22. data/lib/client/operation/module/stage.rb +1 -1
  23. data/lib/client/operation/service/commit_and_push.rb +3 -2
  24. data/lib/client/operation/service/link.rb +2 -1
  25. data/lib/client/operation/service/list.rb +1 -1
  26. data/lib/client/operation/service/pull.rb +2 -1
  27. data/lib/client/operation/service/set_attribute.rb +4 -3
  28. data/lib/client/operation/service/ssh.rb +1 -1
  29. data/lib/client/operation/service/task_status/refresh_mode.rb +12 -5
  30. data/lib/client/operation/service/task_status/snapshot_mode.rb +2 -1
  31. data/lib/client/operation/service/task_status.rb +25 -10
  32. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 254aaacc97b6cc8dde9c36ad4b06d0af2cda66b1
4
- data.tar.gz: bb1fe62fcd2014f790ecab9a9b13aecbda698cd8
3
+ metadata.gz: 3981a13565726d82ae34679577877df68accfcab
4
+ data.tar.gz: 4dc01e0e0f1dce4285d4a8dc6faa445d1df0f66c
5
5
  SHA512:
6
- metadata.gz: a7c6b9d6679aa46239b60d9db561a1532c658a10f19b1df5eb963f7f7d62ff3996944a8a33a13fddcd63b3525be8f4f008e238bea58d77533148e21a6157c68e
7
- data.tar.gz: 18961ad5eb9205cfd73207d605469eeda4c0e16086a1fcbe630865cd9de40843db4871e768b8cc7034889701f8db686249cc6e7db0ad48cff765e4a013c9cf35
6
+ metadata.gz: f0a443fccb5533b633aeee895ead2c43c05292a2eaebf4936fc688ee2cb50a5e2b25a0a8b61199321cd29f12269f2959984bbc7ab1c86d4da6f4e4d04c95e418
7
+ data.tar.gz: 706bcf1c39b99602dc3409ebfb7cc0614dce6ebc693c95dd73f52ae6922d7e0f45d15fd1fc645a2dfc3e2d4cb7a6af8db44d810c16304b790b7c36a11d039d2c
@@ -25,12 +25,36 @@ module DTK::Client
25
25
  sc.flag Token.version
26
26
  sc.action do |_global_options, options, args|
27
27
  module_name = args[0]
28
- module_ref = module_ref_object_from_options_or_context(:module_ref => module_name, :version => options[:version])
28
+ version = options[:version]
29
+ module_ref = module_ref_object_from_options_or_context(:module_ref => module_name, :version => version)
30
+
29
31
  arg = {
30
- :module_ref => module_ref,
32
+ :module_ref => module_ref,
31
33
  :target_directory => args[1]
32
34
  }
33
- Operation::Module.clone_module(arg)
35
+ repo_dir_info = Operation::Module.clone_module(arg).data
36
+ repo_dir = repo_dir_info[:target_repo_dir]
37
+
38
+ # DTK-3088 - need this to pull service info for dependency module on clone
39
+ if repo_dir_info[:pull_service_info] && (version.nil? || version.eql?('master'))
40
+ repo_dir = repo_dir_info[:target_repo_dir]
41
+ module_ref = module_ref_object_from_options_or_context(:directory_path => repo_dir)
42
+
43
+ operation_args = {
44
+ :module_ref => module_ref,
45
+ :base_dsl_file_obj => @base_dsl_file_obj,
46
+ :has_directory_param => true,
47
+ :directory_path => repo_dir,
48
+ :update_deps => false,
49
+ :do_not_print => true,
50
+ :force => true
51
+ }
52
+
53
+ Operation::Module.pull_dtkn(operation_args)
54
+ Operation::Module.push(operation_args.merge(:method => "pulled"))
55
+ end
56
+
57
+ OsUtil.print_info("DTK module '#{module_ref.pretty_print}' has been successfully cloned into '#{repo_dir}'")
34
58
  end
35
59
  end
36
60
  end
@@ -23,9 +23,10 @@ module DTK::Client
23
23
  command_body c, :stage, 'Create a new service instance to refer to staged infrastructure that then can be deployed' do |sc|
24
24
  sc.flag Token.directory_path, :desc => 'Path to module directory where assembly is being staged from; not needed if in the module directory'
25
25
  sc.flag Token.service_name, :desc => 'If specified, name to use for new service instance; otherwise service instance name is auto-generated'
26
- sc.flag Token.parent_service_instance
26
+ sc.flag Token.context_service_instance
27
27
  sc.switch Token.force
28
- sc.switch Token.target
28
+ sc.switch Token.base
29
+ #sc.switch Token.target
29
30
  # on useful for testing in dev mode
30
31
  # sc.switch Token.purge, :desc => 'Overwrite any content that presently exists in the service instance directory to be created'
31
32
  # sc.flag Token.version
@@ -44,9 +45,9 @@ module DTK::Client
44
45
  :assembly_name => assembly_name,
45
46
  :service_name => service_name,
46
47
  :version => version,
47
- :target_service => options[:parent_service_instance],
48
+ :context_service => options[:context_service_instance],
48
49
  :remove_existing => options[:purge],
49
- :is_target => options[:target],
50
+ :is_target => options[:base],
50
51
  :force => force,
51
52
  :directory_path => directory_path
52
53
  }
@@ -24,7 +24,6 @@ module DTK::Client; module CLI
24
24
  c.arg Token::Arg.service, :optional => true
25
25
  command_body c, 'link', 'List component links in the service instance.' do |sc|
26
26
  sc.flag Token.directory_path, :desc => 'Absolute or relative path to service instance directory containing updates to pull; not need if in the service instance directory'
27
- sc.flag Token.link_name
28
27
  sc.switch Token.unlink
29
28
 
30
29
  sc.action do |_global_options, options, _args|
@@ -33,6 +32,7 @@ module DTK::Client; module CLI
33
32
  service = _args[2]
34
33
  service_instance = service_instance_in_options_or_context(options)
35
34
  link_name = options[:l] unless options[:l].nil?
35
+ options[:d].nil? ? service_instance_dir = @base_dsl_file_obj.parent_dir : service_instance_dir = options[:d]
36
36
 
37
37
  args = {
38
38
  :service_instance => service_instance,
@@ -40,7 +40,8 @@ module DTK::Client; module CLI
40
40
  :base_component => base_component,
41
41
  :dependent_component => dependent_component,
42
42
  :service => service,
43
- :link_name => link_name
43
+ :link_name => link_name,
44
+ :service_instance_dir => service_instance_dir
44
45
  }
45
46
 
46
47
  Operation::Service.link(args)
@@ -21,7 +21,7 @@ module DTK::Client; module CLI
21
21
  subcommand_def 'list-components' do |c|
22
22
  command_body c, 'components', 'List components associated with the service instance.' do |sc|
23
23
  sc.flag Token.directory_path, :desc => 'Absolute or relative path to service instance directory containing updates to pull; not need if in the service instance directory'
24
- sc.switch Token.dependencies, :desc => 'Show dependencies'
24
+ #sc.switch Token.dependencies, :desc => 'Show dependencies'
25
25
 
26
26
  sc.action do |_global_options, options, _args|
27
27
  service_instance = service_instance_in_options_or_context(options)
@@ -22,8 +22,10 @@ module DTK::Client; module CLI
22
22
  command_body c, :pull, 'Pulls any updates server made to service instance on to client directory' do |sc|
23
23
  sc.flag Token.directory_path, :desc => 'Absolute or relative path to service instance directory containing updates to pull; not need if in the service instance directory'
24
24
  sc.action do |_global_options, options, _args|
25
+ options[:d].nil? ? service_instance_dir = @base_dsl_file_obj.parent_dir : service_instance_dir = options[:d]
26
+
25
27
  service_instance = service_instance_in_options_or_context(options)
26
- Operation::Service.pull(:service_instance => service_instance)
28
+ Operation::Service.pull(:service_instance => service_instance, :service_instance_dir => service_instance_dir)
27
29
  end
28
30
  end
29
31
  end
@@ -24,9 +24,12 @@ module DTK::Client; module CLI
24
24
  sc.flag Token.commit_message
25
25
  sc.action do |_global_options, options, _args|
26
26
  service_instance = service_instance_in_options_or_context(options)
27
+ options[:d].nil? ? service_instance_dir = @base_dsl_file_obj.parent_dir : service_instance_dir = options[:d]
28
+
27
29
  args = {
28
30
  :service_instance => service_instance,
29
- :commit_message => options[:commit_message]
31
+ :commit_message => options[:commit_message],
32
+ :service_instance_dir => service_instance_dir
30
33
  }
31
34
  Operation::Service.commit_and_push(args)
32
35
  end
@@ -30,11 +30,14 @@ module DTK::Client; module CLI
30
30
 
31
31
  attribute_name = _args[0]
32
32
  options[:u] ? attribute_value = nil : attribute_value = _args[1]
33
-
33
+
34
+ options[:d].nil? ? service_instance_dir = @base_dsl_file_obj.parent_dir : service_instance_dir = options[:d]
35
+
34
36
  args = {
35
37
  :attribute_name => attribute_name,
36
38
  :service_instance => service_instance,
37
- :attribute_value => attribute_value
39
+ :attribute_value => attribute_value,
40
+ :service_instance_dir => @base_dsl_file_obj.parent_dir
38
41
  }
39
42
 
40
43
  Operation::Service.set_attribute(args)
@@ -19,8 +19,8 @@ module DTK::Client
19
19
  module CLI::Command
20
20
  module Service
21
21
  subcommand_def 'set-default-target' do |c|
22
- c.arg Token::Arg.target_instance
23
- command_body c, 'set-default-target', 'Create a new service instance to refer to staged infrastructure that then can be deployed' do |sc|
22
+ c.arg Token::Arg.service_name
23
+ command_body c, 'set-default-context', 'Create a new service instance to refer to staged infrastructure that then can be deployed' do |sc|
24
24
  sc.action do |_global_options, options, args|
25
25
  Operation::Service.set_default_target(:service_instance => args[0])
26
26
  end
@@ -34,7 +34,8 @@ module DTK::Client
34
34
  # Flag constructor args order: key, arg_name, desc, opts={}
35
35
  :commit_message => Flag.new(:m, 'COMMIT-MSG', 'Commit message'),
36
36
  :directory_path => Flag.new(:d, 'DIRECTORY-PATH', 'Directory path'),
37
- :parent_service_instance => Flag.new(:parent, 'PARENT', 'Parent service instance; if not specfied, the default target service instance serves as parent'),
37
+ :parent_service_instance => Flag.new(:parent, 'PARENT', 'Parent service instance; if not specified, the default context service instance serves as parent'),
38
+ :context_service_instance => Flag.new(:context, 'CONTEXT' ,'Context service instance; if not specified, the default service instance serves as context'),
38
39
  :module_ref => Flag.new(:m, ModuleRef::NamespaceModuleName.legal_form, 'Module name with namespace; not needed if command is executed from within the module directory'),
39
40
  :relative_path => Flag.new(:f, 'RELATIVE-FILE-PATH', 'Relative file path'),
40
41
  :service_instance => Flag.new(:s, 'SERVICE-INSTANCE', 'Service instance name'),
@@ -54,6 +55,7 @@ module DTK::Client
54
55
  # switches
55
56
  # Switch constructor args order: key, desc, opts={}
56
57
  :all => Switch.new(:all, 'All'),
58
+ :base => Switch.new(:base, 'Create base service instance'),
57
59
  :delete => Switch.new(:delete, 'Delete'),
58
60
  :force => Switch.new([:f, :force], 'Force'),
59
61
  :purge => Switch.new(:purge, 'Purge'),
@@ -85,7 +87,8 @@ module DTK::Client
85
87
  :format => 'FORMAT',
86
88
  :base_cmp => 'BASE-COMPONENT',
87
89
  :deps_on_cmp => 'DEPENDS-ON-COMPONENT',
88
- :service => 'SERVICE'
90
+ :service => 'SERVICE',
91
+ :service_name => 'SERVICE-NAME'
89
92
  }
90
93
 
91
94
  end
data/lib/cli/version.rb CHANGED
@@ -18,7 +18,7 @@
18
18
  module DTK
19
19
  module Client
20
20
  module CLI
21
- VERSION="0.11.1"
21
+ VERSION="0.11.2"
22
22
  end
23
23
  end
24
24
  end
@@ -19,8 +19,15 @@ module DTK::Client
19
19
  class LoadSource
20
20
  class ComponentInfo < self
21
21
  def fetch_and_cache_info
22
+ updated = false
22
23
  fetch_remote
23
- transform_from_component_info if merge_from_remote
24
+
25
+ if merge_from_remote
26
+ transform_from_component_info
27
+ updated = true
28
+ end
29
+
30
+ updated
24
31
  end
25
32
 
26
33
  def fetch_info
@@ -48,10 +48,10 @@ module DTK::Client
48
48
 
49
49
  if component_info = remote_module_info.data(:component_info)
50
50
  begin
51
- ComponentInfo.fetch_and_cache_info(transform_helper, component_info['remote_repo_url'], parent, force, use_theirs)
51
+ updated = ComponentInfo.fetch_and_cache_info(transform_helper, component_info['remote_repo_url'], parent, force, use_theirs)
52
52
  info_types_processed << ComponentInfo.info_type
53
53
 
54
- if parent.is_a?(Operation::Module::PullDtkn)
54
+ if parent.is_a?(Operation::Module::PullDtkn) && updated
55
55
  stage_and_commit(target_repo_dir, commit_msg([ComponentInfo.info_type]))
56
56
  delete_diffs(target_repo_dir)
57
57
  end
@@ -85,7 +85,8 @@ module DTK::Client
85
85
  service_instance = args.required(:service_instance)
86
86
  commit_message = args[:commit_message]
87
87
 
88
- repo_dir = ret_base_path(:service, service_instance)
88
+ #repo_dir = ret_base_path(:service, service_instance)
89
+ repo_dir = args[:service_instance_dir] || ret_base_path(:service, service_instance)
89
90
  repo = git_repo.new(repo_dir, :branch => branch)
90
91
  repo.stage_and_commit
91
92
  # TODO: want to switch over to using Dtk_Server::GIT_REMOTE rather than 'origin'
@@ -205,8 +206,9 @@ module DTK::Client
205
206
  repo_url = args.required(:repo_url)
206
207
  remote_branch = args.required(:branch)
207
208
  service_instance = args.required(:service_instance)
208
-
209
- repo_dir = ret_base_path(:service, service_instance)
209
+
210
+ #repo_dir = ret_base_path(:service, service_instance)
211
+ repo_dir = args[:service_instance_dir] || ret_base_path(:service, service_instance)
210
212
  repo = git_repo.new(repo_dir, :branch => remote_branch)
211
213
 
212
214
  repo.pull(repo.remotes.first, remote_branch)
@@ -62,7 +62,13 @@ module DTK::Client
62
62
  LoadSource.fetch_from_remote(module_info, self)
63
63
  end
64
64
 
65
- OsUtil.print_info("DTK module '#{@module_ref.pretty_print}' has been successfully cloned into '#{ret.required(:target_repo_dir)}'")
65
+ # OsUtil.print_info("DTK module '#{@module_ref.pretty_print}' has been successfully cloned into '#{ret.required(:target_repo_dir)}'")
66
+ target_repo_dir = ret.required(:target_repo_dir)
67
+ pull_service_info = check_if_pull_needed
68
+ {
69
+ target_repo_dir: target_repo_dir,
70
+ pull_service_info: pull_service_info
71
+ }
66
72
  end
67
73
 
68
74
  def version
@@ -79,6 +85,19 @@ module DTK::Client
79
85
  self.class.module_ref_post_body(@module_ref)
80
86
  end
81
87
 
88
+ def check_if_pull_needed
89
+ query_string_hash = QueryStringHash.new(
90
+ :module_name => @module_ref.module_name,
91
+ :namespace => @module_ref.namespace,
92
+ :rsa_pub_key => SSHUtil.rsa_pub_key_content,
93
+ :version => version||'master'
94
+ )
95
+ remote_module_info = rest_get "#{BaseRoute}/remote_module_info", query_string_hash
96
+ if remote_module_info.data(:service_info)
97
+ !module_version_exists?(@module_ref, :type => :service_module)
98
+ end
99
+ end
100
+
82
101
  end
83
102
  end
84
103
  end
@@ -18,15 +18,16 @@
18
18
  module DTK::Client; class Operation::Module
19
19
  class Install::DependentModules::ComponentDependencyTree
20
20
  class ResolveModules
21
- def initialize(parent)
21
+ def initialize(parent, opts = {})
22
22
  @print_helper = parent.print_helper
23
23
  @base_module_ref = parent.module_ref
24
24
  @cache = parent.cache
25
+ @opts = opts
25
26
  end
26
27
  private :initialize
27
28
 
28
- def self.resolve_conflicts(parent)
29
- new(parent).resolve_conflicts
29
+ def self.resolve_conflicts(parent, opts = {})
30
+ new(parent, opts).resolve_conflicts
30
31
  end
31
32
  def resolve_conflicts
32
33
  # TODO: change this simplistic method which does not take into accunt the nested structure.
@@ -46,7 +47,7 @@ module DTK::Client; class Operation::Module
46
47
 
47
48
  def process_when_base_module(module_ref)
48
49
  if @base_module_ref.exact_match?(module_ref)
49
- @print_helper.print_warning("Removing dependency '#{module_ref.pretty_print}' that referred to base module")
50
+ @print_helper.print_warning("Removing dependency '#{module_ref.pretty_print}' that referred to base module") unless @opts[:do_not_print]
50
51
  else
51
52
  @print_helper.print_warning("Removing conflicting dependency '#{module_ref.pretty_print}' that referred to base module '#{@base_module_ref.pretty_print}'")
52
53
  end
@@ -53,10 +53,10 @@ module DTK::Client; class Operation::Module
53
53
  end
54
54
 
55
55
  # resolves conflicts and returns an array of unified module_refs
56
- def resolve_conflicts_and_versions
56
+ def resolve_conflicts_and_versions(opts = {})
57
57
  # TODO: currently module refs al nailed as opposed to version contraints; when there are
58
58
  # version contraints; this methdo will take care of them
59
- ResolveModules.resolve_conflicts(self)
59
+ ResolveModules.resolve_conflicts(self, opts)
60
60
  end
61
61
 
62
62
  attr_reader :module_ref, :cache
@@ -136,7 +136,7 @@ module DTK::Client
136
136
  def get_unified_dependent_module_refs
137
137
  component_dependency_tree = ComponentDependencyTree.create(@base_module_ref, @component_module_refs, @print_helper)
138
138
  # returns an array of module_refs that have been unified so only one version and namespace per module name
139
- component_dependency_tree.resolve_conflicts_and_versions
139
+ component_dependency_tree.resolve_conflicts_and_versions(@opts)
140
140
  end
141
141
 
142
142
  def get_local_modules_info
@@ -44,6 +44,7 @@ module DTK::Client
44
44
  skip_prompt = args[:skip_prompt]
45
45
  force = args[:force]
46
46
  update_deps = args[:update_deps]
47
+ do_not_print = args[:do_not_print]
47
48
 
48
49
  case update_deps
49
50
  when "prompt"
@@ -58,7 +59,7 @@ module DTK::Client
58
59
  file_obj = base_dsl_file_obj.raise_error_if_no_content
59
60
  end
60
61
 
61
- new('dtkn', module_ref, directory_path, version, file_obj).pull_dtkn(:update_deps => update_deps, :no_update_deps => no_update_deps, :force => force)
62
+ new('dtkn', module_ref, directory_path, version, file_obj).pull_dtkn(:update_deps => update_deps, :no_update_deps => no_update_deps, :force => force, :do_not_print => do_not_print)
62
63
  end
63
64
  end
64
65
 
@@ -86,7 +87,7 @@ module DTK::Client
86
87
 
87
88
  unless dependent_modules.empty?
88
89
  begin
89
- Install::DependentModules.install(@module_ref, dependent_modules, :update_deps => opts[:update_deps], :no_update_deps => opts[:no_update_deps] , :mode => 'pull')
90
+ Install::DependentModules.install(@module_ref, dependent_modules, :update_deps => opts[:update_deps], :no_update_deps => opts[:no_update_deps] , :mode => 'pull', :do_not_print => opts[:do_not_print])
90
91
  # Install::DependentModules.install(@module_ref, dependent_modules, :skip_prompt => false, :mode => 'pull')
91
92
  rescue Install::TerminateInstall
92
93
  @print_helper.print_terminated_pulling
@@ -94,7 +95,7 @@ module DTK::Client
94
95
  end
95
96
  end
96
97
 
97
- @print_helper.print_continuation_pulling_base_module
98
+ @print_helper.print_continuation_pulling_base_module unless opts[:do_not_print]
98
99
  LoadSource.fetch_transform_and_merge(remote_module_info, self, :stage_and_commit_steps => true, :force => opts[:force], :use_theirs => true)
99
100
 
100
101
  nil
@@ -73,14 +73,17 @@ module DTK::Client
73
73
  end
74
74
 
75
75
  diffs = response.data(:diffs)
76
- if diffs && !diffs.empty?
77
- print = process_semantic_diffs(diffs, method)
78
- else
79
- print = process_semantic_diffs(existing_diffs, method)
76
+ unless args[:do_not_print]
77
+ if diffs && !diffs.empty?
78
+ print = process_semantic_diffs(diffs, method)
79
+ else
80
+ print = process_semantic_diffs(existing_diffs, method)
81
+ end
82
+
83
+ # if diffs is nil then indicate no diffs, otherwise render diffs in yaml
84
+ OsUtil.print_info("No Diffs to be #{method}.") if response.data(:diffs).nil? || !print
80
85
  end
81
86
 
82
- # if diffs is nil then indicate no diffs, otherwise render diffs in yaml
83
- OsUtil.print_info("No Diffs to be #{method}.") if response.data(:diffs).nil? || !print
84
87
  nil
85
88
  end
86
89
  end
@@ -58,6 +58,8 @@ module DTK::Client; class Operation::Module
58
58
  args = [transform_helper, ServiceInfo.info_type, service_info['remote_repo_url'], parent]
59
59
  service_file_path__content_array.each { |file| Operation::ClientModuleDir.create_file_with_content("#{service_file_path(target_repo_dir, file, *args)}", file[:content]) }
60
60
 
61
+ delete_assemblies?(service_file_path__content_array, target_repo_dir)
62
+
61
63
  commit_and_push_to_remote(repo, target_repo_dir, "master", "dtkn")
62
64
  end
63
65
  end
@@ -173,6 +175,14 @@ module DTK::Client; class Operation::Module
173
175
  msg
174
176
  end
175
177
 
178
+ def self.delete_assemblies?(service_file_path__content_array, target_repo_dir)
179
+ assembly_regex = Regexp.new("\.dtk\.assembly\.(yml|yaml)$")
180
+ assemblies = Dir.entries("#{target_repo_dir}/assemblies/").select { |file| file.match(assembly_regex) }
181
+ current_assemblies = assemblies.map { |assembly| "assemblies/#{assembly}" }
182
+ to_delete = current_assemblies - service_file_path__content_array.map { |file| file[:path] }
183
+ to_delete.each { |file| Operation::ClientModuleDir.rm_f("#{target_repo_dir}/#{file}") }
184
+ end
185
+
176
186
  def self.git_repo_operation
177
187
  Operation::ClientModuleDir::GitRepo
178
188
  end
@@ -31,7 +31,7 @@ module DTK::Client
31
31
  :module_name => module_ref.module_name,
32
32
  :assembly_name? => args.required(:assembly_name),
33
33
  :version? => args[:version],
34
- :target_service? => args[:target_service],
34
+ :target_service? => args[:context_service],
35
35
  :is_target? => args[:is_target]
36
36
  )
37
37
 
@@ -22,14 +22,15 @@ module DTK::Client
22
22
  def self.execute(args = Args.new)
23
23
  wrap_operation(args) do |args|
24
24
  service_instance = args.required(:service_instance)
25
-
25
+
26
26
  response = rest_get("#{BaseRoute}/#{service_instance}/repo_info")
27
27
 
28
28
  repo_info_args = Args.new(
29
29
  :service_instance => service_instance,
30
30
  :commit_message => args[:commit_message] || default_commit_message(service_instance),
31
31
  :branch => response.required(:branch, :name),
32
- :repo_url => response.required(:repo, :url)
32
+ :repo_url => response.required(:repo, :url),
33
+ :service_instance_dir => args[:service_instance_dir]
33
34
  )
34
35
 
35
36
  response = ClientModuleDir::GitRepo.commit_and_push_to_service_repo(repo_info_args)
@@ -40,7 +40,8 @@ module DTK::Client
40
40
  repo_info_args = Args.new(
41
41
  :service_instance => service_instance,
42
42
  :branch => response.required(:branch, :name),
43
- :repo_url => response.required(:repo, :url)
43
+ :repo_url => response.required(:repo, :url),
44
+ :service_instance_dir => args[:service_instance_dir]
44
45
  )
45
46
  ClientModuleDir::GitRepo.pull_from_service_repo(repo_info_args)
46
47
  nil
@@ -25,7 +25,7 @@ module DTK::Client
25
25
  :include_namespaces => true
26
26
  )
27
27
  rest_get("#{BaseRoute}/list", query_string_hash)
28
- end.set_render_as_table!
28
+ end.set_render_as_table!(nil, '* denotes that service instance is default context')
29
29
  end
30
30
  end
31
31
  end
@@ -26,7 +26,8 @@ module DTK::Client
26
26
  pull_args = {
27
27
  :service_instance => service_instance,
28
28
  :repo_url => response.required(:repo, :url),
29
- :branch => response.required(:branch, :name)
29
+ :branch => response.required(:branch, :name),
30
+ :service_instance_dir => args[:service_instance_dir]
30
31
  }
31
32
  ClientModuleDir::GitRepo.pull_from_service_repo(pull_args)
32
33
  end
@@ -23,7 +23,7 @@ module DTK::Client
23
23
  service_instance = args.required(:service_instance)
24
24
  attribute_name = args[:attribute_name]
25
25
  attribute_value = args[:attribute_value]
26
-
26
+
27
27
  query_string_hash = QueryStringHash.new(
28
28
  :pattern? => attribute_name,
29
29
  :value? => attribute_value
@@ -34,9 +34,10 @@ module DTK::Client
34
34
  repo_info_args = Args.new(
35
35
  :service_instance => service_instance,
36
36
  :branch => response.required(:branch, :name),
37
- :repo_url => response.required(:repo, :url)
37
+ :repo_url => response.required(:repo, :url),
38
+ :service_instance_dir => args[:service_instance_dir]
38
39
  )
39
-
40
+
40
41
  ClientModuleDir::GitRepo.pull_from_service_repo(repo_info_args)
41
42
  end
42
43
  nil
@@ -88,7 +88,7 @@ pp info_hash
88
88
  end
89
89
 
90
90
  unless remote_user ||= node_info[:default_login_user]
91
- raise Error::Usage, "Retry command with a specfic login user (a default login user could not be computed)"
91
+ raise Error::Usage, "A default Linux login user could not be computed. Retry the command with a specified login using the '-u LINUX-USER' option."
92
92
  end
93
93
 
94
94
  connection_string = "#{remote_user}@#{dns_address}"
@@ -27,13 +27,20 @@ module DTK::Client
27
27
  response = rest_call(opts)
28
28
  return response unless response.ok?
29
29
 
30
- # stop pulling when top level task succeds, fails or timeout
30
+ # TODO: clean this up
31
+ # stop polling when top level task succeeds, fails or timeout
31
32
  if response and response.data and response.data.first
33
+ if debug_mode?(response)
34
+ response.print_error_table!(true)
35
+ add_info_if_debug_mode!(response)
36
+ return response
37
+ end
38
+
32
39
  top_task_failed = response.data.first['status'].eql?('failed')
33
- is_pending = (response.data.select {|r|r["status"].nil? }).size > 0
34
- is_executing = (response.data.select {|r|r["status"].eql? "executing"}).size > 0
35
- is_failed = (response.data.select {|r|r["status"].eql? "failed"}).size > 0
36
- is_cancelled = response.data.first["status"].eql?("cancelled")
40
+ is_pending = (response.data.select {|r|r['status'].nil? }).size > 0
41
+ is_executing = (response.data.select {|r|r['status'].eql? 'executing'}).size > 0
42
+ is_failed = (response.data.select {|r|r['status'].eql? 'failed'}).size > 0
43
+ is_cancelled = response.data.first['status'].eql?('cancelled')
37
44
 
38
45
  is_cancelled = true if top_task_failed
39
46
 
@@ -21,7 +21,8 @@ module DTK::Client
21
21
  def task_status(opts = {})
22
22
  response = rest_call(opts)
23
23
  response.print_error_table!(true)
24
- response.set_render_as_table!
24
+ add_info_if_debug_mode!(response)
25
+ response
25
26
  end
26
27
  end
27
28
  end
@@ -31,24 +31,21 @@ module DTK::Client
31
31
  wrap_operation(args) do |args|
32
32
  service_instance = args.required(:service_instance)
33
33
  task_status_mode = args[:mode]
34
-
35
- if task_status_mode
36
- task_status_with_mode(task_status_mode.to_sym, service_instance)
37
- else
38
- response = rest_call(service_instance)
39
- response.print_error_table!(true)
40
- response.set_render_as_table!
41
- end
34
+ info = nil
35
+
36
+ task_status_mode ||= DEFAULT_MODE
37
+ task_status_with_mode(task_status_mode.to_sym, service_instance)
42
38
  end
43
39
  end
44
40
 
45
41
  def rest_call(opts = {})
46
42
  self.class.rest_call(@service_instance, opts)
47
43
  end
48
-
44
+
49
45
  private
50
46
 
51
- LEGAL_MODES = [:refresh, :snapshot, :stream]
47
+ DEFAULT_MODE = :snapshot
48
+ LEGAL_MODES = [:refresh, :snapshot, :stream]
52
49
  def self.task_status_with_mode(mode, service_instance, opts = {})
53
50
  case mode
54
51
  when :refresh
@@ -74,6 +71,24 @@ module DTK::Client
74
71
  )
75
72
  end
76
73
 
74
+ def add_info_if_debug_mode!(response)
75
+ debug_info_rows = debug_mode_rows(response).select { |row| (row['info'] || {})['message'] }
76
+ if debug_info_rows.size > 0
77
+ info_message = debug_info_rows.last['info']['message']
78
+ response.set_render_as_table!(nil, info_message)
79
+ else
80
+ response.set_render_as_table!
81
+ end
82
+ end
83
+
84
+ def debug_mode?(response)
85
+ debug_mode_rows(response).size > 0
86
+ end
87
+
88
+ def debug_mode_rows(response)
89
+ response['data'].select { |data_row| data_row['status'] == 'debugging' }
90
+ end
91
+
77
92
  end
78
93
  end
79
94
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtk-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reactor8
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-22 00:00:00.000000000 Z
11
+ date: 2017-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dtk-common-core