forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_artifact_checks.py
43 lines (36 loc) · 1.59 KB
/
build_artifact_checks.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
33
34
35
36
37
38
39
40
41
42
43
# 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 typing import Any, Dict
from build_workflow.build_target import BuildTarget
from build_workflow.opensearch.build_artifact_check_maven import BuildArtifactOpenSearchCheckMaven
from build_workflow.opensearch.build_artifact_check_plugin import BuildArtifactOpenSearchCheckPlugin
from build_workflow.opensearch_dashboards.build_artifact_check_plugin import BuildArtifactOpenSearchDashboardsCheckPlugin
class BuildArtifactChecks:
TYPES: Dict[str, Dict[str, Any]] = {
"OpenSearch": {
"plugins": BuildArtifactOpenSearchCheckPlugin,
"maven": BuildArtifactOpenSearchCheckMaven,
},
"OpenSearch Dashboards": {"plugins": BuildArtifactOpenSearchDashboardsCheckPlugin},
}
@classmethod
def from_name_and_type(cls, name: str, type: str) -> Any:
checks = cls.TYPES.get(name, None)
if not checks:
raise ValueError(f"Unsupported bundle: {name}")
return checks.get(type, None)
@classmethod
def create(cls, target: BuildTarget, artifact_type: str) -> Any:
klass = cls.from_name_and_type(target.name, artifact_type)
if not klass:
return None
return klass(target)
@classmethod
def check(cls, target: BuildTarget, artifact_type: str, path: str) -> None:
instance = cls.create(target, artifact_type)
if instance:
instance.check(path)