Skip to content

Remove deprecated "named object list" format for kubernetes model section #1351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2022, Oracle Corporation and/or its affiliates.
Copyright (c) 2022, 2023, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

Methods to update an output file with information from the kubernetes section of the model.
Expand Down Expand Up @@ -205,10 +205,6 @@ def _update_dictionary(output_dictionary, model_dictionary, schema_folder, schem
property_folder = properties[key]
element_type = schema_helper.get_type(property_folder)

# deprecated "named object list" format
value = _check_named_object_list(value, element_type, property_folder, schema_path, key, model_crd_folder)
# end deprecated

value = _convert_value(value, element_type)

if isinstance(value, dict):
Expand Down Expand Up @@ -299,38 +295,6 @@ def _convert_value(model_value, type_name):
return model_value


# *** DELETE METHOD WHEN deprecated "named object list" IS REMOVED ***
def _check_named_object_list(model_value, type_name, schema_folder, schema_path, key, model_crd_folder):
"""
Convert specified model value to an object list if it uses deprecated "named object list" format.
:param model_value: the value to be checked
:param type_name: the schema type name of the value
:param schema_folder: the schema for the value being checked
:param schema_path: used for schema_helper key lookup
:param key: used for schema_helper key lookup
:param model_crd_folder: required for object list matching
:return: the converted value
"""
if type_name == 'array' and isinstance(model_value, dict):
object_list = list()
next_schema_path = schema_helper.append_path(schema_path, key)
list_key = model_crd_folder.get_object_list_key(next_schema_path)
item_info = schema_helper.get_array_item_info(schema_folder)
properties = schema_helper.get_properties(item_info)

for model_key, model_object in model_value.items():
new_object = model_object.copy()

# see if the model name should become an attribute in the new object
if (list_key in properties.keys()) and (list_key not in new_object.keys()):
new_object[list_key] = model_key

object_list.append(new_object)
return object_list

return model_value


def _add_domain_comments(wko_dictionary):
"""
Add relevant comments to the domain CRD dictionary to provide additional information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2020, 2022, Oracle and/or its affiliates.
Copyright (c) 2020, 2023, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
"""

Expand Down Expand Up @@ -133,16 +133,6 @@ def _validate_object_array(self, model_value, property_map, schema_path, model_p
"""
_method_name = '_validate_object_array'

# deprecated "named object list" format
if isinstance(model_value, dict):
self._logger.warning("WLSDPLY-05091", model_path, class_name=self._class_name, method_name=_method_name)
for name in model_value:
object_map = model_value[name]
next_model_path = model_path + "/" + name
self.validate_folder(object_map, property_map, schema_path, next_model_path)
return
# end deprecated

if not isinstance(model_value, list):
self._logger.severe("WLSDPLY-05040", model_path, class_name=self._class_name, method_name=_method_name)
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,6 @@ WLSDPLY-05040=Expected a list of objects in model location {0}

# wlsdeploy/tool/validate/kubernetes_validator.py
WLSDPLY-05090=Model folder {0} is not supported, will be skipped
WLSDPLY-05091=Model folder {0} uses deprecated "named object list" format, should be a hyphenated object list

# wlsdeploy/tools/validate/validation_utils.py
WLSDPLY-05300=NOT USED
Expand Down
22 changes: 1 addition & 21 deletions core/src/test/python/wlsdeploy/tool/extract/extract_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2021, 2022, Oracle and/or its affiliates.
Copyright (c) 2021, 2023, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
"""
import os
Expand Down Expand Up @@ -86,26 +86,6 @@ def testKubernetesModel(self):
self._match_values("Secret 0", secret_list[0], 'secret-1')
self._match_values("Secret 1", secret_list[1], 'secret-2')

# deprecated
def testNamedObjectListModel(self):
"""
Test that fields using the deprecated "named object list" in the kubernetes section of the model
are transferred to the resulting domain resource file
"""
resource = self._extract_domain_resource('3')

# serverPod/env from the kubernetes section should be in the domain resource file
env_list = self._traverse(resource, 'spec', 'serverPod', 'env')
self._match_values("Env count", len(env_list), 2)
self._match_values("Env 0", env_list[0]['name'], 'JAVA_OPTIONS')
self._match_values("Env 1", env_list[1]['name'], 'USER_MEM_ARGS')

# clusters from kubernetes section should be in the domain resource file
cluster_list = self._traverse(resource, 'spec', 'clusters')
self._match_values("Cluster count", len(cluster_list), 2)
self._match_values("Cluster 0 clusterName", cluster_list[0]['clusterName'], 'CLUSTER_1')
self._match_values("Cluster 1 clusterName", cluster_list[1]['clusterName'], 'CLUSTER_2')

def _extract_domain_resource(self, suffix):
model_file = os.path.join(self.MODELS_DIR, 'model-' + suffix + '.yaml')
translator = FileToPython(model_file, use_ordering=True)
Expand Down
21 changes: 0 additions & 21 deletions core/src/test/resources/extract/model-3.yaml

This file was deleted.