Skip to content

Commit

Permalink
pkg_managers: gomod: Add preliminary support for Go 1.21
Browse files Browse the repository at this point in the history
One of Go 1.21's main features is specifying the suggested version of
toolchain to be used for compiling modules as a means of forwards
compatibility.
However, this patch only adds preliminary support for Go 1.21 in that
it essentially explicitly denies usage of toolchains (which is fine,
because those versions are only suggestive, Go always prefers building
with the bundled toolchain anyway) by the means of explicitly setting
the GOTOOLCHAIN env variable to 'local' which instructs Go to always
use it bundled toolchain (provided it's new enough to conform to the
minimum required version of Go indicated by the 'go' line). This patch
makes sure we set GOTOOLCHAIN=local during fetching of the dependencies
as well as for user container builds.

STONEBLD-2047

Signed-off-by: Erik Skultety <[email protected]>
  • Loading branch information
eskultety committed Feb 13, 2024
1 parent b44cf62 commit 75bdd30
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cachito/web/static/api_v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,9 @@ paths:
GOSUMDB:
value: off
kind: literal
GOTOOLCHAIN:
value: local
kind: literal
"404":
description: The request wasn't found
content:
Expand Down Expand Up @@ -1222,6 +1225,9 @@ components:
GOSUMDB:
value: off
kind: literal
GOTOOLCHAIN:
value: local
kind: literal
state:
$ref: "#/components/schemas/RequestState"
state_reason:
Expand Down
6 changes: 5 additions & 1 deletion cachito/workers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ class Config(object):
cachito_archives_minimum_age_days = 365
cachito_auth_type: Optional[str] = None
cachito_default_environment_variables = {
"gomod": {"GOSUMDB": {"value": "off", "kind": "literal"}},
"gomod": {
"GOSUMDB": {"value": "off", "kind": "literal"},
"GOTOOLCHAIN": {"value": "local", "kind": "literal"},
},
"npm": {
"CHROMEDRIVER_SKIP_DOWNLOAD": {"value": "true", "kind": "literal"},
"CYPRESS_INSTALL_BINARY": {"value": "0", "kind": "literal"},
Expand Down Expand Up @@ -161,6 +164,7 @@ class TestingConfig(DevelopmentConfig):
"gomod": {
"GO111MODULE": {"value": "on", "kind": "literal"},
"GOSUMDB": {"value": "off", "kind": "literal"},
"GOTOOLCHAIN": {"value": "local", "kind": "literal"},
},
"npm": {
"CHROMEDRIVER_SKIP_DOWNLOAD": {"value": "true", "kind": "literal"},
Expand Down
1 change: 1 addition & 0 deletions cachito/workers/pkg_managers/gomod.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ def resolve_gomod(app_source_path, request, dep_replacements=None, git_dir_path=
"GOPROXY": f"{athens_url}|{athens_url}",
"PATH": os.environ.get("PATH", ""),
"GOMODCACHE": "{}/pkg/mod".format(temp_dir),
"GOTOOLCHAIN": "local",
}
if "cgo-disable" in request.get("flags", []):
env["CGO_ENABLED"] = "0"
Expand Down
1 change: 1 addition & 0 deletions tests/test_workers/test_tasks/test_gomod.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def directory_present(*args, **kwargs):
env_vars = {
"GO111MODULE": {"value": "on", "kind": "literal"},
"GOSUMDB": {"value": "off", "kind": "literal"},
"GOTOOLCHAIN": {"value": "local", "kind": "literal"},
}
sample_env_vars.update(env_vars)

Expand Down

0 comments on commit 75bdd30

Please sign in to comment.