dtk-client 0.10.2 → 0.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.license_header +15 -0
- data/LICENSE +202 -0
- data/README.md +25 -2
- data/Rakefile +17 -1
- data/bin/dtk +18 -1
- data/lib/cli/command/account/add_ssh_key.rb +40 -0
- data/lib/cli/command/account/delete_ssh_key.rb +43 -0
- data/lib/cli/command/account/list_ssh_keys.rb +31 -0
- data/lib/cli/command/account/register_catalog_user.rb +31 -0
- data/lib/cli/command/account/set_catalog_credentials.rb +31 -0
- data/lib/cli/command/account/set_password.rb +31 -0
- data/lib/cli/command/account.rb +31 -0
- data/lib/cli/command/mixin.rb +1 -1
- data/lib/cli/command/module/delete_from_remote.rb +36 -0
- data/lib/cli/command/module/install.rb +15 -5
- data/lib/cli/command/module/publish.rb +34 -0
- data/lib/cli/command/module/pull_dtkn.rb +35 -0
- data/lib/cli/command/module/push_dtkn.rb +34 -0
- data/lib/cli/command/module/stage.rb +1 -1
- data/lib/cli/command/module/uninstall.rb +13 -7
- data/lib/cli/command/module.rb +14 -1
- data/lib/cli/command/options.rb +2 -0
- data/lib/cli/command/service/converge.rb +1 -1
- data/lib/cli/command/service/delete.rb +1 -1
- data/lib/cli/command/service/exec.rb +5 -2
- data/lib/cli/command/service/exec_sync.rb +4 -1
- data/lib/cli/command/service/{list_dependent_modules.rb → list_dependencies.rb} +3 -3
- data/lib/cli/command/service/uninstall.rb +11 -4
- data/lib/cli/command/service.rb +1 -1
- data/lib/cli/command/token.rb +3 -0
- data/lib/cli/command.rb +1 -1
- data/lib/cli/context/attributes.rb +1 -1
- data/lib/cli/context/type/account.rb +42 -0
- data/lib/cli/context/type/module.rb +2 -1
- data/lib/cli/context/type/service.rb +2 -1
- data/lib/cli/context.rb +82 -12
- data/lib/cli/version.rb +18 -2
- data/lib/client/git_repo/adapter/git_gem.rb +62 -4
- data/lib/client/git_repo.rb +33 -2
- data/lib/client/load_source/component_info.rb +44 -0
- data/lib/client/load_source/service_info.rb +47 -0
- data/lib/client/load_source.rb +148 -0
- data/lib/client/{util/module_ref.rb → module_ref.rb} +19 -0
- data/lib/client/operation/account/add_ssh_key.rb +47 -0
- data/lib/client/operation/account/delete_ssh_key.rb +41 -0
- data/lib/client/operation/account/list_ssh_keys.rb +28 -0
- data/lib/client/operation/account/register_catalog_user.rb +49 -0
- data/lib/client/operation/account/set_catalog_credentials.rb +32 -0
- data/lib/client/operation/account/set_password.rb +59 -0
- data/lib/client/operation/account.rb +7 -4
- data/lib/client/operation/client_module_dir/git_repo/internal/dtkn.rb +83 -0
- data/lib/client/operation/client_module_dir/git_repo/internal.rb +328 -0
- data/lib/client/operation/client_module_dir/git_repo.rb +73 -249
- data/lib/client/operation/client_module_dir.rb +2 -2
- data/lib/client/operation/module/clone_module.rb +41 -25
- data/lib/client/operation/module/delete_from_remote.rb +79 -0
- data/lib/client/operation/module/install/common_module.rb +10 -21
- data/lib/client/operation/module/install/dependent_modules/component_dependency_tree/cache.rb +47 -0
- data/lib/client/operation/module/install/dependent_modules/component_dependency_tree/resolve_modules.rb +69 -0
- data/lib/client/operation/module/install/dependent_modules/component_dependency_tree.rb +143 -0
- data/lib/client/operation/module/install/dependent_modules/component_module.rb +103 -0
- data/lib/client/operation/module/install/dependent_modules/prompt_helper.rb +54 -0
- data/lib/client/operation/module/install/dependent_modules.rb +65 -0
- data/lib/client/operation/module/install/mixin.rb +42 -0
- data/lib/client/operation/module/install/module_ref.rb +48 -0
- data/lib/client/operation/module/install/print_helper.rb +129 -0
- data/lib/client/operation/module/install.rb +68 -25
- data/lib/client/operation/module/install_from_catalog.rb +23 -32
- data/lib/client/operation/module/list.rb +4 -1
- data/lib/client/operation/module/publish.rb +78 -0
- data/lib/client/operation/module/pull_dtkn.rb +76 -0
- data/lib/client/operation/module/push.rb +16 -2
- data/lib/client/operation/module/push_dtkn/convert_source/component_info.rb +42 -0
- data/lib/client/operation/module/push_dtkn/convert_source/service_info.rb +47 -0
- data/lib/client/operation/module/push_dtkn/convert_source.rb +155 -0
- data/lib/client/operation/module/push_dtkn.rb +79 -0
- data/lib/client/operation/module/stage.rb +3 -2
- data/lib/client/operation/module/uninstall.rb +36 -0
- data/lib/client/operation/module.rb +23 -4
- data/lib/client/operation/service/converge.rb +3 -2
- data/lib/client/operation/service/delete.rb +2 -1
- data/lib/client/operation/service/destroy.rb +1 -1
- data/lib/client/operation/service/exec.rb +4 -0
- data/lib/client/operation/service/{list_dependent_modules.rb → list_dependencies.rb} +1 -1
- data/lib/client/operation/service/stage.rb +1 -1
- data/lib/client/operation/service/uninstall.rb +3 -3
- data/lib/client/operation/service.rb +1 -1
- data/lib/client/service_and_component_info/transform_from/info/component.rb +57 -0
- data/lib/client/service_and_component_info/transform_from/info/service.rb +53 -0
- data/lib/client/service_and_component_info/transform_from/info.rb +84 -0
- data/lib/client/service_and_component_info/transform_from.rb +47 -0
- data/lib/client/service_and_component_info/transform_to/info/component.rb +53 -0
- data/lib/client/service_and_component_info/transform_to/info/service.rb +49 -0
- data/lib/client/service_and_component_info/transform_to/info.rb +111 -0
- data/lib/client/service_and_component_info/transform_to.rb +49 -0
- data/lib/client/service_and_component_info.rb +26 -0
- data/lib/client/util/console.rb +22 -0
- data/lib/client/util/interactive_wizard.rb +90 -0
- data/lib/client/util.rb +18 -2
- data/lib/dtk_client.rb +5 -2
- metadata +63 -15
- data/lib/client/content_generator.rb +0 -189
- data/lib/client/operation/module/install/external_module.rb +0 -205
@@ -0,0 +1,79 @@
|
|
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::Module
|
20
|
+
class PushDtkn < self
|
21
|
+
require_relative('push_dtkn/convert_source')
|
22
|
+
|
23
|
+
attr_reader :version, :module_ref, :target_repo_dir, :base_dsl_file_obj
|
24
|
+
def initialize(catalog, module_ref, directory_path, version, base_dsl_file_obj)
|
25
|
+
@catalog = catalog
|
26
|
+
@module_ref = module_ref
|
27
|
+
@directory_path = directory_path
|
28
|
+
@target_repo_dir = directory_path || base_dsl_file_obj.parent_dir
|
29
|
+
@version = version # if nil wil be dynamically updated
|
30
|
+
@base_dsl_file_obj = base_dsl_file_obj
|
31
|
+
end
|
32
|
+
private :initialize
|
33
|
+
|
34
|
+
def self.execute(args = Args.new)
|
35
|
+
wrap_operation(args) do |args|
|
36
|
+
module_ref = args.required(:module_ref)
|
37
|
+
version = args[:version]
|
38
|
+
directory_path = args[:directory_path]
|
39
|
+
base_dsl_file_obj = args[:base_dsl_file_obj]
|
40
|
+
new('dtkn', module_ref, directory_path, version, base_dsl_file_obj).push_dtkn
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def push_dtkn
|
45
|
+
# TODO: DTK-2765: not sure if we need module to exist on server to do push-dtkn
|
46
|
+
unless module_version_exists?(@module_ref, :type => :common_module)
|
47
|
+
raise Error::Usage, "Module #{@module_ref.print_form} does not exist on server"
|
48
|
+
end
|
49
|
+
|
50
|
+
if ref_version = @version || module_ref.version
|
51
|
+
raise Error::Usage, "You are not allowed to push module version '#{ref_version}'!" unless ref_version.eql?('master')
|
52
|
+
end
|
53
|
+
|
54
|
+
error_msg = "To allow push-dtkn to go through, invoke 'dtk push' to push the changes to server before invoking push-dtkn again"
|
55
|
+
GitRepo.modified_with_diff?(@target_repo_dir, { :error_msg => error_msg })
|
56
|
+
|
57
|
+
query_string_hash = QueryStringHash.new(
|
58
|
+
:module_name => @module_ref.module_name,
|
59
|
+
:namespace => @module_ref.namespace,
|
60
|
+
:rsa_pub_key => SSHUtil.rsa_pub_key_content,
|
61
|
+
:version? => @version
|
62
|
+
)
|
63
|
+
|
64
|
+
remote_module_info = rest_get "#{BaseRoute}/remote_module_info", query_string_hash
|
65
|
+
|
66
|
+
unless @version
|
67
|
+
@version = remote_module_info.required(:version)
|
68
|
+
@module_ref.version = @version
|
69
|
+
end
|
70
|
+
|
71
|
+
ConvertSource.transform_and_commit(remote_module_info, self)
|
72
|
+
nil
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
|
@@ -34,8 +34,9 @@ module DTK::Client
|
|
34
34
|
:target_service? => args[:target_service],
|
35
35
|
:is_target? => args[:is_target]
|
36
36
|
)
|
37
|
-
|
38
|
-
|
37
|
+
|
38
|
+
error_msg = "To allow stage to go through, invoke 'dtk push' to push the changes to server before invoking stage again"
|
39
|
+
GitRepo.modified_with_diff?(directory_path || module_ref.client_dir_path, { :error_msg => error_msg }) unless force
|
39
40
|
service_name ||= rest_post("#{BaseRoute}/generate_service_name", post_body).data
|
40
41
|
base_path = ClientModuleDir.ret_base_path(:service, service_name)
|
41
42
|
|
@@ -21,7 +21,42 @@ module DTK::Client
|
|
21
21
|
def self.execute(args = Args.new)
|
22
22
|
wrap_operation(args) do |args|
|
23
23
|
module_ref = args.required(:module_ref)
|
24
|
+
name = args.required(:name)
|
25
|
+
version = args.required(:version)
|
26
|
+
|
27
|
+
unless name.nil?
|
28
|
+
query_string_hash = QueryStringHash.new(
|
29
|
+
:detail_to_include => ['remotes', 'versions']
|
30
|
+
)
|
31
|
+
response = rest_get("#{BaseRoute}/list", query_string_hash)
|
32
|
+
installed_modules = response.data
|
33
|
+
|
34
|
+
name.gsub!("/", ":")
|
35
|
+
installed_modules.each do |module_val|
|
36
|
+
if module_val["display_name"].eql? name
|
37
|
+
val = name.split(":")
|
38
|
+
if version.nil?
|
39
|
+
versions = module_val["versions"].split(",").map(&:strip)
|
40
|
+
if versions.size > 1
|
41
|
+
version = Console.version_prompt(versions, "Select which module version to uninstall: ", { :add_all => true})
|
42
|
+
module_val["versions"] if version.eql? "all"
|
43
|
+
else
|
44
|
+
version = module_val["versions"]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
module_opts = {
|
49
|
+
:module_name => val[1],
|
50
|
+
:namespace => val[0],
|
51
|
+
:version => version
|
52
|
+
}
|
53
|
+
module_ref = ModuleRef.new(module_opts)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
24
57
|
|
58
|
+
raise Error::Usage, "Invalid module name." if module_ref.nil?
|
59
|
+
|
25
60
|
opts = {
|
26
61
|
:namespace => module_ref.namespace,
|
27
62
|
:version => module_ref.version
|
@@ -36,6 +71,7 @@ module DTK::Client
|
|
36
71
|
:namespace => module_ref.namespace,
|
37
72
|
:version? => module_ref.version
|
38
73
|
)
|
74
|
+
|
39
75
|
rest_post("#{BaseRoute}/delete", post_body)
|
40
76
|
OsUtil.print_info("DTK module '#{DTK::Common::PrettyPrintForm.module_ref(module_ref.module_name, opts)}' has been deleted successfully.")
|
41
77
|
nil
|
@@ -18,7 +18,21 @@
|
|
18
18
|
module DTK::Client
|
19
19
|
class Operation
|
20
20
|
class Module < self
|
21
|
-
OPERATIONS = [
|
21
|
+
OPERATIONS = [
|
22
|
+
:install,
|
23
|
+
:list,
|
24
|
+
:list_assemblies,
|
25
|
+
:list_remotes,
|
26
|
+
:push,
|
27
|
+
:uninstall,
|
28
|
+
:clone_module,
|
29
|
+
:install_from_catalog,
|
30
|
+
:push_dtkn,
|
31
|
+
:stage,
|
32
|
+
:pull_dtkn,
|
33
|
+
:publish,
|
34
|
+
:delete_from_remote
|
35
|
+
]
|
22
36
|
OPERATIONS.each { |operation| require_relative("module/#{operation}") }
|
23
37
|
|
24
38
|
BaseRoute = 'modules'
|
@@ -27,13 +41,18 @@ module DTK::Client
|
|
27
41
|
|
28
42
|
private
|
29
43
|
|
30
|
-
def
|
31
|
-
self.class.
|
44
|
+
def module_version_exists?(module_ref, opts = {})
|
45
|
+
self.class.module_version_exists?(module_ref, opts)
|
32
46
|
end
|
33
47
|
|
34
|
-
def self.
|
48
|
+
def self.module_version_exists?(module_ref, opts = {})
|
35
49
|
type = opts[:type] || :common_module
|
36
50
|
query_string_hash = QueryStringHash.new(module_ref_hash(module_ref).merge(:module_type => type))
|
51
|
+
|
52
|
+
if ret_remote_info = opts[:remote_info]
|
53
|
+
query_string_hash.merge!(:remote_info => ret_remote_info, :rsa_pub_key => opts[:rsa_pub_key])
|
54
|
+
end
|
55
|
+
|
37
56
|
response = rest_get(BaseRoute, query_string_hash)
|
38
57
|
response.data.empty? ? nil : response
|
39
58
|
end
|
@@ -21,14 +21,15 @@ module DTK::Client
|
|
21
21
|
def self.execute(args = Args.new)
|
22
22
|
wrap_operation(args) do |args|
|
23
23
|
service_instance = args.required(:service_instance)
|
24
|
+
module_dir = args.required(:module_dir)
|
24
25
|
force = args[:force]
|
25
|
-
directory_path = args[:directory_path]
|
26
26
|
|
27
27
|
post_body = PostBody.new(
|
28
28
|
:service_instance => service_instance
|
29
29
|
)
|
30
30
|
|
31
|
-
|
31
|
+
error_msg = "To allow converge to go through, invoke 'dtk push' to push the changes to server before invoking converge again"
|
32
|
+
GitRepo.modified_with_diff?(module_dir, { :error_msg => error_msg }) unless force
|
32
33
|
violations = find_violations(service_instance)
|
33
34
|
return violations if violations
|
34
35
|
|
@@ -29,7 +29,8 @@ module DTK::Client
|
|
29
29
|
return false unless Console.prompt_yes_no("Are you sure you want to delete the content of service instance '#{service_instance}' ?", :add_options => true)
|
30
30
|
end
|
31
31
|
|
32
|
-
|
32
|
+
error_msg = "To allow delete to go through, invoke 'dtk push' to push the changes to server before invoking delete again"
|
33
|
+
GitRepo.modified_with_diff?(directory_path || @module_ref.client_dir_path, { :error_msg => error_msg }) unless force
|
33
34
|
post_body = PostBody.new(
|
34
35
|
:service_instance => service_instance,
|
35
36
|
:recursive? => recursive
|
@@ -29,7 +29,7 @@ module DTK::Client
|
|
29
29
|
post_body = PostBody.new(:service_instance => service_instance)
|
30
30
|
rest_post("#{BaseRoute}/delete", post_body)
|
31
31
|
|
32
|
-
ClientModuleDir.
|
32
|
+
ClientModuleDir.rm_f(args[:directory_path]) if args[:purge]
|
33
33
|
|
34
34
|
OsUtil.print_info("DTK module '#{service_instance}' has been deleted successfully.")
|
35
35
|
end
|
@@ -23,6 +23,7 @@ module DTK::Client
|
|
23
23
|
service_instance = args.required(:service_instance)
|
24
24
|
action = args.required(:action)
|
25
25
|
action_params = args[:action_params]
|
26
|
+
directory_path = args[:directory_path]
|
26
27
|
|
27
28
|
# parse params and return format { 'p_name1' => 'p_value1' , 'p_name2' => 'p_value2' }
|
28
29
|
task_params = parse_params?(action_params)||{}
|
@@ -33,6 +34,9 @@ module DTK::Client
|
|
33
34
|
task_params.merge!("node" => node)
|
34
35
|
end
|
35
36
|
|
37
|
+
error_msg = "To allow #{args[:command]} to go through, invoke 'dtk push' to push the changes to server before invoking #{args[:command]} again"
|
38
|
+
GitRepo.modified_with_diff?(directory_path, { :error_msg => error_msg })
|
39
|
+
|
36
40
|
post_body = PostBody.new(
|
37
41
|
:task_params? => task_params
|
38
42
|
)
|
@@ -35,7 +35,7 @@ module DTK::Client
|
|
35
35
|
:is_target? => args[:is_target]
|
36
36
|
)
|
37
37
|
|
38
|
-
|
38
|
+
GitRepo.modified?(directory_path || OsUtil.current_dir) unless force
|
39
39
|
service_name ||= rest_post("#{BaseRoute}/generate_service_name", post_body).data
|
40
40
|
base_path = ClientModuleDir.ret_base_path(:service, service_name)
|
41
41
|
|
@@ -22,7 +22,7 @@ module DTK::Client
|
|
22
22
|
wrap_operation(args) do |args|
|
23
23
|
service_instance = args.required(:service_instance)
|
24
24
|
recursive = args.required(:recursive)
|
25
|
-
|
25
|
+
delete = args.required(:delete)
|
26
26
|
|
27
27
|
unless args[:skip_prompt]
|
28
28
|
return false unless Console.prompt_yes_no("Are you sure you want to uninstall the infrastructure associated with '#{service_instance}' and delete this service instance from the server?", :add_options => true)
|
@@ -31,11 +31,11 @@ module DTK::Client
|
|
31
31
|
post_body = PostBody.new(
|
32
32
|
:service_instance => service_instance,
|
33
33
|
:recursive? => recursive,
|
34
|
-
:
|
34
|
+
:delete => delete
|
35
35
|
)
|
36
36
|
rest_post("#{BaseRoute}/uninstall", post_body)
|
37
37
|
|
38
|
-
ClientModuleDir.
|
38
|
+
ClientModuleDir.rm_f(args[:directory_path]) if args[:purge]
|
39
39
|
|
40
40
|
OsUtil.print_info("DTK module '#{service_instance}' has been uninstalled successfully.")
|
41
41
|
end
|
@@ -0,0 +1,57 @@
|
|
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 ServiceAndComponentInfo::TransformFrom::Info
|
20
|
+
class Component < self
|
21
|
+
def read_inputs_and_compute_outputs!
|
22
|
+
# Input component dsl file and module_ref filedslpdslp
|
23
|
+
if component_dsl_path = component_dsl_path()
|
24
|
+
add_content!(component_dsl_input_files_processor, component_dsl_path)
|
25
|
+
end
|
26
|
+
|
27
|
+
if module_refs_path = module_refs_path()
|
28
|
+
add_content!(module_ref_input_files_processor, module_refs_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
# compute and cache outputs
|
32
|
+
dtk_dsl_component_info_processor.compute_outputs!
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def info_type
|
38
|
+
:component_info
|
39
|
+
end
|
40
|
+
|
41
|
+
def dtk_dsl_component_info_processor
|
42
|
+
@dtk_dsl_info_processor
|
43
|
+
end
|
44
|
+
|
45
|
+
def component_dsl_path
|
46
|
+
matches = directory_file_paths.select { |path| component_dsl_input_files_processor.match?(path) }
|
47
|
+
raise Error, "Unexpected that there is not a unique component dsl file" if matches.size != 1
|
48
|
+
matches.first
|
49
|
+
end
|
50
|
+
|
51
|
+
def component_dsl_input_files_processor
|
52
|
+
@component_dsl_input_files_processor ||= input_files_processor(:component_dsl_file)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -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
|
19
|
+
class ServiceAndComponentInfo::TransformFrom::Info
|
20
|
+
class Service < self
|
21
|
+
def read_inputs_and_compute_outputs!
|
22
|
+
# Input assemblies and module_ref file
|
23
|
+
assembly_file_paths.each { |path| add_content!(assembly_input_files_processor, path) }
|
24
|
+
|
25
|
+
if module_refs_path = module_refs_path()
|
26
|
+
add_content!(module_ref_input_files_processor, module_refs_path)
|
27
|
+
end
|
28
|
+
|
29
|
+
# compute and cache outputs
|
30
|
+
dtk_dsl_service_info_processor.compute_outputs!
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def info_type
|
36
|
+
:service_info
|
37
|
+
end
|
38
|
+
|
39
|
+
def dtk_dsl_service_info_processor
|
40
|
+
@dtk_dsl_info_processor
|
41
|
+
end
|
42
|
+
|
43
|
+
def assembly_file_paths
|
44
|
+
directory_file_paths.select { |path| assembly_input_files_processor.match?(path) }
|
45
|
+
end
|
46
|
+
|
47
|
+
def assembly_input_files_processor
|
48
|
+
@assembly_input_files_processor ||= input_files_processor(:assemblies)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,84 @@
|
|
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
|
+
|
19
|
+
module DTK::Client
|
20
|
+
class ServiceAndComponentInfo::TransformFrom
|
21
|
+
class Info
|
22
|
+
require_relative('info/service')
|
23
|
+
require_relative('info/component')
|
24
|
+
|
25
|
+
attr_reader :input_file_paths
|
26
|
+
def initialize(content_dir, dtk_dsl_parse_helper)
|
27
|
+
@content_dir = content_dir
|
28
|
+
@dtk_dsl_info_processor = dtk_dsl_parse_helper.info_processor(info_type)
|
29
|
+
|
30
|
+
# dynamically computed
|
31
|
+
@input_file_paths = []
|
32
|
+
@directory_file_paths = nil # this will be all paths in module
|
33
|
+
end
|
34
|
+
private :initialize
|
35
|
+
|
36
|
+
def self.create(info_type, content_dir, dtk_dsl_parse_helper)
|
37
|
+
case info_type
|
38
|
+
when :service_info then Service.new(content_dir, dtk_dsl_parse_helper)
|
39
|
+
when :component_info then Component.new(content_dir, dtk_dsl_parse_helper)
|
40
|
+
else
|
41
|
+
fail Error, "Unexpected info_type '#{info_type}'"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def add_content!(input_files_processor, path)
|
48
|
+
@input_file_paths << path
|
49
|
+
input_files_processor.add_content!(path, get_raw_content?(path))
|
50
|
+
end
|
51
|
+
|
52
|
+
def input_files_processor(type)
|
53
|
+
@dtk_dsl_info_processor.indexed_input_files[type] || raise_missing_type_error(type)
|
54
|
+
end
|
55
|
+
|
56
|
+
def module_refs_path
|
57
|
+
matches = directory_file_paths.select { |path| module_ref_input_files_processor.match?(path) }
|
58
|
+
raise Error, "Unexpected that multiple module ref files" if matches.size > 1
|
59
|
+
matches.first
|
60
|
+
end
|
61
|
+
|
62
|
+
def module_ref_input_files_processor
|
63
|
+
@module_ref_input_files_processor ||= input_files_processor(:module_refs)
|
64
|
+
end
|
65
|
+
|
66
|
+
def get_raw_content?(file_path)
|
67
|
+
File.open(file_path).read if file_path and File.exists?(file_path)
|
68
|
+
end
|
69
|
+
|
70
|
+
def raise_missing_type_error(type)
|
71
|
+
raise Error, "Unexpected that no indexed_input_files of type '#{type}'"
|
72
|
+
end
|
73
|
+
|
74
|
+
def directory_file_paths
|
75
|
+
@directory_file_paths ||= Dir.glob("#{@content_dir}/**/*")
|
76
|
+
end
|
77
|
+
|
78
|
+
def get_raw_content?(file_path)
|
79
|
+
File.open(file_path).read if file_path and File.exists?(file_path)
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,47 @@
|
|
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
|
+
|
19
|
+
module DTK::Client
|
20
|
+
module ServiceAndComponentInfo
|
21
|
+
class TransformFrom
|
22
|
+
require_relative('transform_from/info')
|
23
|
+
|
24
|
+
def initialize(content_dir, module_ref, version)
|
25
|
+
@content_dir = content_dir
|
26
|
+
@module_ref = module_ref
|
27
|
+
@version = version
|
28
|
+
@dtk_dsl_parse_helper = dtk_dsl_transform_class.new(module_ref.namespace, module_ref.module_name, version)
|
29
|
+
end
|
30
|
+
|
31
|
+
def info_processor(info_type)
|
32
|
+
Info.create(info_type, @content_dir, @dtk_dsl_parse_helper)
|
33
|
+
end
|
34
|
+
|
35
|
+
def output_path_text_pairs
|
36
|
+
@dtk_dsl_parse_helper.output_path_text_pairs
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def dtk_dsl_transform_class
|
42
|
+
::DTK::DSL::ServiceAndComponentInfo::TransformFrom
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -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
|
19
|
+
class ServiceAndComponentInfo::TransformTo::Info
|
20
|
+
class Component < self
|
21
|
+
def read_inputs_and_compute_outputs!
|
22
|
+
# Input component dsl file and module_ref filedslpdslp
|
23
|
+
if component_dsl_path = component_dsl_path()
|
24
|
+
add_content!(component_dsl_input_files_processor, component_dsl_path)
|
25
|
+
end
|
26
|
+
|
27
|
+
# compute and cache outputs
|
28
|
+
dtk_dsl_component_info_processor.compute_outputs!
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def info_type
|
34
|
+
:component_info
|
35
|
+
end
|
36
|
+
|
37
|
+
def dtk_dsl_component_info_processor
|
38
|
+
@dtk_dsl_info_processor
|
39
|
+
end
|
40
|
+
|
41
|
+
def component_dsl_path
|
42
|
+
matches = directory_file_paths.select { |path| component_dsl_input_files_processor.match?(path) }
|
43
|
+
# raise Error, "Unexpected that there is not a unique component dsl file" if matches.size != 1
|
44
|
+
matches.first
|
45
|
+
end
|
46
|
+
|
47
|
+
def component_dsl_input_files_processor
|
48
|
+
@component_dsl_input_files_processor ||= input_files_processor(:module)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,49 @@
|
|
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 ServiceAndComponentInfo::TransformTo::Info
|
20
|
+
class Service < self
|
21
|
+
def read_inputs_and_compute_outputs!
|
22
|
+
# Input assemblies and module_ref file
|
23
|
+
module_file_paths.each { |path| add_content!(module_input_files_processor, path) }
|
24
|
+
|
25
|
+
# compute and cache outputs
|
26
|
+
dtk_dsl_service_info_processor.compute_outputs!
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def info_type
|
32
|
+
:service_info
|
33
|
+
end
|
34
|
+
|
35
|
+
def dtk_dsl_service_info_processor
|
36
|
+
@dtk_dsl_info_processor
|
37
|
+
end
|
38
|
+
|
39
|
+
def module_file_paths
|
40
|
+
directory_file_paths.select { |path| module_input_files_processor.match?(path) }
|
41
|
+
end
|
42
|
+
|
43
|
+
def module_input_files_processor
|
44
|
+
@module_input_files_processor ||= input_files_processor(:module)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|