Skip to content

Commit 03526e5

Browse files
authored
Set domain source type default for extractResource and target resource files (#810)
* JIRA WDT-530 - Display enum options in modelHelp and in unit test model * JIRA WDT-530 - Set domainHomeSourceType to Image if not specified in model * JIRA WDT-530 - Add domainHomeSourceType to resource file for -target vz output
1 parent 54f2633 commit 03526e5

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

core/src/main/python/wlsdeploy/tool/extract/domain_resource_extractor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
CLUSTER_NAME = 'clusterName'
2828
CONFIGURATION = 'configuration'
2929
DOMAIN_HOME = 'domainHome'
30+
DOMAIN_HOME_SOURCE_TYPE = 'domainHomeSourceType'
3031
DOMAIN_TYPE = 'domainType'
3132
IMAGE = 'image'
3233
IMAGE_PULL_POLICY = 'imagePullPolicy'
@@ -47,6 +48,7 @@
4748
DEFAULT_WEBLOGIC_CREDENTIALS_SECRET = PASSWORD_TOKEN
4849
DEFAULT_IMAGE = PASSWORD_TOKEN
4950
DEFAULT_IMAGE_PULL_SECRETS = PASSWORD_TOKEN
51+
DEFAULT_SOURCE_TYPE = 'Image'
5052

5153
MULTI_KEYS = {
5254
'spec/adminServer/adminService/channels': 'channelName',
@@ -217,6 +219,10 @@ def _update_resource_dictionary(self, resource_dict):
217219
if DOMAIN_HOME not in spec_section:
218220
spec_section[DOMAIN_HOME] = self._model_context.get_domain_home()
219221

222+
# only set domain home source type if it is not present in spec section
223+
if DOMAIN_HOME_SOURCE_TYPE not in spec_section:
224+
spec_section[DOMAIN_HOME_SOURCE_TYPE] = DEFAULT_SOURCE_TYPE
225+
220226
# only set image if it is not present in spec section
221227
if IMAGE not in spec_section:
222228
spec_section[IMAGE] = DEFAULT_IMAGE

core/src/main/python/wlsdeploy/tool/extract/wko_schema_helper.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ def get_type(schema_map):
130130
return dictionary_utils.get_element(schema_map, "type")
131131

132132

133+
def get_enum_values(schema_map):
134+
return dictionary_utils.get_element(schema_map, 'enum')
135+
136+
133137
def is_unsupported_folder(path):
134138
return path in UNSUPPORTED_FOLDERS
135139

core/src/main/python/wlsdeploy/tool/modelhelp/model_kubernetes_printer.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,11 @@ def _print_attributes_sample(self, schema_folder, indent_level):
174174
attribute_map[key] = 'list of ' + wko_schema_helper.get_array_element_type(property_map)
175175

176176
elif not wko_schema_helper.is_folder(property_map):
177-
attribute_map[key] = wko_schema_helper.get_type(property_map)
177+
type_text = wko_schema_helper.get_type(property_map)
178+
enum_values = wko_schema_helper.get_enum_values(property_map)
179+
if enum_values:
180+
type_text += ' (' + ', '.join(enum_values) + ')'
181+
attribute_map[key] = type_text
178182

179183
if attribute_map:
180184
attr_list = attribute_map.keys()

core/src/main/targetconfigs/vz/model.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ spec:
1313
# The WebLogic Domain Home
1414
domainHome: {{{domainHome}}}
1515

16+
# The domain home source type
17+
# Set to PersistentVolume for domain-in-pv, Image for domain-in-image, or FromModel for model-in-image
18+
domainHomeSourceType: {{{domainHomeSourceType}}}
19+
1620
# The WebLogic Server Docker image that the Operator uses to start the domain
1721
image: {{{imageName}}}
1822

core/src/test/python/wlsdeploy/tool/extract/kubernetes_schema_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ def _write_folder(self, folder, name, is_multiple, path, indent):
104104
elif property_type in wko_schema_helper.SIMPLE_TYPES:
105105
if property_name != multi_key:
106106
value = _get_sample_value(property_type)
107+
enum_values = wko_schema_helper.get_enum_values(property_map)
108+
if enum_values:
109+
value = "'" + enum_values[0] + "' # " + ', '.join(enum_values)
107110
self._write_line(indent + str(property_name) + ": " + value)
108111

109112
else:

0 commit comments

Comments
 (0)