forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci_check_lists.py
29 lines (25 loc) · 1.12 KB
/
ci_check_lists.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
# 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 abc import ABC
from typing import Any
from ci_workflow.ci_check_list_dist import CiCheckListDist
from ci_workflow.ci_check_list_source import CiCheckListSource
from ci_workflow.ci_check_list_source_ref import CiCheckListSourceRef
from ci_workflow.ci_target import CiTarget
from manifests.input_manifest import InputComponentFromDist, InputComponentFromSource
class CiCheckLists(ABC):
@classmethod
def from_component(self, component: Any, target: CiTarget) -> Any:
if type(component) is InputComponentFromDist:
return CiCheckListDist(component, target)
elif type(component) is InputComponentFromSource:
if len(component.checks) > 0:
return CiCheckListSource(component, target)
else:
return CiCheckListSourceRef(component, target)
else:
raise ValueError(f"Invalid component type: {type(component)}")