ALBS-444 #2

Merged
anfimovdm merged 9 commits from ALBS-444 into master 2022-07-01 14:25:17 +00:00
1 changed files with 12 additions and 8 deletions
Showing only changes of commit 036d5c589a - Show all commits

View File

@ -83,22 +83,24 @@ class CasWrapper:
self, self,
local_path: str, local_path: str,
return_json: bool = False, return_json: bool = False,
use_hash: bool = False,
): ):
""" """
Wrapper around `cas authenticate` Wrapper around `cas authenticate`
:param local_path: path to a local Git repo :param local_path: path to a local Git repo
(should be started from `git://`) (should be started from `git://`)
or to a single local file or to a single local file or hash
:param return_json: flag for return json response
:param use_hash: flag for authenticate by hash
:return: true if a commit is trusted, vice versa - false :return: true if a commit is trusted, vice versa - false
or dict with result if return_json param is True or dict with result if return_json param is True
:rtype: bool or dict :rtype: bool or dict
""" """
command = self._cas[ command_args = ['authenticate', local_path]
'authenticate', if use_hash:
local_path, command_args = ['authenticate', '--hash', local_path]
'-o', command_args.extend(('-o', 'json'))
'json', command = self._cas[command_args]
]
try: try:
with local.env( with local.env(
CAS_API_KEY=self._cas_api_key, CAS_API_KEY=self._cas_api_key,
@ -139,11 +141,13 @@ class CasWrapper:
def authenticate_artifact( def authenticate_artifact(
self, self,
local_path: str, local_path: str,
use_hash: bool = False,
) -> bool: ) -> bool:
is_authenticated = False is_authenticated = False
with self as cas: with self as cas:
anfimovdm marked this conversation as resolved Outdated

Instead of with self I would prefer self.ensure_login() or something, because you didn't use exit

Instead of `with self` I would prefer `self.ensure_login()` or something, because you didn't use __exit__

Done

Done
try: try:
anfimovdm marked this conversation as resolved Outdated

I guess colon is not needed in the logging message or it's in wrong place of the message

I guess colon is not needed in the logging message or it's in wrong place of the message
is_authenticated = cas.authenticate(local_path) is_authenticated = cas.authenticate(local_path,
use_hash=use_hash)
# we can fall with ProcessExecutionError, # we can fall with ProcessExecutionError,
# because source can be not notarized # because source can be not notarized
except ProcessExecutionError: except ProcessExecutionError: