11"""
2- Copyright (c) 2022 Oracle Corporation and/or its affiliates.
2+ Copyright (c) 2022, Oracle Corporation and/or its affiliates.
33Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
55Methods to update an output file with information from the kubernetes section of the model.
1313from wlsdeploy .aliases import alias_utils
1414from wlsdeploy .aliases .model_constants import KUBERNETES
1515from wlsdeploy .aliases .model_constants import MODEL_LIST_DELIMITER
16+ from wlsdeploy .exception import exception_helper
1617from wlsdeploy .exception .expection_types import ExceptionType
1718from wlsdeploy .logging .platform_logger import PlatformLogger
1819from wlsdeploy .tool .extract import wko_schema_helper
2829
2930WKO_DOMAIN_KIND = 'Domain'
3031DOMAIN_HOME = 'domainHome'
32+ IMAGE_PULL_SECRETS = 'imagePullSecrets'
3133
3234# specific to Verrazzano
3335COMPONENT_KIND = 'Component'
@@ -90,6 +92,7 @@ def _update_documents(documents, kubernetes_content, output_file_path):
9092 # is this a standard WKO document?
9193 if kind == WKO_DOMAIN_KIND :
9294 _update_dictionary (document , kubernetes_content , schema , None , output_file_path )
95+ _add_comments (document )
9396 found = True
9497
9598 # is this a Verrazzano WebLogic workload document?
@@ -101,6 +104,7 @@ def _update_documents(documents, kubernetes_content, output_file_path):
101104 component_spec = _get_or_create_dictionary (workload , SPEC )
102105 component_template = _get_or_create_dictionary (component_spec , TEMPLATE )
103106 _update_dictionary (component_template , kubernetes_content , schema , None , output_file_path )
107+ _add_comments (component_template )
104108 found = True
105109
106110 if not found :
@@ -255,6 +259,19 @@ def _check_named_object_list(model_value, type_name, schema_folder, schema_path,
255259 return model_value
256260
257261
262+ def _add_comments (wko_dictionary ):
263+ """
264+ Add relevant comments to the output dictionary to provide additional information.
265+ :param wko_dictionary: the top-level WKO dictionary containing metadata, spec, etc.
266+ """
267+ spec = dictionary_utils .get_element (wko_dictionary , SPEC )
268+ if spec :
269+ image_pull_secrets = dictionary_utils .get_element (spec , IMAGE_PULL_SECRETS )
270+ if image_pull_secrets is not None and not len (image_pull_secrets ):
271+ message = exception_helper .get_message ('WLSDPLY-01679' )
272+ spec .addComment (IMAGE_PULL_SECRETS , message )
273+
274+
258275def _get_or_create_dictionary (dictionary , key ):
259276 if key not in dictionary :
260277 dictionary [key ] = PyOrderedDict ()
0 commit comments