forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci_manifests.py
28 lines (22 loc) · 877 Bytes
/
ci_manifests.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
# 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 re
from io import TextIOWrapper
from typing import Type, Union
from ci_workflow.ci_args import CiArgs
from ci_workflow.ci_input_manifest import CiInputManifest
from ci_workflow.ci_test_manifest import CiTestManifest
class CiManifests:
@staticmethod
def __klass(filename: str) -> Union[Type[CiTestManifest], Type[CiInputManifest]]:
if re.search("-test.yml$", filename):
return CiTestManifest
else:
return CiInputManifest
@classmethod
def from_file(cls, file: TextIOWrapper, args: CiArgs) -> Union[CiTestManifest, CiInputManifest]:
return cls.__klass(file.name)(file, args)