dtk-dsl 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/dsl/input_output_common/canonical/hash_key.rb +1 -0
- data/lib/dsl/input_output_common/semantic_parse/hash.rb +5 -0
- data/lib/dsl/input_output_common/semantic_parse/mixin.rb +1 -1
- data/lib/dsl/service_and_component_info/info/input_files.rb +58 -0
- data/lib/dsl/service_and_component_info/info.rb +64 -0
- data/lib/dsl/service_and_component_info/module_ref.rb +56 -0
- data/lib/dsl/service_and_component_info/parser.rb +58 -0
- data/lib/dsl/service_and_component_info/transform_from/info/component.rb +42 -0
- data/lib/dsl/service_and_component_info/transform_from/info/input_files.rb +27 -0
- data/lib/dsl/service_and_component_info/transform_from/info/service.rb +43 -0
- data/lib/dsl/service_and_component_info/transform_from/info.rb +64 -0
- data/lib/dsl/service_and_component_info/transform_from/parser/top_dsl/assemblies/node_bindings.rb +81 -0
- data/lib/dsl/service_and_component_info/transform_from/parser/top_dsl/assemblies/workflows.rb +37 -0
- data/lib/dsl/service_and_component_info/transform_from/parser/top_dsl/assemblies.rb +52 -0
- data/lib/dsl/service_and_component_info/transform_from/parser/top_dsl/components.rb +33 -0
- data/lib/dsl/service_and_component_info/transform_from/parser/top_dsl/dependencies.rb +74 -0
- data/lib/dsl/service_and_component_info/transform_from/parser/top_dsl/module_info.rb +31 -0
- data/lib/dsl/service_and_component_info/transform_from/parser/top_dsl.rb +36 -0
- data/lib/dsl/service_and_component_info/transform_from/parser.rb +24 -0
- data/lib/dsl/service_and_component_info/transform_from.rb +25 -0
- data/lib/dsl/service_and_component_info/transform_to/info/component.rb +70 -0
- data/lib/dsl/service_and_component_info/transform_to/info/input_files.rb +36 -0
- data/lib/dsl/service_and_component_info/transform_to/info/service.rb +72 -0
- data/lib/dsl/service_and_component_info/transform_to/info.rb +51 -0
- data/lib/dsl/service_and_component_info/transform_to/parser/component_module/module_refs.rb +27 -0
- data/lib/dsl/service_and_component_info/transform_to/parser/component_module/top_dsl.rb +47 -0
- data/lib/dsl/service_and_component_info/transform_to/parser/component_module.rb +28 -0
- data/lib/dsl/service_and_component_info/transform_to/parser/module_refs.rb +54 -0
- data/lib/dsl/service_and_component_info/transform_to/parser/service_module/module_refs.rb +27 -0
- data/lib/dsl/service_and_component_info/transform_to/parser/service_module/top_dsl.rb +73 -0
- data/lib/dsl/service_and_component_info/transform_to/parser/service_module.rb +28 -0
- data/lib/dsl/service_and_component_info/transform_to/parser/top_dsl.rb +36 -0
- data/lib/dsl/service_and_component_info/transform_to/parser.rb +39 -0
- data/lib/dsl/service_and_component_info/transform_to.rb +25 -0
- data/lib/dsl/service_and_component_info.rb +55 -0
- data/lib/dsl/template/parsing/mixin.rb +6 -5
- data/lib/dsl/template/parsing/parsing_error/subclasses.rb +13 -13
- data/lib/dsl/template/v1/common_module.rb +4 -2
- data/lib/dsl/template/v1/component.rb +11 -2
- data/lib/dsl/template/v1/component_def/semantic_parse.rb +26 -0
- data/lib/dsl/template/v1/component_def.rb +52 -0
- data/lib/dsl/template/v1/workflow.rb +0 -1
- data/lib/dsl/template/v1.rb +1 -0
- data/lib/dsl/version.rb +1 -1
- data/lib/dsl/yaml_helper.rb +1 -0
- data/lib/dtk_dsl.rb +2 -0
- metadata +41 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 729eb1869724a0dfe75290f15ed8eb7735412797
|
4
|
+
data.tar.gz: 180a6b31a242f1b54f2c4b12e3f8464f87cca30d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04143ec146daa4c2157263e074f13ed75bf108e358c99c84b3ee13fd4d497ae5d962612d8d8d98e54aa9d28696283aa659e67db3b7e9b45afe603047ae230ea4
|
7
|
+
data.tar.gz: a3619c787e623b66ae81e3ad87b8e2874df66f1bb35d15713b1dbfd44eff0fca735085dba5df929a355c3da2046253b5f198002d449c2685d63f90183ed9ca0f
|
@@ -0,0 +1,58 @@
|
|
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::DSL
|
19
|
+
class ServiceAndComponentInfo::Info
|
20
|
+
class InputFiles
|
21
|
+
def initialize(regexps)
|
22
|
+
@regexps = regexps
|
23
|
+
|
24
|
+
# dyanmically set
|
25
|
+
# For TransformFrom hash_content is type ::Hash where for TransformTo it is type InputOutputCommon::Canonical::Hash
|
26
|
+
@ndx_file_hash_content = {} #indexed by file hash name
|
27
|
+
end
|
28
|
+
|
29
|
+
def match?(path)
|
30
|
+
@regexps.find { |regexp| path =~ regexp }
|
31
|
+
end
|
32
|
+
|
33
|
+
def content_hash_array
|
34
|
+
@ndx_file_hash_content.values
|
35
|
+
end
|
36
|
+
|
37
|
+
def input_paths
|
38
|
+
@ndx_file_hash_content.keys
|
39
|
+
end
|
40
|
+
|
41
|
+
def empty?
|
42
|
+
@ndx_file_hash_content.empty?
|
43
|
+
end
|
44
|
+
|
45
|
+
def content_hash?
|
46
|
+
fail Error, "Unexpected that @ndx_file_hash_content.size > 1" if @ndx_file_hash_content.size > 1
|
47
|
+
@ndx_file_hash_content.values.first
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def add_hash_content!(path, hash_content)
|
53
|
+
@ndx_file_hash_content.merge!(path => hash_content)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,64 @@
|
|
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::DSL
|
19
|
+
class ServiceAndComponentInfo
|
20
|
+
class Info
|
21
|
+
require_relative('info/input_files')
|
22
|
+
|
23
|
+
attr_reader :indexed_input_files, :module_ref
|
24
|
+
def initialize(parent)
|
25
|
+
@parent = parent
|
26
|
+
@module_ref = parent.module_ref
|
27
|
+
# indexed by input file type
|
28
|
+
@indexed_input_files = ret_indexed_input_files(info_type)
|
29
|
+
end
|
30
|
+
|
31
|
+
def compute_outputs!
|
32
|
+
raise Error::NoMethodForConcreteClass.new(self.class)
|
33
|
+
end
|
34
|
+
|
35
|
+
def output_path_text_pairs
|
36
|
+
@parent.output_path_text_pairs
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
# indexed by input file type
|
42
|
+
def ret_indexed_input_files(input_type)
|
43
|
+
input_type_hash(input_type)[:input_files].inject({}) { |h, (k, v) | h.merge(k => input_files_class.new(v[:regexps])) }
|
44
|
+
end
|
45
|
+
|
46
|
+
def input_type_hash(input_type)
|
47
|
+
self.class::INFO_HASH[input_type] || fail(Error, "Illegal input_type '#{input_type}'")
|
48
|
+
end
|
49
|
+
|
50
|
+
def output_file_hash(path)
|
51
|
+
@parent.output_path_hash_pairs[path] || {}
|
52
|
+
end
|
53
|
+
|
54
|
+
def update_or_add_output_hash!(path, hash_content)
|
55
|
+
@parent.update_or_add_output_hash!(path, hash_content)
|
56
|
+
end
|
57
|
+
|
58
|
+
def input_files_class
|
59
|
+
@input_files_class ||= @parent.class::Info::InputFiles
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,56 @@
|
|
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::DSL
|
19
|
+
class ServiceAndComponentInfo
|
20
|
+
class ModuleRef
|
21
|
+
attr_reader :namespace, :module_name, :version
|
22
|
+
def initialize(namespace, module_name, version)
|
23
|
+
@namespace = namespace
|
24
|
+
@module_name = module_name
|
25
|
+
@version = version || 'master'
|
26
|
+
end
|
27
|
+
|
28
|
+
NAMESPACE_NAME_DELIM = '/'
|
29
|
+
|
30
|
+
def combined_module_form
|
31
|
+
{ "#{@namespace}#{NAMESPACE_NAME_DELIM}#{@module_name}" => @version }
|
32
|
+
end
|
33
|
+
|
34
|
+
def raise_error_if_conflict(ndx_existing_modules)
|
35
|
+
if matching_module_info = ndx_existing_modules[@module_name]
|
36
|
+
fail Error::Usage, conflict_error_msg(matching_module_info) unless match?(matching_module_info)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def print_form
|
41
|
+
"#{@namespace}#{NAMESPACE_NAME_DELIM}#{@module_name}(#{@version})"
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def match?(module_info2)
|
47
|
+
@version == module_info2.version and @module_name == module_info2.module_name and @namespace == module_info2.namespace
|
48
|
+
end
|
49
|
+
|
50
|
+
def conflict_error_msg(matching_module_info)
|
51
|
+
"Conflicting versions of module '#{@module_name}': '#{print_form}' vs '#{matching_module_info.print_form}'"
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,58 @@
|
|
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::DSL
|
19
|
+
class ServiceAndComponentInfo
|
20
|
+
class Parser
|
21
|
+
|
22
|
+
attr_reader :output_hash, :info_object
|
23
|
+
def initialize(output_hash, info_object)
|
24
|
+
@output_hash = output_hash
|
25
|
+
@info_object = info_object
|
26
|
+
@indexed_input_files = info_object.indexed_input_files
|
27
|
+
end
|
28
|
+
private :initialize
|
29
|
+
|
30
|
+
def self.update_output_hash?(output_hash, info_object)
|
31
|
+
new(output_hash, info_object).update_output_hash?
|
32
|
+
output_hash
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def input_files(type)
|
38
|
+
input_files?(type) || raise(Error, "Unexpected that no indexed_input_files of type '#{type}'")
|
39
|
+
end
|
40
|
+
|
41
|
+
def input_files?(type)
|
42
|
+
@indexed_input_files[type]
|
43
|
+
end
|
44
|
+
|
45
|
+
def input_file_hash?(type)
|
46
|
+
if input_files = input_files?(type)
|
47
|
+
input_files.content_hash?
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def raise_error_missing_field(key)
|
52
|
+
raise Error, "Unexpected that field '#{key}' is missing"
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
@@ -0,0 +1,42 @@
|
|
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::DSL
|
19
|
+
class ServiceAndComponentInfo::TransformFrom
|
20
|
+
class Info
|
21
|
+
class Component < self
|
22
|
+
def compute_outputs!
|
23
|
+
path = top_level_dsl_path
|
24
|
+
update_or_add_output_hash!(path, top_dsl_file_hash_content!(output_file_hash(path)))
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def info_type
|
30
|
+
:component_info
|
31
|
+
end
|
32
|
+
|
33
|
+
def top_dsl_file_hash_content!(output_hash)
|
34
|
+
top_dsl_parser::ModuleInfo.update_output_hash?(output_hash, self)
|
35
|
+
top_dsl_parser::Dependencies.update_output_hash?(output_hash, self)
|
36
|
+
top_dsl_parser::Components.update_output_hash?(output_hash, self)
|
37
|
+
output_hash
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,27 @@
|
|
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::DSL
|
19
|
+
class ServiceAndComponentInfo::TransformFrom::Info
|
20
|
+
class InputFiles < ServiceAndComponentInfo::Info::InputFiles
|
21
|
+
def add_content!(path, text_content)
|
22
|
+
file_obj = FileObj.new(nil, path, :content => text_content)
|
23
|
+
add_hash_content!(path, YamlHelper.parse(file_obj))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,43 @@
|
|
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::DSL
|
19
|
+
class ServiceAndComponentInfo::TransformFrom
|
20
|
+
class Info
|
21
|
+
class Service < self
|
22
|
+
def compute_outputs!
|
23
|
+
path = top_level_dsl_path
|
24
|
+
update_or_add_output_hash!(path, top_dsl_file_hash_content!(output_file_hash(path)))
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def info_type
|
30
|
+
:service_info
|
31
|
+
end
|
32
|
+
|
33
|
+
def top_dsl_file_hash_content!(output_hash)
|
34
|
+
top_dsl_parser::ModuleInfo.update_output_hash?(output_hash, self)
|
35
|
+
top_dsl_parser::Dependencies.update_output_hash?(output_hash, self)
|
36
|
+
top_dsl_parser::Assemblies.update_output_hash?(output_hash, self)
|
37
|
+
output_hash
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,64 @@
|
|
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::DSL
|
19
|
+
class ServiceAndComponentInfo::TransformFrom
|
20
|
+
class Info < ServiceAndComponentInfo::Info
|
21
|
+
require_relative('info/input_files')
|
22
|
+
require_relative('info/service')
|
23
|
+
require_relative('info/component')
|
24
|
+
# This is for mapping to module directories (not service instance directories)
|
25
|
+
INFO_HASH = {
|
26
|
+
:service_info => {
|
27
|
+
:input_files => {
|
28
|
+
:assemblies => {
|
29
|
+
:regexps =>
|
30
|
+
[
|
31
|
+
Regexp.new("assemblies/(.*)\.dtk\.assembly\.(yml|yaml)$"),
|
32
|
+
Regexp.new("assemblies/([^/]+)/assembly\.(yml|yaml)$") #Legacy form
|
33
|
+
]
|
34
|
+
},
|
35
|
+
:module_refs => {
|
36
|
+
:regexps => [Regexp.new("module_refs\.yaml$")]
|
37
|
+
}
|
38
|
+
}
|
39
|
+
},
|
40
|
+
:component_info => {
|
41
|
+
:input_files => {
|
42
|
+
:component_dsl_file => {
|
43
|
+
:regexps => [Regexp.new("dtk\.model\.yaml$")],
|
44
|
+
},
|
45
|
+
:module_refs => {
|
46
|
+
:regexps => [Regexp.new("module_refs\.yaml$")]
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def top_dsl_parser
|
55
|
+
@top_dsl_parser ||= Parser::TopDSL
|
56
|
+
end
|
57
|
+
|
58
|
+
def top_level_dsl_path
|
59
|
+
@top_level_dsl_path ||= FileType::CommonModule::DSLFile::Top.canonical_path
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/dsl/service_and_component_info/transform_from/parser/top_dsl/assemblies/node_bindings.rb
ADDED
@@ -0,0 +1,81 @@
|
|
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::DSL
|
19
|
+
class ServiceAndComponentInfo::TransformFrom::Parser
|
20
|
+
class TopDSL::Assemblies
|
21
|
+
module NodeBindings
|
22
|
+
def self.add_node_properties!(assembly_content, node_bindings)
|
23
|
+
nodes = assembly_content['nodes'] || []
|
24
|
+
return if nodes.empty?
|
25
|
+
|
26
|
+
node_bindings.each do |node, node_binding|
|
27
|
+
if node_content = nodes[node]
|
28
|
+
process_node_content!(node_content, node_binding)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def self.process_node_content!(node_content, node_binding)
|
36
|
+
components = node_content['components']
|
37
|
+
components = components.is_a?(Array) ? components : [components]
|
38
|
+
image, size = ec2_properties_from_node_binding(node_binding)
|
39
|
+
new_attrs = { 'image' => image, 'size' => size }
|
40
|
+
|
41
|
+
if index = include_node_property_component?(components)
|
42
|
+
ec2_properties = components[index]
|
43
|
+
if ec2_properties.is_a?(::Hash)
|
44
|
+
if attributes = ec2_properties.values.first['attributes']
|
45
|
+
attributes['image'] ||= image
|
46
|
+
attributes['size'] ||= size
|
47
|
+
else
|
48
|
+
ec2_properties.merge!('attributes' => new_attrs)
|
49
|
+
end
|
50
|
+
else
|
51
|
+
components[index] = { ec2_properties => { 'attributes' => new_attrs } }
|
52
|
+
end
|
53
|
+
elsif node_attributes = node_content['attributes']
|
54
|
+
node_attributes['image'] ||= image
|
55
|
+
node_attributes['size'] ||= size
|
56
|
+
else
|
57
|
+
node_content['attributes'] = new_attrs
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.ec2_properties_from_node_binding(node_binding)
|
62
|
+
image, size = node_binding.split('-')
|
63
|
+
[image, size]
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.include_node_property_component?(components)
|
67
|
+
property_component = 'ec2::properties'
|
68
|
+
components.each do |component|
|
69
|
+
if component.is_a?(Hash)
|
70
|
+
return components.index(component) if component.keys.first.eql?(property_component)
|
71
|
+
else
|
72
|
+
return components.index(component) if component.eql?(property_component)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
false
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,37 @@
|
|
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::DSL
|
19
|
+
class ServiceAndComponentInfo::TransformFrom::Parser
|
20
|
+
class TopDSL::Assemblies
|
21
|
+
module Workflows
|
22
|
+
def self.hash_content?(assembly_hash)
|
23
|
+
if workflows = assembly_hash['workflow'] || assembly_hash['workflows']
|
24
|
+
if workflow_name = workflows['assembly_action']
|
25
|
+
# this is legacy workflow
|
26
|
+
workflows_without_name = workflows.inject({}) { |h, (k, v)| k == 'assembly_action' ? h : h.merge(k => v) }
|
27
|
+
{ workflow_name => workflows_without_name }
|
28
|
+
else
|
29
|
+
workflows
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,52 @@
|
|
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::DSL
|
19
|
+
class ServiceAndComponentInfo::TransformFrom::Parser
|
20
|
+
class TopDSL
|
21
|
+
class Assemblies < self
|
22
|
+
require_relative('assemblies/workflows')
|
23
|
+
require_relative('assemblies/node_bindings')
|
24
|
+
def update_output_hash?
|
25
|
+
input_files(:assemblies).content_hash_array.each do |input_hash|
|
26
|
+
name = input_hash['name'] || raise_error_missing_field('name')
|
27
|
+
assembly_hash = input_hash['assembly'] || raise_error_missing_field('assembly')
|
28
|
+
|
29
|
+
assembly_content = {}
|
30
|
+
if description = input_hash['description']
|
31
|
+
assembly_content.merge!('description' => description)
|
32
|
+
end
|
33
|
+
|
34
|
+
assembly_content.merge!(assembly_hash)
|
35
|
+
|
36
|
+
if workflows = Workflows.hash_content?(input_hash)
|
37
|
+
assembly_content.merge!('workflows' => workflows)
|
38
|
+
end
|
39
|
+
|
40
|
+
if node_bindings = input_hash['node_bindings']
|
41
|
+
# convert node_bindings to node attributes
|
42
|
+
NodeBindings.add_node_properties!(assembly_content, node_bindings)
|
43
|
+
end
|
44
|
+
(output_hash['assemblies'] ||= {}).merge!(name => assembly_content)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,33 @@
|
|
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::DSL
|
19
|
+
class ServiceAndComponentInfo::TransformFrom::Parser
|
20
|
+
class TopDSL
|
21
|
+
class Components < self
|
22
|
+
def update_output_hash?
|
23
|
+
if component_dsl_input_hash = input_file_hash?(:component_dsl_file)
|
24
|
+
if component_defs = component_dsl_input_hash['components']
|
25
|
+
output_hash['component_defs'] = component_defs
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|