11
11
from wlsdeploy .aliases .alias_constants import PASSWORD_TOKEN
12
12
from wlsdeploy .aliases .model_constants import CLUSTER
13
13
from wlsdeploy .aliases .model_constants import DEFAULT_WLS_DOMAIN_NAME
14
- from wlsdeploy .aliases .model_constants import KUBERNETES
15
14
from wlsdeploy .aliases .model_constants import MODEL_LIST_DELIMITER
16
15
from wlsdeploy .aliases .model_constants import NAME
17
16
from wlsdeploy .exception import exception_helper
18
17
from wlsdeploy .exception .expection_types import ExceptionType
19
18
from wlsdeploy .tool .extract import wko_schema_helper
20
19
from wlsdeploy .tool .util import k8s_helper
21
20
from wlsdeploy .util import dictionary_utils
21
+ from wlsdeploy .util .boolean_value import BooleanValue
22
22
from wlsdeploy .util .model_translator import PythonToFile
23
23
24
24
API_VERSION = 'apiVersion'
@@ -93,7 +93,6 @@ def extract(self):
93
93
94
94
# write the resource file structure to the output file
95
95
writer = PythonToFile (resource_dict )
96
- writer .set_yaml_hyphenate_yaml_lists (True )
97
96
writer .write_to_file (resource_file )
98
97
return
99
98
@@ -108,18 +107,16 @@ def _create_domain_resource_dictionary(self):
108
107
109
108
schema = wko_schema_helper .get_domain_resource_schema (ExceptionType .DEPLOY )
110
109
111
- model_path = KUBERNETES + ":"
112
- self ._process_folder (kubernetes_map , schema , resource_dict , None , model_path )
110
+ self ._process_folder (kubernetes_map , schema , resource_dict , None )
113
111
return resource_dict
114
112
115
- def _process_folder (self , model_dict , schema_folder , target_dict , schema_path , model_path ):
113
+ def _process_folder (self , model_dict , schema_folder , target_dict , schema_path ):
116
114
"""
117
115
Transfer folders and attributes from the model dictionary to the target domain resource dictionary.
118
116
:param model_dict: the source model dictionary
119
117
:param schema_folder: the schema for this folder
120
118
:param target_dict: the target dictionary for the domain resource file.
121
119
:param schema_path: the path of schema elements (no multi-element names), used for supported check
122
- :param model_path: the path of model elements (including multi-element names), used for logging
123
120
"""
124
121
folder_properties = schema_folder ["properties" ]
125
122
@@ -129,21 +126,18 @@ def _process_folder(self, model_dict, schema_folder, target_dict, schema_path, m
129
126
if wko_schema_helper .is_single_folder (properties ):
130
127
# single object instance
131
128
next_schema_path = wko_schema_helper .append_path (schema_path , key )
132
- next_model_path = model_path + "/" + key
133
129
if not wko_schema_helper .is_unsupported_folder (next_schema_path ):
134
130
next_target_dict = PyOrderedDict ()
135
131
target_dict [key ] = next_target_dict
136
- self ._process_folder (model_value , properties , next_target_dict , next_schema_path ,
137
- next_model_path )
132
+ self ._process_folder (model_value , properties , next_target_dict , next_schema_path )
138
133
139
134
elif wko_schema_helper .is_multiple_folder (properties ):
140
135
# multiple object instances
141
136
next_schema_path = wko_schema_helper .append_path (schema_path , key )
142
- next_model_path = model_path + "/" + key
143
137
if not wko_schema_helper .is_unsupported_folder (next_schema_path ):
144
138
item_info = wko_schema_helper .get_array_item_info (properties )
145
139
target_dict [key ] = \
146
- self ._process_multiple_folder (model_value , item_info , next_schema_path , next_model_path )
140
+ self ._process_multiple_folder (model_value , item_info , next_schema_path )
147
141
148
142
elif wko_schema_helper .is_simple_map (properties ):
149
143
# map of key / value pairs
@@ -154,30 +148,19 @@ def _process_folder(self, model_dict, schema_folder, target_dict, schema_path, m
154
148
property_type = wko_schema_helper .get_type (properties )
155
149
target_dict [key ] = _get_target_value (model_value , property_type )
156
150
157
- def _process_multiple_folder (self , model_value , item_info , schema_path , model_path ):
151
+ def _process_multiple_folder (self , model_value , item_info , schema_path ):
158
152
"""
159
153
Process a multiple-element model section.
160
- There should be a dictionary of names , each containing a sub-folder.
154
+ There should be a list of objects , each representing a sub-folder.
161
155
:param model_value: the model contents for a folder
162
156
:param item_info: describes the contents of the sub-folder for each element
163
157
:param schema_path: the path of schema elements (no multi-element names), used for supported check
164
- :param model_path: the path of model elements (including multi-element names), used for logging
165
158
"""
166
159
child_list = list ()
167
- for name in model_value :
168
- name_map = model_value [name ]
160
+ for name_map in model_value :
169
161
next_target_dict = PyOrderedDict ()
170
- next_model_path = model_path + "/" + name
171
- self ._process_folder (name_map , item_info , next_target_dict , schema_path , next_model_path )
172
-
173
- # see if the model name should become an attribute in the target dict
174
- mapped_name = get_mapped_key (schema_path )
175
- properties = wko_schema_helper .get_properties (item_info )
176
- if (mapped_name in properties .keys ()) and (mapped_name not in next_target_dict .keys ()):
177
- _add_to_top (next_target_dict , mapped_name , name )
178
-
162
+ self ._process_folder (name_map , item_info , next_target_dict , schema_path )
179
163
child_list .append (next_target_dict )
180
-
181
164
return child_list
182
165
183
166
def _update_resource_dictionary (self , resource_dict ):
@@ -304,7 +287,7 @@ def _get_target_value(model_value, type_name):
304
287
if type_name == 'boolean' :
305
288
# the model values can be true, false, 1, 0, etc.
306
289
# target boolean values must be 'true' or 'false'
307
- return alias_utils . convert_to_type ( 'boolean' , model_value )
290
+ return BooleanValue ( model_value )
308
291
309
292
if type_name == 'array' :
310
293
# the model values can be 'abc,123'.
@@ -337,21 +320,6 @@ def _add_secrets(folder, secrets, domain_uid):
337
320
secrets .append (secret_name )
338
321
339
322
340
- def get_mapped_key (schema_path ):
341
- """
342
- Because the WDT model does not support hyphenated lists, the name of each item in a
343
- multiple folder sometimes corresponds to one of its attributes, usually "name".
344
- If a different attribute name is used for the path, return that name.
345
- If the default 'name' is returned, caller should verify that it is an available attribute.
346
- :param schema_path: the slash-delimited path of the elements (no multi-element names)
347
- :return: the attribute key to be used
348
- """
349
- mapped_key = dictionary_utils .get_element (MULTI_KEYS , schema_path )
350
- if mapped_key is not None :
351
- return mapped_key
352
- return 'name'
353
-
354
-
355
323
def _add_to_top (dictionary , key , item ):
356
324
"""
357
325
Add an item to the beginning of an ordered dictionary.
0 commit comments