forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bundles.py
32 lines (26 loc) · 1.2 KB
/
bundles.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
32
# 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 assemble_workflow.bundle import Bundle
from assemble_workflow.bundle_opensearch import BundleOpenSearch
from assemble_workflow.bundle_opensearch_dashboards import BundleOpenSearchDashboards
from assemble_workflow.bundle_recorder import BundleRecorder
from manifests.build_manifest import BuildManifest
class Bundles:
TYPES = {
"OpenSearch": BundleOpenSearch,
"OpenSearch Dashboards": BundleOpenSearchDashboards,
}
@classmethod
def from_name(cls, name: str) -> Bundle:
klass = cls.TYPES.get(name, None)
if not klass:
raise ValueError(f"Unsupported bundle: {name}")
return klass # type: ignore[return-value]
@classmethod
def create(cls, build_manifest: BuildManifest, artifacts_dir: str, bundle_recorder: BundleRecorder, keep: bool) -> Bundle:
klass = cls.from_name(build_manifest.build.name)
return klass(build_manifest, artifacts_dir, bundle_recorder, keep) # type: ignore[no-any-return, operator]