Skip to content

Commit 52defa8

Browse files
committed
Merge remote-tracking branch 'origin/kubernetes-doc' into kubernetes-doc
2 parents 889164e + 4cc5df4 commit 52defa8

File tree

31 files changed

+2323
-400
lines changed

31 files changed

+2323
-400
lines changed

core/src/main/antlr4/oracle/weblogic/deploy/yaml/Yaml.g4

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
33
* The Universal Permissive License (UPL), Version 1.0
44
*/
55
grammar Yaml;
@@ -84,17 +84,17 @@ statement
8484
;
8585

8686
assign
87-
: name ASSIGN_OP value WS? COMMENT? NEWLINE?
87+
: name ASSIGN_OP value COMMENT? NEWLINE
8888
;
8989

9090
list_item
9191
: LIST_ITEM_OP assign # YamlListItemAssign
92-
| LIST_ITEM_OP value WS? COMMENT? NEWLINE? # YamlListItemValue
92+
| LIST_ITEM_OP value COMMENT? NEWLINE? # YamlListItemValue
9393
| LIST_ITEM_OP object # YamlListItemObject
9494
;
9595

9696
object
97-
: name BLOCK_OP COMMENT? obj_block
97+
: name ASSIGN_OP COMMENT? obj_block
9898
;
9999

100100
obj_block
@@ -127,8 +127,16 @@ inline_list_item
127127
: (NEWLINE (INDENT)?)? value
128128
;
129129

130+
// comments and blank lines before the first element avoid use of NEWLINE so there is no indent/dedent.
131+
// this rule should be one of the first in this file, to override later definitions.
132+
ATSTART
133+
: {atStartOfInput()}? ( (COMMENT | WS*) ('\r'? '\n' | '\r' | '\f') )+ -> skip
134+
;
135+
136+
// comments may appear on separate lines, or on the same line as assignments or object starts.
137+
// don't close with NEWLINE here, needed to distinguish assign from object declaration.
130138
COMMENT
131-
: '# ' ~[\r\n\f]+ NEWLINE -> skip
139+
: WS? '#' ~[\r\n\f]* -> skip
132140
;
133141

