Skip to content

Commit

Permalink
Fixes based on code review.
Browse files Browse the repository at this point in the history
Version 1.2, because this is an enhancement, not a bug fix.

Additional checks on the command line interpretation to ensure valid input, plus unit tests for this.
  • Loading branch information
groboclown committed May 12, 2020
1 parent 658bc2a commit 186ab6c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion claircli/__version__.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
__version__ = '1.1.1'
__version__ = '1.2'
__title__ = 'claircli'
__description__ = 'Command line tool to interact with Clair'
__url__ = 'https://github.com/joelee2012/claircli'
Expand Down
6 changes: 5 additions & 1 deletion claircli/cli.py
Expand Up @@ -157,7 +157,11 @@ def analyze_image(self):
args.images = self.resolve_images(args.images)
for domain_token in args.domain_tokens:
domain_token_split = domain_token.split(':', 1)
if len(domain_token_split) != 2:
if (
len(domain_token_split) != 2 or
not domain_token_split[0] or
not domain_token_split[1]
):
logger.warning(
'registry token value must be in the form "domain:token"' +
'; found "%s"', domain_token)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_claircli.py
Expand Up @@ -274,8 +274,8 @@ def test_analyze_images_in_secure_registry(self):
with patch('sys.argv', ['claircli', '-c',
self.clair_url,
'-k', self.reg + ':' + token,
# Include a check for an ignored argument
'-k', '1234',
# Include a check for ignored arguments
'-k', '1234', '-k', 'ab:', '-k', ':',
self.name]):
cli = ClairCli()
cli.run()
Expand Down

0 comments on commit 186ab6c

Please sign in to comment.