dtk-client 0.11.7 → 0.11.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -2
- data/dtk-client.gemspec +2 -2
- data/lib/cli/command/account/add_to_group.rb +33 -0
- data/lib/cli/command/account/chmod.rb +33 -0
- data/lib/cli/command/account/create_namespace.rb +32 -0
- data/lib/cli/command/account/delete_namespace.rb +32 -0
- data/lib/cli/command/account/list_namespaces.rb +30 -0
- data/lib/cli/command/account/remove_from_group.rb +33 -0
- data/lib/cli/command/account.rb +14 -1
- data/lib/cli/command/module/delete_from_remote.rb +5 -3
- data/lib/cli/command/module/install.rb +242 -102
- data/lib/cli/command/module/list_remotes.rb +1 -1
- data/lib/cli/command/module/publish.rb +3 -2
- data/lib/cli/command/module/pull_dtkn.rb +2 -2
- data/lib/cli/command/module/push.rb +2 -1
- data/lib/cli/command/module/push_dtkn.rb +3 -2
- data/lib/cli/command/module/unpublish.rb +42 -0
- data/lib/cli/command/module/update.rb +33 -0
- data/lib/cli/command/module.rb +3 -1
- data/lib/cli/command/token.rb +9 -3
- data/lib/cli/context.rb +7 -5
- data/lib/cli/directory_parser/file_system.rb +76 -36
- data/lib/cli/processor/plugin/gli.rb +2 -0
- data/lib/cli/version.rb +1 -1
- data/lib/client/error/subclasses.rb +12 -0
- data/lib/client/git_repo/adapter/git_gem.rb +3 -1
- data/lib/client/operation/account/add_to_group.rb +29 -0
- data/lib/client/operation/account/chmod.rb +29 -0
- data/lib/client/operation/account/create_namespace.rb +29 -0
- data/lib/client/operation/account/delete_namespace.rb +29 -0
- data/lib/client/operation/account/list_namespaces.rb +29 -0
- data/lib/client/operation/account/remove_from_group.rb +29 -0
- data/lib/client/operation/account.rb +14 -1
- data/lib/client/operation/client_module_dir/git_repo/internal.rb +4 -22
- data/lib/client/operation/client_module_dir/git_repo.rb +5 -6
- data/lib/client/operation/client_module_dir/service_instance/internal/module_info.rb +67 -0
- data/lib/client/operation/client_module_dir/service_instance/internal.rb +106 -0
- data/lib/client/operation/client_module_dir/service_instance.rb +30 -0
- data/lib/client/operation/client_module_dir.rb +5 -0
- data/lib/client/operation/module/clone_module.rb +2 -2
- data/lib/client/operation/module/delete_from_remote.rb +7 -31
- data/lib/client/operation/module/install/dependent_modules/component_module.rb +1 -2
- data/lib/client/operation/module/install/dependent_modules/local_dependencies.rb +1 -1
- data/lib/client/operation/module/install/print_helper.rb +1 -1
- data/lib/client/operation/module/install.rb +25 -19
- data/lib/client/operation/module/install_from_catalog.rb +15 -29
- data/lib/client/operation/module/list_remotes.rb +4 -11
- data/lib/client/operation/module/publish.rb +17 -31
- data/lib/client/operation/module/pull_dtkn.rb +37 -28
- data/lib/client/operation/module/push.rb +69 -5
- data/lib/client/operation/module/push_dtkn.rb +25 -13
- data/lib/client/operation/module/stage.rb +3 -3
- data/lib/client/operation/module/unpublish.rb +60 -0
- data/lib/client/operation/module/update.rb +59 -0
- data/lib/client/operation/module.rb +23 -9
- data/lib/client/operation/service/clone_service.rb +3 -0
- data/lib/client/operation.rb +7 -0
- metadata +38 -5
@@ -95,26 +95,16 @@ module DTK::Client
|
|
95
95
|
repo.head_commit_sha
|
96
96
|
end
|
97
97
|
|
98
|
-
def self.
|
99
|
-
repo_url = args.required(:repo_url)
|
100
|
-
branch = args.required(:branch)
|
101
|
-
service_instance = args.required(:service_instance)
|
102
|
-
remove_existing = args[:remove_existing]
|
103
|
-
repo_dir = args[:repo_dir]
|
104
|
-
|
105
|
-
target_repo_dir = create_service_dir(service_instance, :remove_existing => remove_existing, :path => repo_dir)
|
98
|
+
def self.clone(repo_url, target_repo_dir, branch)
|
106
99
|
begin
|
107
100
|
git_repo.clone(repo_url, target_repo_dir, branch)
|
108
101
|
rescue => e
|
109
|
-
#cleanup by deleting directory
|
110
|
-
|
111
102
|
FileUtils.rm_rf(target_repo_dir) if File.directory?(target_repo_dir)
|
112
|
-
# Log error details
|
113
103
|
Logger.instance.error_pp(e.message, e.backtrace)
|
114
|
-
|
115
|
-
# User-friendly error
|
104
|
+
|
116
105
|
raise Error::Usage, "Clone to directory '#{target_repo_dir}' failed"
|
117
106
|
end
|
107
|
+
|
118
108
|
target_repo_dir
|
119
109
|
end
|
120
110
|
|
@@ -127,15 +117,7 @@ module DTK::Client
|
|
127
117
|
repo_dir = args[:repo_dir]
|
128
118
|
|
129
119
|
target_repo_dir = create_module_dir(module_type, module_name, :remove_existing => remove_existing, :path => repo_dir)
|
130
|
-
|
131
|
-
git_repo.clone(repo_url, target_repo_dir, branch)
|
132
|
-
rescue => e
|
133
|
-
FileUtils.rm_rf(target_repo_dir) if File.directory?(target_repo_dir)
|
134
|
-
Logger.instance.error_pp(e.message, e.backtrace)
|
135
|
-
|
136
|
-
raise Error::Usage, "Clone to directory '#{target_repo_dir}' failed"
|
137
|
-
end
|
138
|
-
|
120
|
+
clone(repo_url, target_repo_dir, branch)
|
139
121
|
target_repo_dir
|
140
122
|
end
|
141
123
|
|
@@ -34,9 +34,12 @@ module DTK::Client
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
def self.
|
37
|
+
def self.clone(args)
|
38
38
|
wrap_operation(args) do |args|
|
39
|
-
|
39
|
+
repo_url = args.required(:repo_url)
|
40
|
+
target_repo_dir = args.required(:target_repo_dir)
|
41
|
+
branch = args.required(:branch)
|
42
|
+
response_data_hash(:target_repo_dir => Internal.clone(repo_url, target_repo_dir, branch))
|
40
43
|
end
|
41
44
|
end
|
42
45
|
|
@@ -235,10 +238,6 @@ module DTK::Client
|
|
235
238
|
Internal::Dtkn.repo_with_remote(info_type, repo_dir, add_remote: args[:add_remote])
|
236
239
|
end
|
237
240
|
|
238
|
-
def self.response_data_hash(hash = {})
|
239
|
-
hash.inject({}) { |h, (k, v)| h.merge(k.to_s => v) }
|
240
|
-
end
|
241
|
-
|
242
241
|
end
|
243
242
|
end
|
244
243
|
end
|
@@ -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
|
19
|
+
class Operation::ClientModuleDir
|
20
|
+
class ServiceInstance::Internal
|
21
|
+
class ModuleInfo
|
22
|
+
def initialize(module_info_hash)
|
23
|
+
@module_info_hash = module_info_hash
|
24
|
+
end
|
25
|
+
|
26
|
+
def repo_url
|
27
|
+
index(:repo, :url)
|
28
|
+
end
|
29
|
+
|
30
|
+
def branch
|
31
|
+
index(:branch, :name)
|
32
|
+
end
|
33
|
+
|
34
|
+
def module_name
|
35
|
+
index(:module, :name)
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
|
40
|
+
attr_reader :module_info_hash
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def index(index1, index2)
|
45
|
+
index?(index1, index2) || raise_error_missing_key(index1, index2)
|
46
|
+
end
|
47
|
+
|
48
|
+
def index?(index1, index2)
|
49
|
+
(self.module_info_hash[index1.to_s] || {})[index2.to_s]
|
50
|
+
end
|
51
|
+
|
52
|
+
def raise_error_missing_key(index1, index2)
|
53
|
+
if module_name = index?(:module, :name)
|
54
|
+
if module_namespace = index?(:module, :namespace)
|
55
|
+
module_name = "#{module_name}:#{module_namespace}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
module_name ||= 'module'
|
59
|
+
raise Error, "Unexpected that #{module_name}[#{index1}][#{index2}] is nil"
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
@@ -0,0 +1,106 @@
|
|
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
|
19
|
+
class Operation::ClientModuleDir
|
20
|
+
class ServiceInstance
|
21
|
+
# All Internal methods do not have wrap_operation and can only be accessed by a method that wraps it
|
22
|
+
class Internal < self
|
23
|
+
require_relative('internal/module_info')
|
24
|
+
|
25
|
+
def initialize(args)
|
26
|
+
@base_module = args.required(:base_module)
|
27
|
+
@nested_modules = args.required(:nested_modules)
|
28
|
+
@service_instance = args.required(:service_instance)
|
29
|
+
@remove_existing = args[:remove_existing]
|
30
|
+
@repo_dir = args[:repo_dir]
|
31
|
+
end
|
32
|
+
private :initialize
|
33
|
+
|
34
|
+
def self.clone(args)
|
35
|
+
new(args).clone
|
36
|
+
end
|
37
|
+
|
38
|
+
def clone
|
39
|
+
@target_repo_dir = clone_base_module
|
40
|
+
@nested_module_base = make_nested_module_base
|
41
|
+
self.nested_modules.each { |nested_module| clone_nested_module(nested_module) }
|
42
|
+
self.target_repo_dir
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
attr_reader :base_module, :nested_modules, :service_instance, :remove_existing, :repo_dir
|
48
|
+
|
49
|
+
def target_repo_dir
|
50
|
+
@target_repo_dir || raise(Error, "Unexpected that @target_repo_dir is nil")
|
51
|
+
end
|
52
|
+
|
53
|
+
def nested_module_base
|
54
|
+
@nested_module_base || raise(Error, "Unexpected that @nested_module_base is nil")
|
55
|
+
end
|
56
|
+
|
57
|
+
def possible_nested_module_base_dirs
|
58
|
+
self.class.possible_nested_module_base_dirs
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def clone_base_module
|
64
|
+
module_info = ModuleInfo.new(self.base_module)
|
65
|
+
target_repo_dir = self.class.create_service_dir(self.service_instance, :remove_existing => self.remove_existing, :path => self.repo_dir)
|
66
|
+
clone_repo(module_info, target_repo_dir)
|
67
|
+
target_repo_dir
|
68
|
+
end
|
69
|
+
|
70
|
+
def clone_nested_module(nested_module_hash)
|
71
|
+
module_info = ModuleInfo.new(nested_module_hash)
|
72
|
+
nested_repo_dir = "#{self.nested_module_base}/#{module_info.module_name}"
|
73
|
+
clone_repo(module_info, nested_repo_dir)
|
74
|
+
end
|
75
|
+
|
76
|
+
def make_nested_module_base
|
77
|
+
unless nested_module_base = find_unused_path?(self.possible_nested_module_base_dirs)
|
78
|
+
raise Error::Usage, "The module must not have files/directories that conflict with each of #{self.possible_nested_module_base_dirs.join(', ')}"
|
79
|
+
end
|
80
|
+
FileUtils.mkdir_p(nested_module_base)
|
81
|
+
nested_module_base
|
82
|
+
end
|
83
|
+
|
84
|
+
def find_unused_path?(dirs)
|
85
|
+
dirs.map { |dir| "#{self.target_repo_dir}/#{dir}" }.find { |full_path| ! File.exists?(full_path) }
|
86
|
+
end
|
87
|
+
|
88
|
+
def clone_repo(module_info, target_repo_dir)
|
89
|
+
clone_args = {
|
90
|
+
:repo_url => module_info.repo_url,
|
91
|
+
:branch => module_info.branch,
|
92
|
+
:target_repo_dir => target_repo_dir
|
93
|
+
}
|
94
|
+
response = ClientModuleDir::GitRepo.clone(clone_args)
|
95
|
+
raise Error::Usage, response.data unless response.ok?
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.possible_nested_module_base_dirs
|
99
|
+
@possible_nested_module_base_dirs ||= ::DTK::DSL::DirectoryType::ServiceInstance::NestedModule.possible_paths
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
@@ -0,0 +1,30 @@
|
|
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
|
19
|
+
class Operation::ClientModuleDir
|
20
|
+
# Operations for managing service instance folder content
|
21
|
+
class ServiceInstance < self
|
22
|
+
require_relative('service_instance/internal')
|
23
|
+
def self.clone(args)
|
24
|
+
wrap_operation(args) do |args|
|
25
|
+
response_data_hash(:target_repo_dir => Internal.clone(args))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -22,6 +22,7 @@ module DTK::Client
|
|
22
22
|
# Operations for managing module folders
|
23
23
|
class ClientModuleDir < self
|
24
24
|
require_relative('client_module_dir/git_repo')
|
25
|
+
require_relative('client_module_dir/service_instance')
|
25
26
|
|
26
27
|
NAMESPACE_SEPERATOR = ':'
|
27
28
|
# opts can have keys
|
@@ -121,6 +122,10 @@ module DTK::Client
|
|
121
122
|
|
122
123
|
private
|
123
124
|
|
125
|
+
def self.response_data_hash(hash = {})
|
126
|
+
hash.inject({}) { |h, (k, v)| h.merge(k.to_s => v) }
|
127
|
+
end
|
128
|
+
|
124
129
|
def self.base_path(type)
|
125
130
|
path =
|
126
131
|
case type.to_sym
|
@@ -34,7 +34,7 @@ module DTK::Client
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def clone_module
|
37
|
-
unless module_info = module_version_exists?(@module_ref, :
|
37
|
+
unless module_info = module_version_exists?(@module_ref, :remote_info => false, :rsa_pub_key => SSHUtil.rsa_pub_key_content)
|
38
38
|
raise Error::Usage, "DTK module '#{@module_ref.pretty_print}' does not exist on the DTK Server."
|
39
39
|
end
|
40
40
|
|
@@ -100,7 +100,7 @@ module DTK::Client
|
|
100
100
|
end
|
101
101
|
|
102
102
|
if remote_module_info && remote_module_info.data(:service_info)
|
103
|
-
!module_version_exists?(@module_ref
|
103
|
+
!module_version_exists?(@module_ref)
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
@@ -34,40 +34,16 @@ module DTK::Client
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def delete_from_remote(opts = {})
|
37
|
-
query_string_hash = QueryStringHash.new(
|
38
|
-
:module_name => module_ref.module_name,
|
39
|
-
:namespace => module_ref.namespace,
|
40
|
-
:rsa_pub_key => SSHUtil.rsa_pub_key_content,
|
41
|
-
:force? => opts[:force]
|
42
|
-
)
|
43
|
-
|
44
|
-
unless version = module_ref.version
|
45
|
-
remotes = Operation::Module.list_remotes({})
|
46
|
-
|
47
|
-
selected_module = remotes.data.find{ |vr| vr['display_name'].eql?("#{module_ref.namespace}/#{module_ref.module_name}") }
|
48
|
-
raise Error::Usage, "Module '#{module_ref.namespace}/#{module_ref.module_name}' does not exist on repo manager!" unless selected_module
|
49
|
-
|
50
|
-
versions = selected_module['versions']
|
51
|
-
versions.map! { |v| v == 'base' ? 'master' : v }
|
52
|
-
|
53
|
-
if versions.size > 1
|
54
|
-
ret_version = Console.version_prompt(versions, "Select which module version to delete: ", { :add_all => true })
|
55
|
-
return unless ret_version
|
56
|
-
version = ret_version
|
57
|
-
else
|
58
|
-
version = versions.first
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
query_string_hash.merge!(:version => version)
|
63
|
-
query_string_hash.merge!(:versions => versions) if version.eql?('all')
|
64
|
-
|
65
37
|
unless opts[:skip_prompt]
|
66
38
|
module_ref_opts = { :namespace => module_ref.namespace }
|
67
|
-
|
68
|
-
return unless Console.prompt_yes_no("Are you sure you want to delete module '#{DTK::Common::PrettyPrintForm.module_ref(module_ref.module_name, module_ref_opts)}' from repo manager?", :add_options => true)
|
39
|
+
return unless Console.prompt_yes_no("Are you sure you want to delete module '#{DTK::Common::PrettyPrintForm.module_ref(module_ref.module_name, module_ref_opts)}' from dtk network?", :add_options => true)
|
69
40
|
end
|
70
|
-
|
41
|
+
|
42
|
+
module_info = {
|
43
|
+
name: module_ref.module_name,
|
44
|
+
namespace: module_ref.namespace
|
45
|
+
}
|
46
|
+
DtkNetworkClient::Delete.run(module_info)
|
71
47
|
|
72
48
|
nil
|
73
49
|
end
|
@@ -61,8 +61,7 @@ module DTK::Client; class Operation::Module
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def query_if_component_module_is_installed?
|
64
|
-
|
65
|
-
module_version_exists?(@module_ref, :type => :component_module)
|
64
|
+
module_version_exists?(@module_ref)
|
66
65
|
end
|
67
66
|
|
68
67
|
private
|
@@ -34,7 +34,7 @@ module DTK::Client; class Operation::Module
|
|
34
34
|
unless Install::DependentModules.resolved.include?("#{dep['namespace']}:#{dep['name']}")
|
35
35
|
Install::DependentModules.add_to_resolved("#{dep['namespace']}:#{dep['name']}")
|
36
36
|
dep_module_ref = Install::DependentModules.create_module_ref(dep, opts = {})
|
37
|
-
if dep_ref_info = module_version_exists?(dep_module_ref, :
|
37
|
+
if dep_ref_info = module_version_exists?(dep_module_ref, :remote_info => true, :rsa_pub_key => SSHUtil.rsa_pub_key_content)
|
38
38
|
new_print_helper = Install::PrintHelper.new(:module_ref => dep_module_ref, :source => :remote)
|
39
39
|
if dep_ref_info.data(:has_remote) && !prompt_helper.update_none
|
40
40
|
ComponentModule.install_or_pull?(dep_module_ref, prompt_helper, new_print_helper) unless dep_module_ref.is_base_module?
|
@@ -41,7 +41,7 @@ module DTK::Client; class Operation::Module
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def print_continuation_installing_base_module
|
44
|
-
print_continuation "Installing
|
44
|
+
print_continuation "Installing module '#{pretty_print_module}' from #{source_term}", :color => :yellow
|
45
45
|
end
|
46
46
|
|
47
47
|
def print_continuation_pulling_base_module
|
@@ -25,12 +25,12 @@ module DTK::Client
|
|
25
25
|
require_relative('install/dependent_modules')
|
26
26
|
require_relative('install/common_module')
|
27
27
|
|
28
|
-
def initialize(file_obj, module_ref, has_remote_repo)
|
28
|
+
def initialize(file_obj, module_ref, has_remote_repo, install_from)
|
29
29
|
@file_obj = file_obj
|
30
30
|
@base_module_ref = module_ref
|
31
31
|
@parsed_module = file_obj.parse_content(:common_module_summary)
|
32
32
|
@has_remote_repo = has_remote_repo
|
33
|
-
@print_helper = PrintHelper.new(:module_ref => @base_module_ref, :source =>
|
33
|
+
@print_helper = PrintHelper.new(:module_ref => @base_module_ref, :source => install_from || :local) # ? :remote : :local)
|
34
34
|
end
|
35
35
|
private :initialize
|
36
36
|
|
@@ -41,7 +41,8 @@ module DTK::Client
|
|
41
41
|
has_directory_param = args[:has_directory_param]
|
42
42
|
has_remote_repo = args[:has_remote_repo]
|
43
43
|
update_deps = args[:update_deps]
|
44
|
-
|
44
|
+
install_from = args[:install_from]
|
45
|
+
|
45
46
|
case update_deps
|
46
47
|
when "prompt"
|
47
48
|
update_deps = nil
|
@@ -55,7 +56,7 @@ module DTK::Client
|
|
55
56
|
file_obj = args.required(:base_dsl_file_obj).raise_error_if_no_content
|
56
57
|
end
|
57
58
|
|
58
|
-
new(file_obj, module_ref, has_remote_repo).install(:update_deps => update_deps, :no_update_deps => no_update_deps)
|
59
|
+
new(file_obj, module_ref, has_remote_repo, install_from).install(:update_deps => update_deps, :no_update_deps => no_update_deps)
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
@@ -67,25 +68,30 @@ module DTK::Client
|
|
67
68
|
raise Error::Usage, "No base module reference #{dsl_path_ref}"
|
68
69
|
end
|
69
70
|
|
70
|
-
if module_version_exists?(@base_module_ref
|
71
|
+
if module_version_exists?(@base_module_ref)
|
71
72
|
raise Error::Usage, "Module '#{@base_module_ref.print_form}' exists already"
|
72
73
|
end
|
73
74
|
|
74
|
-
unless dependent_modules.empty?
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
end
|
75
|
+
# unless dependent_modules.empty?
|
76
|
+
# begin
|
77
|
+
# if @has_remote_repo
|
78
|
+
# DependentModules.install(@base_module_ref, dependent_modules, opts)
|
79
|
+
# else
|
80
|
+
# DependentModules.install_with_local(@base_module_ref, dependent_modules, opts)
|
81
|
+
# end
|
82
|
+
# rescue TerminateInstall
|
83
|
+
# @print_helper.print_terminated_installation
|
84
|
+
# return nil
|
85
|
+
# end
|
86
|
+
# end
|
86
87
|
|
87
88
|
@print_helper.print_continuation_installing_base_module
|
88
|
-
|
89
|
+
|
90
|
+
base_path = @base_module_ref.client_dir_path || @file_obj.parent_dir?
|
91
|
+
self.class.handle_error base_path do
|
92
|
+
CommonModule.install(@base_module_ref, @file_obj, :has_remote_repo => @has_remote_repo)
|
93
|
+
end
|
94
|
+
|
89
95
|
@print_helper.print_done_message
|
90
96
|
nil
|
91
97
|
end
|
@@ -112,7 +118,7 @@ module DTK::Client
|
|
112
118
|
ModuleRef.new(:namespace => dep_namespace, :module_name => dep_module_name, :version => dep_version, :is_base_module => is_base_module)
|
113
119
|
end
|
114
120
|
unless base_component_module_found
|
115
|
-
if module_version_exists?(@base_module_ref
|
121
|
+
if module_version_exists?(@base_module_ref)
|
116
122
|
ret << ModuleRef.new(:namespace => namespace, :module_name => module_name, :version => version, :is_base_module => true)
|
117
123
|
end
|
118
124
|
end
|
@@ -19,11 +19,12 @@ module DTK::Client
|
|
19
19
|
class Operation::Module
|
20
20
|
class InstallFromCatalog < self
|
21
21
|
attr_reader :version, :module_ref, :target_repo_dir
|
22
|
-
def initialize(catalog, module_ref, directory_path, version, remote_module_info)
|
22
|
+
def initialize(catalog, module_ref, directory_path, version, remote_module_info, type)
|
23
|
+
@type = type
|
23
24
|
@catalog = catalog
|
24
25
|
@module_ref = module_ref
|
25
26
|
@directory_path = directory_path
|
26
|
-
@target_repo_dir = ClientModuleDir.create_module_dir_from_path(directory_path || OsUtil.current_dir)
|
27
|
+
@target_repo_dir = OsUtil.current_dir unless type == :dependency #ClientModuleDir.create_module_dir_from_path(directory_path || OsUtil.current_dir)
|
27
28
|
@version = version # if nil wil be dynamically updated along with version attribute of @module_ref
|
28
29
|
@remote_module_info = remote_module_info
|
29
30
|
end
|
@@ -35,38 +36,23 @@ module DTK::Client
|
|
35
36
|
version = args[:version]
|
36
37
|
directory_path = args[:directory_path]
|
37
38
|
remote_module_info = args[:remote_module_info]
|
38
|
-
|
39
|
+
type = args[:type]
|
39
40
|
# will create different classes for different catalog types when we add support for them
|
40
|
-
new('dtkn', module_ref, directory_path, version, remote_module_info).install_from_catalog
|
41
|
+
new('dtkn', module_ref, directory_path, version, remote_module_info, type).install_from_catalog
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
44
45
|
def install_from_catalog
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
unless @version
|
57
|
-
@version = @remote_module_info.required(:version)
|
58
|
-
@module_ref.version = @version
|
59
|
-
end
|
60
|
-
|
61
|
-
if module_version_exists?(@module_ref, :type => :common_module)
|
62
|
-
raise Error::Usage, "Module '#{@module_ref.print_form}' exists already"
|
63
|
-
end
|
64
|
-
|
65
|
-
create_repo_opts = { :repo_dir => @target_repo_dir, :commit_msg => "DTK client initialize" }
|
66
|
-
Operation::ClientModuleDir::GitRepo.create_repo_with_empty_commit(create_repo_opts)
|
67
|
-
LoadSource.fetch_transform_and_merge(@remote_module_info, self)
|
68
|
-
|
69
|
-
{:target_repo_dir => @target_repo_dir}
|
46
|
+
module_info = {
|
47
|
+
name: module_ref.module_name,
|
48
|
+
namespace: module_ref.namespace,
|
49
|
+
version: @version,
|
50
|
+
explicit_path: @directory_path,
|
51
|
+
repo_dir: @directory_path || @target_repo_dir
|
52
|
+
}
|
53
|
+
installed_modules = DtkNetworkClient::Install.run(module_info, type: @type)
|
54
|
+
|
55
|
+
{ :installed_modules => installed_modules }
|
70
56
|
end
|
71
57
|
|
72
58
|
end
|
@@ -19,19 +19,12 @@ module DTK::Client
|
|
19
19
|
class Operation::Module
|
20
20
|
class ListRemotes < self
|
21
21
|
def self.execute(args = Args.new)
|
22
|
-
wrap_operation(args) do |
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
:rsa_pub_key => SSHUtil.rsa_pub_key_content,
|
27
|
-
:module_namespace? => args[:module_namespace]
|
28
|
-
)
|
29
|
-
|
30
|
-
rest_get("#{BaseRoute}/remote_modules", query_string_hash)
|
22
|
+
wrap_operation(args) do |args|
|
23
|
+
namespace = args[:namespace]
|
24
|
+
response = DtkNetworkClient::List.run(namespace)
|
25
|
+
Response.new(response)
|
31
26
|
end.set_render_as_table!
|
32
27
|
end
|
33
28
|
end
|
34
29
|
end
|
35
30
|
end
|
36
|
-
|
37
|
-
|
@@ -30,46 +30,32 @@ module DTK::Client
|
|
30
30
|
def self.execute(args = Args.new)
|
31
31
|
wrap_operation(args) do |args|
|
32
32
|
module_ref = args.required(:module_ref)
|
33
|
+
base_dsl_file_obj = args.required(:base_dsl_file_obj)
|
33
34
|
directory_path = args[:directory_path]
|
34
|
-
|
35
|
+
update_lock_file = args[:update_lock_file]
|
36
|
+
new('dtkn', module_ref, directory_path).publish({file_obj: base_dsl_file_obj, update_lock_file: update_lock_file})
|
35
37
|
end
|
36
38
|
end
|
37
|
-
|
38
|
-
def publish
|
39
|
-
unless module_version_exists?(module_ref, :type => :common_module)
|
40
|
-
raise Error::Usage, "Module #{module_ref.print_form} does not exist on server"
|
41
|
-
end
|
42
|
-
|
43
|
-
error_msg = "To allow publish to go through, invoke 'dtk push' to push the changes to server before invoking publish again"
|
44
|
-
GitRepo.modified_with_diff?(target_repo_dir, { :error_msg => error_msg })
|
45
39
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
:version => @version,
|
50
|
-
:rsa_pub_key => SSHUtil.rsa_pub_key_content
|
51
|
-
)
|
40
|
+
def publish(opts = {})
|
41
|
+
file_obj = opts[:file_obj]
|
42
|
+
parsed_module = file_obj.parse_content(:common_module_summary)
|
52
43
|
|
53
|
-
|
44
|
+
module_info = {
|
45
|
+
name: module_ref.module_name,
|
46
|
+
namespace: module_ref.namespace,
|
47
|
+
version: @version,
|
48
|
+
repo_dir: @target_repo_dir
|
49
|
+
}
|
54
50
|
|
55
|
-
|
56
|
-
|
57
|
-
:namespace => module_ref.namespace,
|
58
|
-
:rsa_pub_key => SSHUtil.rsa_pub_key_content,
|
59
|
-
:version? => @version
|
60
|
-
)
|
61
|
-
remote_module_info = rest_get "#{BaseRoute}/remote_module_info", query_string_hash
|
51
|
+
response = DtkNetworkClient::Publish.run(module_info, parsed_module: parsed_module, development_mode: Config[:development_mode], update_lock_file: opts[:update_lock_file])
|
52
|
+
OsUtil.print_info("Module '#{module_ref.pretty_print}' has been published successfully.")
|
62
53
|
|
63
|
-
|
64
|
-
|
65
|
-
|
54
|
+
if Config[:development_mode]
|
55
|
+
ret_response = { namespace_id: response['namespace_short_id'], module_version_id: response['short_id'] }
|
56
|
+
return ret_response
|
66
57
|
end
|
67
58
|
|
68
|
-
# this is temporary until we implement push-dtkn from server instead of from client
|
69
|
-
# this part will fetch remote branches from repo manager after publish from server is finished
|
70
|
-
LoadSource.fetch_from_remote(remote_module_info, self)
|
71
|
-
|
72
|
-
OsUtil.print_info("'#{module_ref.pretty_print}' has been published successfully.")
|
73
59
|
nil
|
74
60
|
end
|
75
61
|
end
|