134142
NULL
@@ -192,7 +200,12 @@ NEWLINE
192200
String spaces = getText().replaceAll("[\r\n\f]+", "");
193201
194202
int next = _input.LA(1);
195-
if (opened > 0 || next == '\r' || next == '\n' || next == '\f') {
203+
204+
// if opened > 0, we're in a square-bracket list.
205+
// if next character is end-of-line, this was a blank line.
206+
// if next character is #, this is a comment line.
207+
// for these cases, don't check for indent, dedent.
208+
if (opened > 0 || next == '\r' || next == '\n' || next == '\f' || next == '#') {
196209
skip();
197210
} else {
198211
emit(commonToken(NEWLINE, newLine));
@@ -233,10 +246,6 @@ LIST_ITEM_OP
233246
;
234247

235248
ASSIGN_OP
236-
: WS? ': ' WS?
237-
;
238-
239-
BLOCK_OP
240249
: WS? ':' WS?
241250
;
242251

core/src/main/java/oracle/weblogic/deploy/logging/LoggingUtils.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
33
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
*/
55
package oracle.weblogic.deploy.logging;
@@ -17,7 +17,9 @@ public static <T extends Handler> Class<T> getHandlerClass(String handlerName) {
1717
Class<T> handler = null;
1818
try {
1919
Class<?> checkClass = Class.forName(handlerName);
20-
handler = (Class<T>)checkClass.asSubclass(Class.forName(handlerName));
20+
@SuppressWarnings("unchecked")
21+
Class<T> castHandler = (Class<T>)checkClass.asSubclass(Class.forName(handlerName));
22+
handler = castHandler;
2123
} catch(ClassNotFoundException | ClassCastException cnf) {
2224
exitWithError(
2325
MessageFormat.format("Unable to find handler class {0} so skipping logging configuration",

core/src/main/python/create.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
55
The main module for the WLSDeploy tool to create empty domains.
@@ -48,6 +48,7 @@
4848
from wlsdeploy.util import wlst_extended
4949
from wlsdeploy.util import wlst_helper
5050
from wlsdeploy.util.cla_utils import CommandLineArgUtil
51+
from wlsdeploy.util.cla_utils import TOOL_TYPE_CREATE
5152
from wlsdeploy.util.weblogic_helper import WebLogicHelper
5253
from wlsdeploy.tool.create import atp_helper
5354

@@ -92,7 +93,7 @@ def __process_args(args):
9293
"""
9394
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
9495
cla_util.set_allow_multiple_models(True)
95-
required_arg_map, optional_arg_map = cla_util.process_args(args, True)
96+
required_arg_map, optional_arg_map = cla_util.process_args(args, TOOL_TYPE_CREATE)
9697
__verify_required_args_present(required_arg_map)
9798
__process_java_home_arg(optional_arg_map)
9899
__process_domain_location_args(optional_arg_map)
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
"""
2+
Copyright (c) 2020, Oracle Corporation and/or its affiliates. All rights reserved.
3+
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
5+
The entry point for the extractDomainResource tool.
6+
"""
7+
import os
8+
import sys
9+
10+
from oracle.weblogic.deploy.deploy import DeployException
11+
from oracle.weblogic.deploy.util import CLAException
12+
from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion
13+
14+
sys.path.append(os.path.dirname(os.path.realpath(sys.argv[0])))
15+
16+
# imports from local packages start here
17+
from wlsdeploy.aliases.aliases import Aliases
18+
from wlsdeploy.aliases.wlst_modes import WlstModes
19+
from wlsdeploy.exception.expection_types import ExceptionType
20+
from wlsdeploy.logging.platform_logger import PlatformLogger
21+
from wlsdeploy.tool.extract.domain_resource_extractor import DomainResourceExtractor
22+
from wlsdeploy.tool.util import model_context_helper
23+
from wlsdeploy.tool.util.wlst_helper import WlstHelper
24+
from wlsdeploy.util import cla_helper
25+
from wlsdeploy.util import tool_exit
26+
from wlsdeploy.util import wlst_extended
27+
from wlsdeploy.util.cla_utils import CommandLineArgUtil
28+
from wlsdeploy.util.cla_utils import TOOL_TYPE_EXTRACT
29+
from wlsdeploy.util.model import Model
30+
from wlsdeploy.util.weblogic_helper import WebLogicHelper
31+
32+
wlst_extended.wlst_functions = globals()
33+
34+
_program_name = 'extractDomainResource'
35+
_class_name = 'extract_resource'
36+
__logger = PlatformLogger('wlsdeploy.extract')
37+
__wls_helper = WebLogicHelper(__logger)
38+
__wlst_helper = WlstHelper(__logger, ExceptionType.DEPLOY)
39+
__wlst_mode = WlstModes.OFFLINE
40+
41+
__required_arguments = [
42+
CommandLineArgUtil.ORACLE_HOME_SWITCH,
43+
CommandLineArgUtil.DOMAIN_HOME_SWITCH,
44+
CommandLineArgUtil.DOMAIN_RESOURCE_FILE_SWITCH
45+
]
46+
47+
__optional_arguments = [
48+
# Used by shell script to locate WLST
49+
CommandLineArgUtil.DOMAIN_TYPE_SWITCH,
50+
CommandLineArgUtil.ARCHIVE_FILE_SWITCH,
51+
CommandLineArgUtil.MODEL_FILE_SWITCH,
52+
CommandLineArgUtil.VARIABLE_FILE_SWITCH,
53+
CommandLineArgUtil.USE_ENCRYPTION_SWITCH,
54+
CommandLineArgUtil.PASSPHRASE_SWITCH,
55+
]
56+
57+
58+
def __process_args(args):
59+
"""
60+
Process the command-line arguments and prompt the user for any missing information
61+
:param args: the command-line arguments list
62+
:raises CLAException: if an error occurs while validating and processing the command-line arguments
63+
"""
64+
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
65+
cla_util.set_allow_multiple_models(True)
66+
required_arg_map, optional_arg_map = cla_util.process_args(args, TOOL_TYPE_EXTRACT)
67+
68+
cla_helper.verify_required_args_present(_program_name, __required_arguments, required_arg_map)
69+
cla_helper.validate_optional_archive(_program_name, optional_arg_map)
70+
71+
# determine if the model file was passed separately or requires extraction from the archive.
72+
cla_helper.validate_model_present(_program_name, optional_arg_map)
73+
cla_helper.validate_variable_file_exists(_program_name, optional_arg_map)
74+
cla_helper.process_encryption_args(optional_arg_map)
75+
76+
combined_arg_map = optional_arg_map.copy()
77+
combined_arg_map.update(required_arg_map)
78+
return model_context_helper.create_context(_program_name, combined_arg_map)
79+
80+
81+
def __extract_resource(model, model_context, aliases):
82+
"""
83+
Offline deployment orchestration
84+
:param model: the model
85+
:param model_context: the model context
86+
:param aliases: the aliases object
87+
:raises: DeployException: if an error occurs
88+
"""
89+
_method_name = '__extract_resource'
90+
91+
resource_extractor = DomainResourceExtractor(model, model_context, aliases, __logger)
92+
resource_extractor.extract()
93+
return 0
94+
95+
96+
def main(args):
97+
"""
98+
The python entry point for extractDomainResource.
99+
:param args: the command-line arguments
100+
"""
101+
_method_name = 'main'
102+
103+
__logger.entering(args[0], class_name=_class_name, method_name=_method_name)
104+
for index, arg in enumerate(args):
105+
__logger.finer('sys.argv[{0}] = {1}', str(index), str(arg), class_name=_class_name, method_name=_method_name)
106+
107+
__wlst_helper.silence()
108+
109+
exit_code = CommandLineArgUtil.PROG_OK_EXIT_CODE
110+
111+
try:
112+
model_context = __process_args(args)
113+
except CLAException, ex:
114+
exit_code = ex.getExitCode()
115+
if exit_code != CommandLineArgUtil.HELP_EXIT_CODE:
116+
__logger.severe('WLSDPLY-20008', _program_name, ex.getLocalizedMessage(), error=ex,
117+
class_name=_class_name, method_name=_method_name)
118+
cla_helper.clean_up_temp_files()
119+
120+
# create a minimal model for summary logging
121+
model_context = model_context_helper.create_exit_context(_program_name)
122+
tool_exit.end(model_context, exit_code)
123+
124+
aliases = Aliases(model_context, wlst_mode=__wlst_mode)
125+
126+
model_dictionary = cla_helper.load_model(_program_name, model_context, aliases, "extract", __wlst_mode)
127+
128+
try:
129+
model = Model(model_dictionary)
130+
exit_code = __extract_resource(model, model_context, aliases)
131+
except DeployException, ex:
132+
__logger.severe('WLSDPLY-09015', _program_name, ex.getLocalizedMessage(), error=ex,
133+
class_name=_class_name, method_name=_method_name)
134+
cla_helper.clean_up_temp_files()
135+
tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
136+
137+
cla_helper.clean_up_temp_files()
138+
139+
tool_exit.end(model_context, exit_code)
140+
return
141+
142+
143+
if __name__ == '__main__' or __name__ == 'main':
144+
WebLogicDeployToolingVersion.logVersionInfo(_program_name)
145+
main(sys.argv)

0 commit comments

Comments
 (0)