dtk-client 0.10.6 → 0.10.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGU5NTUzYWM4NzlhOTJiNWFmN2NhNjQwNjE1N2FkN2YwMzc4ZThkYQ==
4
+ Y2M4YzBhNDk4N2Q5NDM2ZTI5ZGY1NDNlN2VmYWFiMjU1MTRlMzc1Yg==
5
5
  data.tar.gz: !binary |-
6
- YjZkZDk4ODA4ZTliNDkyZjdiYjMwMWFiMGRmOWFlYzFjYzJhNzVjNA==
6
+ MzliN2I5MzNjMTFkM2Y0OWRhNjM4ZmE3MTYwZWMyMzUzMTNhMzFmMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTRhOWY0NTkwZTFlNTRlZWVhNDRmNGRjZTc3NmVlMzIzNjU5N2UzZDI1M2I1
10
- ZGRjZTQ4MDMxOGFkOGNkNGUyYzBlZDdhOWQzOWJiNmYzNDEzNmE0YjZkNDNk
11
- ZTVkYTZkMjdlZTVkMmI3YTk4MGY5YmU0Y2EzY2IxY2QyZDVjN2Q=
9
+ MjZmZDgzY2E0ODJhNGM1NTE0YzQ4M2Q0ZTVlNGRlZDVlY2VlZmU0ODllNWJj
10
+ MDgwNjY3MDE1MzM5NGM5YjBkZGViMTNmZDYyOWE2ZWVhMjQ2ZTk3YjdiNzky
11
+ YzU1OWU3NmExYjA0NmY5MzRjNDZmMjhiM2MzMWY2OWYzMTY4Y2U=
12
12
  data.tar.gz: !binary |-
13
- ZDVlYTQxM2Y0M2YwOGE1NjgwMWYzZTY4ZTBjOGEzNGMyYTA1OTE4NTlhZmVj
14
- ZmVhMmE0M2I4NjA3ZGVlNWUzN2NiZjVhNzk0ZTY5ODVmOGVhZWRhZTgwMjgy
15
- N2VlOWNhY2IyNWJjNjE0OGVlMTlmYjk0YWQ0NzY2MDc3MTdmMWE=
13
+ NWUxNzQ4MWU4NDNiOWQyMDk2NTZkNjE0M2FhYWY2NmE2YjdhOTJhZDA0OGY2
14
+ YzlhN2E1M2IxYTc3ZDNmM2ViOTVkYWVjY2Y0M2I5ZjBmMzFlMmRlNjU2ZmZj
15
+ ODc5ZmYyY2RlOTYxM2VlNDFmNmY2ZGRlNzRmYjFlY2U0YzZjNTQ=
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.10.6"
21
+ VERSION="0.10.7"
22
22
  end
23
23
  end
24
24
  end
@@ -297,8 +297,10 @@ module DTK::Client
297
297
  deletions = 0
298
298
  insertions = 0
299
299
  changes[0].each do |item|
300
- deletions += diff[item][:deletions]
301
- insertions += diff[item][:insertions]
300
+ if diff_item = diff[item]
301
+ deletions += (diff_item||{})[:deletions]
302
+ insertions += (diff_item||{})[:insertions]
303
+ end
302
304
  puts "\t#{item} | #{insertions + deletions} " + "+".colorize(:green) * insertions + "-".colorize(:red) * deletions
303
305
  end
304
306
  puts "\t#{file_changed} file changed, #{deletions} deletions(-), #{insertions} insertions(+)"
@@ -64,8 +64,12 @@ module DTK::Client
64
64
  end
65
65
 
66
66
  unless dependent_modules.empty?
67
- begin
68
- DependentModules.install(@base_module_ref, dependent_modules, :skip_prompt => opts[:skip_prompt])
67
+ begin
68
+ if @has_remote_repo
69
+ DependentModules.install(@base_module_ref, dependent_modules, :skip_prompt => opts[:skip_prompt])
70
+ else
71
+ DependentModules.install_with_local(@base_module_ref, dependent_modules, :skip_prompt => opts[:skip_prompt])
72
+ end
69
73
  rescue TerminateInstall
70
74
  @print_helper.print_terminated_installation
71
75
  return nil
@@ -21,6 +21,8 @@ module DTK::Client
21
21
  require_relative('dependent_modules/prompt_helper')
22
22
  require_relative('dependent_modules/component_dependency_tree')
