Added ability to authenticate artifact by hash
This commit is contained in:
parent
0a94dc6f8f
commit
036d5c589a
@ -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:
|
||||||
try:
|
try:
|
||||||
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:
|
||||||
|
Loading…
Reference in New Issue
Block a user