forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sign_args.py
80 lines (74 loc) · 2.23 KB
/
sign_args.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
import argparse
import logging
from pathlib import Path
from typing import List
class SignArgs:
ACCEPTED_SIGNATURE_FILE_TYPES = [".sig", ".asc"]
ACCEPTED_PLATFORM = ["linux", "windows", "mac", "jar_signer"]
target: Path
components: List[str]
type: str
sigtype: str
platform: str
overwrite: bool
def __init__(self) -> None:
parser = argparse.ArgumentParser(description="Sign artifacts")
parser.add_argument(
"target",
type=Path,
help="Path to local manifest file or artifact directory"
)
parser.add_argument(
"-c",
"--component",
type=str,
nargs='*',
dest="components",
help="Component or components to sign"
)
parser.add_argument(
"--type",
help="Artifact type"
)
parser.add_argument(
"--sigtype",
choices=self.ACCEPTED_SIGNATURE_FILE_TYPES,
help="Type of signature file.",
default=".sig"
)
parser.add_argument(
"--platform",
choices=self.ACCEPTED_PLATFORM,
help="Distribution platform.",
default="linux"
)
parser.add_argument(
"--overwrite",
action="store_true",
help="Overwrite existing artifacts or signature files.",
default=False,
dest="overwrite"
)
parser.add_argument(
"-v",
"--verbose",
help="Show more verbose output.",
action="store_const",
default=logging.INFO,
const=logging.DEBUG,
dest="logging_level",
)
args = parser.parse_args()
self.logging_level = args.logging_level
self.target = args.target
self.type = args.type
self.sigtype = args.sigtype
self.components = args.components
self.platform = args.platform
self.overwrite = args.overwrite