forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsigners.py
31 lines (25 loc) · 941 Bytes
/
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
#!/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_pgp import SignerPGP
from sign_workflow.signer_windows import SignerWindows
class Signers:
TYPES = {
"windows": SignerWindows,
"linux": SignerPGP,
}
@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) -> Signer:
klass = cls.from_platform(platform)
return klass() # type: ignore[no-any-return, operator]