forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci_check_lists.py
28 lines (24 loc) · 1.01 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
# 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
class CiCheckLists(ABC):
@classmethod
def from_component(self, component: Any, target: CiTarget) -> Any:
if hasattr(component, "dist"):
return CiCheckListDist(component, target)
elif hasattr(component, "repository"):
if len(component.checks) > 0:
return CiCheckListSource(component, target)
else:
return CiCheckListSourceRef(component, target)
else:
raise ValueError(f"Invalid component type: {type(component)}")