forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
builders.py
25 lines (21 loc) · 935 Bytes
/
builders.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
# 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 build_workflow.build_target import BuildTarget
from build_workflow.builder import Builder
from build_workflow.builder_from_dist import BuilderFromDist
from build_workflow.builder_from_source import BuilderFromSource
from manifests.input_manifest import InputComponent
class Builders(ABC):
@classmethod
def builder_from(self, component: InputComponent, target: BuildTarget) -> Builder:
if hasattr(component, "dist"):
return BuilderFromDist(component, target)
elif hasattr(component, "repository"):
return BuilderFromSource(component, target)
else:
raise ValueError(f"Invalid component type: {type(component)}")