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'
50
50
DEFAULT_IMAGE_PULL_SECRETS = PASSWORD_TOKEN
51
51
DEFAULT_SOURCE_TYPE = 'Image'
52
52
53
- MULTI_KEYS = {
53
+ # deprecated - used for "named object list" format
54
+ OBJECT_NAME_ATTRIBUTES = {
54
55
'spec/adminServer/adminService/channels' : 'channelName' ,
55
56
'spec/clusters' : 'clusterName'
56
57
}
@@ -71,9 +72,6 @@ def __init__(self, model, model_context, logger):
71
72
return
72
73
73
74
def extract (self ):
74
- """
75
- Deploy resource model elements at the domain level, including multi-tenant elements.
76
- """
77
75
_method_name = 'extract'
78
76
79
77
resource_file = self ._model_context .get_domain_resource_file ()
@@ -93,7 +91,6 @@ def extract(self):
93
91
94
92
# write the resource file structure to the output file
95
93
writer = PythonToFile (resource_dict )
96
- writer .set_yaml_hyphenate_yaml_lists (True )
97
94
writer .write_to_file (resource_file )
98
95
return
99
96
@@ -108,42 +105,35 @@ def _create_domain_resource_dictionary(self):
108
105
109
106
schema = wko_schema_helper .get_domain_resource_schema (ExceptionType .DEPLOY )
110
107
111
- model_path = KUBERNETES + ":"
112
- self ._process_folder (kubernetes_map , schema , resource_dict , None , model_path )
108
+ self ._process_object (kubernetes_map , schema , resource_dict , None )
113
109
return resource_dict
114
110
115
- def _process_folder (self , model_dict , schema_folder , target_dict , schema_path , model_path ):
111
+ def _process_object (self , model_dict , schema_folder , target_dict , schema_path ):
116
112
"""
117
113
Transfer folders and attributes from the model dictionary to the target domain resource dictionary.
118
114
:param model_dict: the source model dictionary
119
115
:param schema_folder: the schema for this folder
120
116
:param target_dict: the target dictionary for the domain resource file.
121
- :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
117
+ :param schema_path: the path of schema elements, used for supported check
123
118
"""
124
119
folder_properties = schema_folder ["properties" ]
125
120
126
121
for key , model_value in model_dict .items ():
127
122
properties = folder_properties [key ]
128
123
129
- if wko_schema_helper .is_single_folder (properties ):
130
- # single object instance
124
+ if wko_schema_helper .is_single_object (properties ):
131
125
next_schema_path = wko_schema_helper .append_path (schema_path , key )
132
- next_model_path = model_path + "/" + key
133
126
if not wko_schema_helper .is_unsupported_folder (next_schema_path ):
134
127
next_target_dict = PyOrderedDict ()
135
128
target_dict [key ] = next_target_dict
136
- self ._process_folder (model_value , properties , next_target_dict , next_schema_path ,
137
- next_model_path )
129
+ self ._process_object (model_value , properties , next_target_dict , next_schema_path )
138
130
139
- elif wko_schema_helper .is_multiple_folder (properties ):
140
- # multiple object instances
131
+ elif wko_schema_helper .is_object_array (properties ):
141
132
next_schema_path = wko_schema_helper .append_path (schema_path , key )
142
- next_model_path = model_path + "/" + key
143
133
if not wko_schema_helper .is_unsupported_folder (next_schema_path ):
144
134
item_info = wko_schema_helper .get_array_item_info (properties )
145
135
target_dict [key ] = \
146
- self ._process_multiple_folder (model_value , item_info , next_schema_path , next_model_path )
136
+ self ._process_object_array (model_value , item_info , next_schema_path )
147
137
148
138
elif wko_schema_helper .is_simple_map (properties ):
149
139
# map of key / value pairs
@@ -154,30 +144,35 @@ def _process_folder(self, model_dict, schema_folder, target_dict, schema_path, m
154
144
property_type = wko_schema_helper .get_type (properties )
155
145
target_dict [key ] = _get_target_value (model_value , property_type )
156
146
157
- def _process_multiple_folder (self , model_value , item_info , schema_path , model_path ):
147
+ def _process_object_array (self , model_value , item_info , schema_path ):
158
148
"""
159
- Process a multiple-element model section.
160
- There should be a dictionary of names, each containing a sub-folder.
149
+ Process an array of objects.
161
150
:param model_value: the model contents for a folder
162
151
:param item_info: describes the contents of the sub-folder for each element
163
- :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
152
+ :param schema_path: the path of schema elements, used for supported check
165
153
"""
166
154
child_list = list ()
167
- for name in model_value :
168
- name_map = model_value [name ]
169
- 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
155
156
+ # deprecated "named object list" format - warning was issued in validator
157
+ if isinstance (model_value , dict ):
158
+ for name in model_value :
159
+ object_map = model_value [name ]
160
+ next_target_dict = PyOrderedDict ()
161
+ self ._process_object (object_map , item_info , next_target_dict , schema_path )
162
+
163
+ # see if the model name should become an attribute in the target dict
164
+ mapped_name = get_mapped_key (schema_path )
165
+ properties = wko_schema_helper .get_properties (item_info )
166
+ if (mapped_name in properties .keys ()) and (mapped_name not in next_target_dict .keys ()):
167
+ _add_to_top (next_target_dict , mapped_name , name )
168
+ child_list .append (next_target_dict )
169
+ return child_list
170
+ # end deprecated
171
+
172
+ for object_map in model_value :
173
+ next_target_dict = PyOrderedDict ()
174
+ self ._process_object (object_map , item_info , next_target_dict , schema_path )
179
175
child_list .append (next_target_dict )
180
-
181
176
return child_list
182
177
183
178
def _update_resource_dictionary (self , resource_dict ):
@@ -304,7 +299,7 @@ def _get_target_value(model_value, type_name):
304
299
if type_name == 'boolean' :
305
300
# the model values can be true, false, 1, 0, etc.
306
301
# target boolean values must be 'true' or 'false'
307
- return alias_utils . convert_to_type ( 'boolean' , model_value )
302
+ return BooleanValue ( model_value )
308
303
309
304
if type_name == 'array' :
310
305
# the model values can be 'abc,123'.
@@ -337,16 +332,17 @@ def _add_secrets(folder, secrets, domain_uid):
337
332
secrets .append (secret_name )
338
333
339
334
335
+ # deprecated
340
336
def get_mapped_key (schema_path ):
341
337
"""
342
- Because the WDT model does not support hyphenated lists , the name of each item in a
338
+ For the deprecated "named object list format" , the name of each item in a
343
339
multiple folder sometimes corresponds to one of its attributes, usually "name".
344
340
If a different attribute name is used for the path, return that name.
345
341
If the default 'name' is returned, caller should verify that it is an available attribute.
346
342
:param schema_path: the slash-delimited path of the elements (no multi-element names)
347
343
:return: the attribute key to be used
348
344
"""
349
- mapped_key = dictionary_utils .get_element (MULTI_KEYS , schema_path )
345
+ mapped_key = dictionary_utils .get_element (OBJECT_NAME_ATTRIBUTES , schema_path )
350
346
if mapped_key is not None :
351
347
return mapped_key
352
348
return 'name'
0 commit comments