Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def add(input_repo, noautosubscribe, lookuptag):
"""
INPUT_REPO: Input repository can be in the following formats: registry/repo
"""
ecode = 0
autosubscribe = not noautosubscribe
image_info = anchorecli.cli.utils.parse_dockerimage_string(input_repo)
input_repo = image_info['registry'] + "/" + image_info['repo']
try:
ret = anchorecli.clients.apiexternal.add_repo(config, input_repo, autosubscribe=autosubscribe, lookuptag=lookuptag)
ecode = anchorecli.cli.utils.get_ecode(ret)
if ret['success']:
print(anchorecli.cli.utils.format_output(config, 'repo_add', {}, ret['payload']))
else:
raise Exception( json.dumps(ret['error'], indent=4))
except Exception as err:
print(anchorecli.cli.utils.format_error_output(config, 'repo_add', {}, err))
if not ecode:
ecode = 2
anchorecli.cli.utils.doexit(ecode)
def unwatch(input_repo):
"""
INPUT_REPO: Input repo can be in the following formats: registry/repo
"""
ecode = 0
image_info = anchorecli.cli.utils.parse_dockerimage_string(input_repo)
input_repo = image_info['registry'] + "/" + image_info['repo']
try:
ret = anchorecli.clients.apiexternal.unwatch_repo(config, input_repo)
ecode = anchorecli.cli.utils.get_ecode(ret)
if ret:
if ret['success']:
print(anchorecli.cli.utils.format_output(config, 'repo_unwatch', {}, ret['payload']))
else:
raise Exception(json.dumps(ret['error'], indent=4))
else:
raise Exception("operation failed with empty response")
except Exception as err:
print(anchorecli.cli.utils.format_error_output(config, 'repo_unwatch', {}, err))
if not ecode:
def watch(input_repo):
"""
INPUT_REPO: Input repo can be in the following formats: registry/repo
"""
ecode = 0
image_info = anchorecli.cli.utils.parse_dockerimage_string(input_repo)
input_repo = image_info['registry'] + "/" + image_info['repo']
try:
ret = anchorecli.clients.apiexternal.watch_repo(config, input_repo)
ecode = anchorecli.cli.utils.get_ecode(ret)
if ret:
if ret['success']:
print(anchorecli.cli.utils.format_output(config, 'repo_watch', {}, ret['payload']))
else:
raise Exception(json.dumps(ret['error'], indent=4))
else:
raise Exception("operation failed with empty response")
except Exception as err:
print(anchorecli.cli.utils.format_error_output(config, 'repo_watch', {}, err))
if not ecode:
def delete(input_repo):
"""
INPUT_REPO: Input repo can be in the following formats: registry/repo
"""
ecode = 0
image_info = anchorecli.cli.utils.parse_dockerimage_string(input_repo)
input_repo = image_info['registry'] + "/" + image_info['repo']
try:
ret = anchorecli.clients.apiexternal.delete_repo(config, input_repo)
ecode = anchorecli.cli.utils.get_ecode(ret)
if ret:
if ret['success']:
print(anchorecli.cli.utils.format_output(config, 'repo_delete', {}, ret['payload']))
else:
raise Exception(json.dumps(ret['error'], indent=4))
else:
raise Exception("operation failed with empty response")
except Exception as err:
print(anchorecli.cli.utils.format_error_output(config, 'repo_delete', {}, err))
if not ecode:
def get(input_repo):
"""
INPUT_REPO: Input repository can be in the following formats: registry/repo
"""
ecode = 0
image_info = anchorecli.cli.utils.parse_dockerimage_string(input_repo)
input_repo = image_info['registry'] + "/" + image_info['repo']
try:
ret = anchorecli.clients.apiexternal.get_repo(config, input_repo=input_repo)
if ret:
ecode = anchorecli.cli.utils.get_ecode(ret)
if ret['success']:
print(anchorecli.cli.utils.format_output(config, 'repo_get', {}, ret['payload']))
else:
raise Exception(json.dumps(ret['error'], indent=4))
else:
raise Exception("operation failed with empty response")
except Exception as err:
print(anchorecli.cli.utils.format_error_output(config, 'repo_get', {}, err))
if not ecode: