From 2785bf54726231ec34058cba7d5e69a126a346f5 Mon Sep 17 00:00:00 2001 From: Ziv Nevo <79099626+zivnevo@users.noreply.github.com> Date: Wed, 25 Aug 2021 09:06:39 +0300 Subject: [PATCH] Issue #81 - A commandline switch to force a 0 return value (#84) --- network-config-analyzer/nca.py | 4 +++- tests/cmdline_tests.yaml | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/network-config-analyzer/nca.py b/network-config-analyzer/nca.py index 9fd74dfd4..be82d4ae4 100644 --- a/network-config-analyzer/nca.py +++ b/network-config-analyzer/nca.py @@ -146,6 +146,7 @@ def nca_main(argv=None): help='Output format specification (txt, csv, md, dot or yaml). The default is txt.') parser.add_argument('--file_out', '-f', type=str, help='A file path to which output is redirected') parser.add_argument('--pr_url', type=str, help='The full api url for adding a PR comment') + parser.add_argument('--return_0', action='store_true', help='Force a return value 0') args = parser.parse_args(argv) @@ -156,7 +157,8 @@ def nca_main(argv=None): return RestServer(args.ns_list, args.pod_list).run() if args.period <= 0: - return run_args(args) + ret_val = run_args(args) + return 0 if args.return_0 else ret_val _do_every(args.period * 60, run_args, args) return 0 diff --git a/tests/cmdline_tests.yaml b/tests/cmdline_tests.yaml index 54059789a..ae2cffd4c 100644 --- a/tests/cmdline_tests.yaml +++ b/tests/cmdline_tests.yaml @@ -85,3 +85,11 @@ --ns_list https://github.com/IBM/network-config-analyzer/tree/master/tests/example_workload_resources/ --pod_list https://github.com/IBM/network-config-analyzer/tree/master/tests/example_workload_resources/ expected: 0 + +- name: return_0 + args: > + --sanity example_policies/testcase8/testcase8-networkpolicy1.yaml + --ns_list example_podlist/ns_list.json + --pod_list example_podlist/pods_list.json + --return_0 + expected: 0