Skip to content

Commit

Permalink
Issue #81 - A commandline switch to force a 0 return value (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
zivnevo committed Aug 25, 2021
1 parent 8fa4d63 commit 2785bf5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion network-config-analyzer/nca.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions tests/cmdline_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2785bf5

Please sign in to comment.