1
1
"""
2
- Copyright (c) 2022 Oracle Corporation and/or its affiliates.
2
+ Copyright (c) 2022, Oracle Corporation and/or its affiliates.
3
3
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4
4
5
5
Methods to update an output file with information from the kubernetes section of the model.
13
13
from wlsdeploy .aliases import alias_utils
14
14
from wlsdeploy .aliases .model_constants import KUBERNETES
15
15
from wlsdeploy .aliases .model_constants import MODEL_LIST_DELIMITER
16
+ from wlsdeploy .exception import exception_helper
16
17
from wlsdeploy .exception .expection_types import ExceptionType
17
18
from wlsdeploy .logging .platform_logger import PlatformLogger
18
19
from wlsdeploy .tool .extract import wko_schema_helper
28
29
29
30
WKO_DOMAIN_KIND = 'Domain'
30
31
DOMAIN_HOME = 'domainHome'
32
+ IMAGE_PULL_SECRETS = 'imagePullSecrets'
31
33
32
34
# specific to Verrazzano
33
35
COMPONENT_KIND = 'Component'
@@ -90,6 +92,7 @@ def _update_documents(documents, kubernetes_content, output_file_path):
90
92
# is this a standard WKO document?
91
93
if kind == WKO_DOMAIN_KIND :
92
94
_update_dictionary (document , kubernetes_content , schema , None , output_file_path )
95
+ _add_comments (document )
93
96
found = True
94
97
95
98
# is this a Verrazzano WebLogic workload document?
@@ -101,6 +104,7 @@ def _update_documents(documents, kubernetes_content, output_file_path):
101
104
component_spec = _get_or_create_dictionary (workload , SPEC )
102
105
component_template = _get_or_create_dictionary (component_spec , TEMPLATE )
103
106
_update_dictionary (component_template , kubernetes_content , schema , None , output_file_path )
107
+ _add_comments (component_template )
104
108
found = True
105
109
106
110
if not found :
@@ -255,6 +259,19 @@ def _check_named_object_list(model_value, type_name, schema_folder, schema_path,
255
259
return model_value
256
260
257
261
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
+
258
275
def _get_or_create_dictionary (dictionary , key ):
259
276
if key not in dictionary :
260
277
dictionary [key ] = PyOrderedDict ()
0 commit comments