forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
signers.py
35 lines (29 loc) · 1.09 KB
/
signers.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
#!/usr/bin/env python
# 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.
from sign_workflow.signer import Signer
from sign_workflow.signer_jar import SignerJar
from sign_workflow.signer_mac import SignerMac
from sign_workflow.signer_pgp import SignerPGP
from sign_workflow.signer_windows import SignerWindows
class Signers:
TYPES = {
"windows": SignerWindows,
"linux": SignerPGP,
"mac": SignerMac,
"jar_signer": SignerJar
}
@classmethod
def from_platform(cls, platform: str) -> Signer:
klass = cls.TYPES.get(platform, None)
if not klass:
raise ValueError(f"Unsupported type of platform for signing: {platform}")
return klass # type: ignore[return-value]
@classmethod
def create(cls, platform: str, overwrite: bool) -> Signer:
klass = cls.from_platform(platform)
return klass(overwrite) # type: ignore[no-any-return, operator]