Skip to content

Remove default image pull secret from WKO domain resource template #1146

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 2 commits into from
Jun 16, 2022
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, Oracle Corporation 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 All @@ -13,6 +13,7 @@
from wlsdeploy.aliases import alias_utils
from wlsdeploy.aliases.model_constants import KUBERNETES
from wlsdeploy.aliases.model_constants import MODEL_LIST_DELIMITER
from wlsdeploy.exception import exception_helper
from wlsdeploy.exception.expection_types import ExceptionType
from wlsdeploy.logging.platform_logger import PlatformLogger
from wlsdeploy.tool.extract import wko_schema_helper
Expand All @@ -28,6 +29,7 @@

WKO_DOMAIN_KIND = 'Domain'
DOMAIN_HOME = 'domainHome'
IMAGE_PULL_SECRETS = 'imagePullSecrets'

# specific to Verrazzano
COMPONENT_KIND = 'Component'
Expand Down Expand Up @@ -90,6 +92,7 @@ def _update_documents(documents, kubernetes_content, output_file_path):
# is this a standard WKO document?
if kind == WKO_DOMAIN_KIND:
_update_dictionary(document, kubernetes_content, schema, None, output_file_path)
_add_comments(document)
found = True

# is this a Verrazzano WebLogic workload document?
Expand All @@ -101,6 +104,7 @@ def _update_documents(documents, kubernetes_content, output_file_path):
component_spec = _get_or_create_dictionary(workload, SPEC)
component_template = _get_or_create_dictionary(component_spec, TEMPLATE)
_update_dictionary(component_template, kubernetes_content, schema, None, output_file_path)
_add_comments(component_template)
found = True

if not found:
Expand Down Expand Up @@ -255,6 +259,19 @@ def _check_named_object_list(model_value, type_name, schema_folder, schema_path,
return model_value


def _add_comments(wko_dictionary):
"""
Add relevant comments to the output dictionary to provide additional information.
:param wko_dictionary: the top-level WKO dictionary containing metadata, spec, etc.
"""
spec = dictionary_utils.get_element(wko_dictionary, SPEC)
if spec:
image_pull_secrets = dictionary_utils.get_element(spec, IMAGE_PULL_SECRETS)
if image_pull_secrets is not None and not len(image_pull_secrets):
message = exception_helper.get_message('WLSDPLY-01679')
spec.addComment(IMAGE_PULL_SECRETS, message)


def _get_or_create_dictionary(dictionary, key):
if key not in dictionary:
dictionary[key] = PyOrderedDict()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ WLSDPLY-01675=Updating target output file "{0}" from the {1} section of the mode
WLSDPLY-01676=Unable to find section for update in target output file "{0}"
WLSDPLY-01677=Expected a map value for {0} in the target output file {1}, skipping update
WLSDPLY-01678=Expected a list value for {0} in the target output file {1}, skipping update
WLSDPLY-01679=Add any credential secrets that are required to pull the image

# wlsdeploy/util/enum.py
WLSDPLY-01700=The value {0} is not a valid value of the Enum type {1}
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/targetconfigs/templates/wko-domain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ spec:
image: '{{{imageName}}}'

# Identify which Secret contains the credentials for pulling an image
imagePullSecrets:
- name: ocir
imagePullSecrets: []

# Identify which Secret contains the WebLogic Admin credentials
webLogicCredentialsSecret:
Expand Down