23
23
  require_relative('dependent_modules/component_module')
24
+ require_relative('dependent_modules/local_dependencies')
25
+ require_relative('dependent_modules/remote_dependencies')
24
26
 
25
27
  BaseRoute = "modules"
26
28
  # opts can have keys:
@@ -41,6 +43,18 @@ module DTK::Client
41
43
  new(*args).install
42
44
  end
43
45
 
46
+ def self.install_with_local(*args)
47
+ new(*args).install_with_local
48
+ end
49
+
50
+ def self.resolved
51
+ @resolved ||= []
52
+ end
53
+
54
+ def self.add_to_resolved(module_name)
55
+ resolved << module_name
56
+ end
57
+
44
58
  def install
45
59
  @print_helper.print_getting_dependencies
46
60
  unified_module_refs = get_unified_dependent_module_refs
@@ -58,12 +72,86 @@ module DTK::Client
58
72
  end
59
73
  end
60
74
 
75
+ def install_with_local
76
+ @component_module_refs.each do |component_module_ref|
77
+ unless self.class.resolved.include?("#{component_module_ref.namespace}:#{component_module_ref.module_name}")
78
+ self.class.add_to_resolved("#{component_module_ref.namespace}:#{component_module_ref.module_name}")
79
+ if component_module_ref.is_master_version?
80
+ server_response = self.class.get_server_dependencies(component_module_ref)
81
+ if module_info = server_response.data(:module_info)
82
+ if module_info['has_remote']
83
+ new_print_helper = PrintHelper.new(:module_ref => component_module_ref, :source => :remote)
84
+ if @prompt_helper.pull_module_update?(new_print_helper)
85
+ ComponentModule.install_or_pull_new?(component_module_ref, @prompt_helper, new_print_helper) unless component_module_ref.is_base_module?
86
+ RemoteDependencies.install_or_pull?(component_module_ref, @prompt_helper, new_print_helper)
87
+ else
88
+ new_print_helper.print_using_installed_dependent_module
89
+ LocalDependencies.install_or_pull?(server_response, @prompt_helper, new_print_helper)
90
+ end
91
+ else
92
+ # does not have remote but exist locally
93
+ new_print_helper = PrintHelper.new(:module_ref => component_module_ref, :source => :remote)
94
+ new_print_helper.print_using_installed_dependent_module
95
+
96
+ LocalDependencies.install_or_pull?(server_response, @prompt_helper, new_print_helper)
97
+ end
98
+ else
99
+ remote_response = nil
100
+ new_print_helper = PrintHelper.new(:module_ref => component_module_ref, :source => :remote)
101
+ cmp = ComponentModule.new(component_module_ref, @prompt_helper, new_print_helper)
102
+ if component_module_ref.module_installed?(cmp)
103
+ if @prompt_helper.pull_module_update?(new_print_helper)
104
+ ComponentModule.install_or_pull_new?(component_module_ref, @prompt_helper, new_print_helper) unless component_module_ref.is_base_module?
105
+ else
106
+ new_print_helper.print_using_installed_dependent_module
107
+ end
108
+ else
109
+ ComponentModule.install_or_pull_new?(component_module_ref, @prompt_helper, new_print_helper) unless component_module_ref.is_base_module?
110
+ end
111
+ end
112
+ else
113
+ new_print_helper = PrintHelper.new(:module_ref => component_module_ref, :source => :remote)
114
+ new_print_helper.print_using_installed_dependent_module
115
+ cmp = ComponentModule.new(component_module_ref, @prompt_helper, new_print_helper)
116
+ unless component_module_ref.module_installed?(cmp)
117
+ ComponentModule.install_or_pull_new?(component_module_ref, @prompt_helper, new_print_helper)
118
+ end
119
+
120
+ server_response = self.class.get_server_dependencies(component_module_ref)
121
+ LocalDependencies.install_or_pull?(server_response, @prompt_helper, new_print_helper)
122
+ end
123
+ end
124
+ end
125
+ end
126
+
127
+ def self.create_module_ref(ref_hash, opts = {})
128
+ module_ref_hash = {
129
+ :namespace => ref_hash['namespace'],
130
+ :module_name => ref_hash['name'],
131
+ :version => ref_hash['version']
132
+ }
133
+ Install::ModuleRef.new(module_ref_hash)
134
+ end
135
+
61
136
  def get_unified_dependent_module_refs
