forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_target.py
75 lines (65 loc) · 2.29 KB
/
build_target.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# 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.
import os
import uuid
from typing import List
from system.os import current_architecture, current_platform
class BuildTarget:
build_id: str
name: str
version: str
platform: str
architecture: str
distribution: str
snapshot: bool
output_dir: str
def __init__(
self,
version: str,
patches: List[str] = [],
platform: str = None,
architecture: str = None,
distribution: str = None,
name: str = None,
snapshot: bool = True,
build_id: str = None,
output_dir: str = "artifacts",
):
self.build_id = os.getenv("BUILD_NUMBER") or build_id or uuid.uuid4().hex
self.name = name
self.version = version
self.patches = patches
self.snapshot = snapshot
self.architecture = architecture or current_architecture()
self.distribution = distribution
self.platform = platform or current_platform()
self.output_dir = output_dir
@property
def opensearch_version(self) -> str:
return self.version + "-SNAPSHOT" if self.snapshot else self.version
@property
def compatible_opensearch_versions(self) -> List[str]:
return (
[self.version + "-SNAPSHOT" if self.snapshot else self.version]
+ self.patches
+ list(map(lambda version: version + "-SNAPSHOT", self.patches))
)
@property
def component_version(self) -> str:
# BUG: the 4th digit is dictated by the component, it's not .0, this will break for 1.1.0.1
return self.version + ".0-SNAPSHOT" if self.snapshot else f"{self.version}.0"
@property
def compatible_component_versions(self) -> List[str]:
return (
[self.version + ".0-SNAPSHOT" if self.snapshot else f"{self.version}.0"]
+ list(map(lambda version: version + ".0", self.patches))
+ list(map(lambda version: version + ".0-SNAPSHOT", self.patches))
)
@property
def compatible_versions(self) -> List[str]:
versions = [self.version]
versions.extend(self.patches)
return versions