-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add strict SQL mode to allow d2-cloner to stop execution on error during cloning process #136
base: development
Are you sure you want to change the base?
Changes from 4 commits
05baf81
a98cc72
bf380c7
fb587b5
906e9c4
53fac6c
759d8d0
ea240d5
5dfb7aa
137e2c5
79eb233
8f601bf
6d68319
9b753f9
612c4f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,9 @@ def main(): | |
args = parser.parse_args() | ||
utils.logger.setLevel(args.log_level.upper()) | ||
|
||
|
||
if getattr(args, "strict_sql", False) and not args.run_sql: | ||
parser.error("--strict-sql requires --run-sql to be set") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cannot do args checking of some specific command (start) in the main cli. The check should be done in the "run" function of start.py. |
||
if not getattr(args, "func", None): | ||
parser.print_usage() | ||
return 1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ def setup(parser): | |
parser.add_argument("--tomcat-server-xml", metavar="FILE", help=server_xml_help) | ||
parser.add_argument("--dhis-conf", metavar="FILE", help=dhis_conf_help) | ||
parser.add_argument("--run-sql", metavar="DIRECTORY", help="Run .sql[.gz] files in directory") | ||
parser.add_argument("--strict-sql", action="store_true", default=False, help="Stop the sql script on first fail and show in the log") | ||
parser.add_argument("--debug-port", metavar="PORT", help="Expose DHIS2 core debug port") | ||
parser.add_argument("--db-port", metavar="PORT", help="Expose DB Postgres port") | ||
parser.add_argument( | ||
|
@@ -93,6 +94,11 @@ def start(args): | |
) | ||
|
||
deploy_path = "/" + re.sub("^/*", "", args.deploy_path) if args.deploy_path else "" | ||
post_strict_sql_dir = None | ||
post_sql_dir = args.run_sql | ||
if args.run_sql and args.strict_sql: | ||
post_strict_sql_dir = post_sql_dir | ||
post_sql_dir = None | ||
|
||
with utils.stop_docker_on_interrupt(image_name, core_image): | ||
utils.run_docker_compose( | ||
|
@@ -102,7 +108,8 @@ def start(args): | |
bind_ip=args.bind_ip, | ||
core_image=core_image, | ||
load_from_data=override_containers, | ||
post_sql_dir=args.run_sql, | ||
post_sql_dir=post_sql_dir, | ||
post_strict_sql_dir=post_strict_sql_dir, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of passing a new |
||
debug_port=args.debug_port, | ||
db_port=args.db_port, | ||
scripts_dir=args.run_scripts, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra blank line