-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathgolang.py
More file actions
126 lines (115 loc) · 4.12 KB
/
golang.py
File metadata and controls
126 lines (115 loc) · 4.12 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
"""Go language BCI containers"""
import textwrap
from itertools import product
from typing import Literal
from bci_build.container_attributes import SupportLevel
from bci_build.os_version import CAN_BE_LATEST_OS_VERSION
from bci_build.os_version import OsVersion
from bci_build.package import DOCKERFILE_RUN
from bci_build.package import LOG_CLEAN
from bci_build.package import DevelopmentContainer
from bci_build.package import generate_disk_size_constraints
from bci_build.replacement import Replacement
from bci_build.util import ParseVersion
_GO_VER_T = Literal["1.20", "1.21", "1.22", "1.23", "1.24", "1.25"]
_GOLANG_VERSIONS: list[_GO_VER_T] = ["1.24", "1.25"]
_GOLANG_OPENSSL_VERSIONS: list[_GO_VER_T] = ["1.24", "1.25"]
_GOLANG_VARIANT_T = Literal["", "-openssl"]
assert len(_GOLANG_VERSIONS) == 2, "Only two golang versions must be supported"
assert len(_GOLANG_OPENSSL_VERSIONS) == 2, (
"Only two golang-openssl versions must be supported"
)
def _get_golang_kwargs(
ver: _GO_VER_T, variant: _GOLANG_VARIANT_T, os_version: OsVersion
):
golang_version_regex = "%%golang_version%%"
if variant == "":
is_stable = ver == _GOLANG_VERSIONS[-1]
elif variant == "-openssl":
is_stable = ver == _GOLANG_OPENSSL_VERSIONS[-1]
stability_tag = f"oldstable{variant}"
if is_stable:
stability_tag = f"stable{variant}"
go = f"go{ver}{variant}"
go_packages = (
f"{go}",
f"{go}-doc",
)
return {
"os_version": os_version,
"package_name": f"golang-{stability_tag}-image",
"pretty_name": f"Go {ver}{variant} development",
"name": "golang",
"stability_tag": stability_tag,
"is_latest": (is_stable and (os_version in CAN_BE_LATEST_OS_VERSION)),
"tag_version": f"{ver}{variant}",
"version": f"{golang_version_regex}{variant}",
"env": {
"GOLANG_VERSION": golang_version_regex,
"GOPATH": "/go",
"GOTOOLCHAIN": "local",
"PATH": "/go/bin:/usr/local/go/bin:/root/go/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
},
"replacements_via_service": [
Replacement(
regex_in_build_description=golang_version_regex,
package_name=go,
parse_version=ParseVersion.PATCH,
)
],
"custom_end": (
textwrap.dedent(
f"""
# only available on go's tsan_arch architectures
#!ArchExclusiveLine: x86_64 aarch64 s390x ppc64le
{DOCKERFILE_RUN} if zypper -n install {go}-race; then zypper -n clean -a; fi
WORKDIR /go
{DOCKERFILE_RUN} install -m 755 -d /go/bin /go/src
"""
)
+ f"{DOCKERFILE_RUN} {LOG_CLEAN}"
),
"package_list": [*go_packages, "make"]
+ os_version.common_devel_packages
+ os_version.lifecycle_data_pkg,
"extra_files": {
# the go binaries are huge and will ftbfs on workers with a root partition with 4GB
"_constraints": generate_disk_size_constraints(8)
},
"min_release_counter": {
OsVersion.SP7: 70,
},
}
GOLANG_CONTAINERS = (
[
DevelopmentContainer(
**_get_golang_kwargs(ver, govariant, sle15sp),
support_level=SupportLevel.L3,
)
for ver, govariant, sle15sp in product(
_GOLANG_VERSIONS, ("",), (OsVersion.SP7,)
)
]
+ [
DevelopmentContainer(
**_get_golang_kwargs(ver, govariant, sl16ver),
support_level=SupportLevel.L3,
)
for ver, govariant, sl16ver in product(
_GOLANG_VERSIONS, ("",), (OsVersion.SL16_0,)
)
]
+ [
DevelopmentContainer(
**_get_golang_kwargs(ver, govariant, sle15sp),
support_level=SupportLevel.L3,
)
for ver, govariant, sle15sp in product(
_GOLANG_OPENSSL_VERSIONS, ("-openssl",), (OsVersion.SP7,)
)
]
+ [
DevelopmentContainer(**_get_golang_kwargs(ver, "", OsVersion.TUMBLEWEED))
for ver in _GOLANG_VERSIONS
]
)