62
137
  component_dependency_tree = ComponentDependencyTree.create(@base_module_ref, @component_module_refs, @print_helper)
63
138
  # returns an array of module_refs that have been unified so only one version and namespace per module name
64
139
  component_dependency_tree.resolve_conflicts_and_versions
65
140
  end
66
141
 
142
+ def get_local_modules_info
143
+ component_dependency_tree = ComponentDependencyTree.create(@base_module_ref, @component_module_refs, @print_helper, 'local')
144
+ component_dependency_tree.resolve_conflicts_and_versions
145
+ end
146
+
147
+ def self.get_server_dependencies(component_module_ref)
148
+ hash = {
149
+ :module_name => component_module_ref.module_name,
150
+ :namespace => component_module_ref.namespace,
151
+ :version? => component_module_ref.version
152
+ }
153
+ rest_get "#{BaseRoute}/module_info_with_local_dependencies", QueryStringHash.new(hash)
154
+ end
67
155
  end
68
156
  end
69
157
  end
@@ -31,6 +31,10 @@ module DTK::Client; class Operation::Module
31
31
  def self.install_or_pull?(module_ref, prompt_helper, print_helper)
32
32
  new(module_ref, prompt_helper, print_helper).install_or_pull?
33
33
  end
34
+
35
+ def self.install_or_pull_new?(module_ref, prompt_helper, print_helper)
36
+ new(module_ref, prompt_helper, print_helper).install_or_pull_new?
37
+ end
34
38
 
35
39
  def install_or_pull?
36
40
  if @module_ref.module_installed?(self)
@@ -44,6 +48,18 @@ module DTK::Client; class Operation::Module
44
48
  end
45
49
  end
46
50
 
51
+ def install_or_pull_new?
52
+ if @module_ref.module_installed?(self)
53
+ if @module_ref.is_master_version?
54
+ pull_module_update_new?
55
+ else
56
+ @print_helper.print_using_installed_dependent_module
57
+ end
58
+ else
59
+ install_module
60
+ end
61
+ end
62
+
47
63
  def query_if_component_module_is_installed?
48
64
  # TODO: :type => :component_module is for legacy; once we get past having legacy can change to :common_module
49
65
  module_version_exists?(@module_ref, :type => :component_module)
@@ -51,6 +67,27 @@ module DTK::Client; class Operation::Module
51
67
 
52
68
  private
53
69
 
70
+ def pull_module_update_new?
71
+ # return unless @prompt_helper.pull_module_update?(@print_helper)
72
+ @print_helper.print_continuation_pulling_dependency_update
73
+
74
+ post_body = {
75
+ :module_name => module_name,
76
+ :namespace => namespace,
77
+ :rsa_pub_key => SSHUtil.rsa_pub_key_content,
78
+ :version? => version,
79
+ :force => true # TODO: hardwired
80
+ }
81
+ response = rest_post "#{BaseRoute}/pull_component_info_from_remote", PostBody.new(post_body)
82
+
83
+ if (response.data(:diffs) || {}).empty?
84
+ # OsUtil.print("No changes to pull from remote.", :yellow) unless response['errors']
85
+ OsUtil.print("No changes to pull from remote.", :yellow)
86
+ else
87
+ OsUtil.print("Changes pulled from remote", :green)
88
+ end
89
+ end
90
+
54
91
  def pull_module_update?
55
92
  return unless @prompt_helper.pull_module_update?(@print_helper)
56
93
  @print_helper.print_continuation_pulling_dependency_update
