Skip to content

Commit 6949e52

Browse files
authored
Merge pull request #303 from ligangty/radas-umb
Refactor: refactor the RadasSender
2 parents 08fe405 + 678606b commit 6949e52

File tree

10 files changed

+236
-218
lines changed

10 files changed

+236
-218
lines changed

charon/cmd/cmd_sign.py

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616
from typing import List
1717

1818
from charon.config import get_config
19-
from charon.pkgs.radas_signature_handler import sign_in_radas
20-
from charon.cmd.internal import (
21-
_decide_mode, _safe_delete
22-
)
19+
from charon.pkgs.radas_sign import sign_in_radas
20+
from charon.cmd.internal import _decide_mode
21+
2322
from click import command, option, argument
2423

2524
import traceback
@@ -39,14 +38,16 @@
3938
"-r",
4039
help="""
4140
The requester who sends the signing request.
42-
"""
41+
""",
42+
required=True
4343
)
4444
@option(
4545
"--result_path",
4646
"-p",
4747
help="""
4848
The path which will save the sign result file.
49-
"""
49+
""",
50+
required=True
5051
)
5152
@option(
5253
"--ignore_patterns",
@@ -57,14 +58,6 @@
5758
not be allowed to upload to S3. Can accept more than one pattern.
5859
"""
5960
)
60-
@option(
61-
"--work_dir",
62-
"-w",
63-
help="""
64-
The temporary working directory into which archives should
65-
be extracted, when needed.
66-
"""
67-
)
6861
@option(
6962
"--config",
7063
"-c",
@@ -79,7 +72,8 @@
7972
help="""
8073
rpm-sign key to be used, will replace {{ key }} in default configuration for signature.
8174
Does noting if detach_signature_command does not contain {{ key }} field.
82-
"""
75+
""",
76+
required=True
8377
)
8478
@option(
8579
"--debug",
@@ -100,10 +94,9 @@ def sign(
10094
repo_url: str,
10195
requester: str,
10296
result_path: str,
97+
sign_key: str,
10398
ignore_patterns: List[str] = None,
104-
work_dir: str = None,
10599
config: str = None,
106-
sign_key: str = "redhatdevel",
107100
debug=False,
108101
quiet=False,
109102
dryrun=False
@@ -112,7 +105,6 @@ def sign(
112105
radas service. The repo_url points to the maven zip repository
113106
in quay.io, which will be sent as the source of the signing.
114107
"""
115-
tmp_dir = work_dir
116108
logger.debug("%s", ignore_patterns)
117109
try:
118110
current = datetime.datetime.now().strftime("%Y%m%d%I%M")
@@ -139,10 +131,8 @@ def sign(
139131
"ignore_patterns": ig_patterns,
140132
"radas_config": radas_conf
141133
}
134+
logger.debug("params: %s", args)
142135
sign_in_radas(**args) # type: ignore
143136
except Exception:
144137
print(traceback.format_exc())
145138
sys.exit(2)
146-
finally:
147-
if not debug and tmp_dir:
148-
_safe_delete(tmp_dir)

charon/config.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,34 +75,36 @@ def validate(self) -> bool:
7575
return True
7676

7777
def umb_target(self) -> str:
78-
return f"amqps://{self.__umb_host}:{self.__umb_host_port}"
78+
return f"amqps://{self.__umb_host.strip()}:{self.__umb_host_port}"
7979

8080
def result_queue(self) -> str:
81-
return self.__result_queue
81+
return self.__result_queue.strip()
8282

8383
def request_queue(self) -> str:
84-
return self.__request_queue
84+
return self.__request_queue.strip()
8585

8686
def client_ca(self) -> str:
87-
return self.__client_ca
87+
return self.__client_ca.strip()
8888

8989
def client_key(self) -> str:
90-
return self.__client_key
90+
return self.__client_key.strip()
9191

9292
def client_key_password(self) -> str:
9393
pass_file = self.__client_key_pass_file
9494
if os.access(pass_file, os.R_OK):
9595
with open(pass_file, "r") as f:
96-
return f.read()
96+
return f.read().strip()
9797
elif pass_file:
9898
logger.warning("The key password file is not accessible. Will ignore the password.")
9999
return ""
100100

101101
def root_ca(self) -> str:
102-
return self.__root_ca
102+
return self.__root_ca.strip()
103103

104104
def quay_radas_registry_config(self) -> Optional[str]:
105-
return self.__quay_radas_registry_config
105+
if self.__quay_radas_registry_config:
106+
return self.__quay_radas_registry_config.strip()
107+
return None
106108

107109
def radas_sign_timeout_retry_count(self) -> int:
108110
return self.__radas_sign_timeout_retry_count

charon/pkgs/maven.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from charon.utils.files import HashType
1717
import charon.pkgs.indexing as indexing
1818
import charon.pkgs.signature as signature
19-
import charon.pkgs.radas_signature_handler as radas_signature
19+
import charon.pkgs.radas_sign as radas_signature
2020
from charon.utils.files import overwrite_file, digest, write_manifest
2121
from charon.utils.archive import extract_zip_all
2222
from charon.utils.strings import remove_prefix

0 commit comments

Comments
 (0)