Skip to content

Wdt 414 k8s filter #628

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 23 commits into from
May 27, 2020
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Currently, the project provides five single-purpose tools, all exposed as shell
- The [Encrypt Model Tool](site/encrypt.md) (`encryptModel`) encrypts the passwords in a model (or its variable file) using a user-provided passphrase.
- The [Validate Model Tool](site/validate.md) (`validateModel`) provides both standalone validation of a model as well as model usage information to help users write or edit their models.
- The [Compare Model Tool](site/compare.md) (`compareModel`) compares two model files.
- The [Prepare Model Tool](site/compare.md) (`prepareModel`) prepare model files for deploying to WebLogic Kubernetes Operator environment.
- The [Extract Domain Resource Tool](site/kubernetes.md) (`extractDomainResource`) generates a domain resource YAML for use with the Oracle WebLogic Server Kubernetes Operator.

As new use cases are discovered, new tools will likely be added to cover those operations but all will use the metadata model to describe what needs to be done.
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/python/compare_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
]

__optional_arguments = [
CommandLineArgUtil.COMPARE_MODEL_OUTPUT_DIR_SWITCH,
CommandLineArgUtil.OUTPUT_DIR_SWITCH,
CommandLineArgUtil.VARIABLE_FILE_SWITCH
]

Expand Down
41 changes: 37 additions & 4 deletions core/src/main/python/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from wlsdeploy.util.cla_utils import CommandLineArgUtil
from wlsdeploy.util.model import Model
from wlsdeploy.util.weblogic_helper import WebLogicHelper
from wlsdeploy.util import target_configuration_helper

wlst_helper.wlst_functions = globals()

Expand All @@ -73,7 +74,9 @@
CommandLineArgUtil.ADMIN_URL_SWITCH,
CommandLineArgUtil.ADMIN_USER_SWITCH,
CommandLineArgUtil.ADMIN_PASS_SWITCH,
CommandLineArgUtil.TARGET_MODE_SWITCH
CommandLineArgUtil.TARGET_MODE_SWITCH,
CommandLineArgUtil.OUTPUT_DIR_SWITCH,
CommandLineArgUtil.TARGET_SWITCH
]


Expand All @@ -90,6 +93,8 @@ def __process_args(args):

cla_helper.verify_required_args_present(_program_name, __required_arguments, required_arg_map)
__wlst_mode = cla_helper.process_online_args(optional_arg_map)

__process_target_arg(optional_arg_map)
__process_archive_filename_arg(required_arg_map)
__process_variable_filename_arg(optional_arg_map)
__process_java_home(optional_arg_map)
Expand All @@ -98,6 +103,24 @@ def __process_args(args):
combined_arg_map.update(required_arg_map)
return model_context_helper.create_context(_program_name, combined_arg_map)

def __process_target_arg(optional_arg_map):

_method_name = '__process_target_arg'

if CommandLineArgUtil.TARGET_SWITCH in optional_arg_map:
# if -target is specified -output_dir is required
output_dir = optional_arg_map[CommandLineArgUtil.OUTPUT_DIR_SWITCH]
if output_dir is None or os.path.isdir(output_dir) is False:
if not os.path.isdir(output_dir):
ex = exception_helper.create_cla_exception('WLSDPLY-01642', output_dir)
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
raise ex

# Set the -variable_file parameter if not present with default

if CommandLineArgUtil.VARIABLE_FILE_SWITCH not in optional_arg_map:
optional_arg_map[CommandLineArgUtil.VARIABLE_FILE_SWITCH] = os.path.join(output_dir,
"k8s_variable.properties")

def __process_archive_filename_arg(required_arg_map):
"""
Expand Down Expand Up @@ -399,15 +422,25 @@ def __check_and_customize_model(model, model_context, aliases, injector):
_method_name = '__check_and_customize_model'
__logger.entering(class_name=_class_name, method_name=_method_name)

if filter_helper.apply_filters(model.get_model(), "discover"):
if filter_helper.apply_filters(model.get_model(), "discover", model_context):
__logger.info('WLSDPLY-06014', _class_name=_class_name, method_name=_method_name)

cache = None
if injector is not None:
cache = injector.get_variable_cache()
# Generate k8s create secret script, after that clear the dictionary to avoid showing up in the variable file
if model_context.is_targetted_config():
validation_method = model_context.get_target_configuration()['validation_method']
model_context.set_validation_method(validation_method)
target_configuration_helper.generate_k8s_script(model_context.get_kubernetes_variable_file(), cache)
cache.clear()

variable_injector = VariableInjector(_program_name, model.get_model(), model_context,
WebLogicHelper(__logger).get_actual_weblogic_version(), cache)

inserted, variable_model, variable_file_name = \
VariableInjector(_program_name, model.get_model(), model_context,
WebLogicHelper(__logger).get_actual_weblogic_version(), cache).inject_variables_keyword_file()
variable_injector.inject_variables_keyword_file()

if inserted:
model = Model(variable_model)
try:
Expand Down
Loading