@@ -0,0 +1,53 @@
1
+ #
2
+ # Copyright (C) 2010-2016 dtk contributors
3
+ #
4
+ # This file is part of the dtk project.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ module DTK::Client; class Operation::Module
19
+ class Install::DependentModules
20
+ class LocalDependencies < Operation::Module
21
+ include Install::Mixin
22
+ BaseRoute = "modules"
23
+
24
+ def initialize(module_ref, prompt_helper, print_helper)
25
+ @module_ref = module_ref
26
+ @prompt_helper = prompt_helper
27
+ @print_helper = print_helper.set_module_ref!(module_ref)
28
+ end
29
+ private :initialize
30
+
31
+ def self.install_or_pull?(server_response, prompt_helper, print_helper)
32
+ if dependencies = (server_response.data(:dependencies)||{})['required_modules']
33
+ dependencies.each do |dep|
34
+ unless Install::DependentModules.resolved.include?("#{dep['namespace']}:#{dep['name']}")
35
+ Install::DependentModules.add_to_resolved("#{dep['namespace']}:#{dep['name']}")
36
+ dep_module_ref = Install::DependentModules.create_module_ref(dep, opts = {})
37
+ if dep_ref_info = module_version_exists?(dep_module_ref, :type => :component_module, :remote_info => true, :rsa_pub_key => SSHUtil.rsa_pub_key_content)
38
+ new_print_helper = Install::PrintHelper.new(:module_ref => dep_module_ref, :source => :remote)
39
+ if dep_ref_info.data(:has_remote) && !prompt_helper.update_none
40
+ ComponentModule.install_or_pull?(dep_module_ref, prompt_helper, new_print_helper) unless dep_module_ref.is_base_module?
41
+ else
42
+ new_print_helper.print_using_installed_dependent_module
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end; end
52
+
53
+
@@ -0,0 +1,67 @@
1
+ #
2
+ # Copyright (C) 2010-2016 dtk contributors
3
+ #
4
+ # This file is part of the dtk project.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ module DTK::Client; class Operation::Module
19
+ class Install::DependentModules
20
+ class RemoteDependencies < Operation::Module
21
+ include Install::Mixin
22
+ BaseRoute = "modules"
23
+
24
+ def initialize(module_ref, prompt_helper, print_helper)
25
+ @module_ref = module_ref
26
+ @prompt_helper = prompt_helper
27
+ @print_helper = print_helper.set_module_ref!(module_ref)
28
+ end
29
+ private :initialize
30
+
31
+ def self.install_or_pull?(component_module_ref, prompt_helper, print_helper)
32
+ remote_response = nil
33
+ begin
34
+ hash = {
35
+ :module_name => component_module_ref.module_name,
36
+ :namespace => component_module_ref.namespace,
37
+ :rsa_pub_key => SSHUtil.rsa_pub_key_content,
38
+ :version? => component_module_ref.version
39
+ }
40
+ remote_response = rest_get "#{BaseRoute}/module_dependencies", QueryStringHash.new(hash)
41
+ rescue Error::ServerNotOkResponse => e
42
+ # temp fix for issue when dependent module is imported from puppet forge
43
+ if errors = e.response && e.response['errors']
44
+ remote_response = nil if errors.first.include?('not found')
45
+ else
46
+ raise e
47
+ end
48
+ end
49
+
50
+ if remote_required = remote_response.data(:required_modules)
51
+ remote_required.each do |req_module|
52
+ unless Install::DependentModules.resolved.include?("#{req_module['namespace']}:#{req_module['name']}")
53
+ Install::DependentModules.add_to_resolved("#{req_module['namespace']}:#{req_module['name']}")
54
+ req_ref = Install::DependentModules.create_module_ref(req_module)
55
+ new_print_helper = Install::PrintHelper.new(:module_ref => req_ref, :source => :remote)
56
+ if prompt_helper.pull_module_update?(new_print_helper)
57
+ ComponentModule.install_or_pull_new?(req_ref, prompt_helper, new_print_helper) unless req_ref.is_base_module?
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end; end
66
+
67
+
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.10.6
4
+ version: 0.10.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reactor8
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-05 00:00:00.000000000 Z
11
+ date: 2017-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dtk-common-core
@@ -259,7 +259,9 @@ files:
259
259
  - lib/client/operation/module/install/dependent_modules/component_dependency_tree/cache.rb
260
260
  - lib/client/operation/module/install/dependent_modules/component_dependency_tree/resolve_modules.rb
261
261
  - lib/client/operation/module/install/dependent_modules/component_module.rb
262
+ - lib/client/operation/module/install/dependent_modules/local_dependencies.rb
262
263
  - lib/client/operation/module/install/dependent_modules/prompt_helper.rb
264
+ - lib/client/operation/module/install/dependent_modules/remote_dependencies.rb
263
265
  - lib/client/operation/module/install/mixin.rb
264
266
  - lib/client/operation/module/install/module_ref.rb
265
267
  - lib/client/operation/module/install/print_helper.rb
@@ -385,7 +387,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
385
387
  version: '0'
386
388
  requirements: []
387
389
  rubyforge_project:
388
- rubygems_version: 2.4.8
390
+ rubygems_version: 2.6.11
389
391
  signing_key:
390
392
  specification_version: 4
391
393
  summary: DTK CLI client for DTK server interaction.