Skip to content

Commit 81ca59a

Browse files
author
Clemens Beck
committed
Go builds: Use local toolchain
Use the local Go toolchain (the Go version included in the Omnibus builder images) for all Go builds. This prevents us from accidentally building Go binaries with another Go version. Go toolchain documentation: https://go.dev/doc/toolchain
1 parent 6dec87e commit 81ca59a

12 files changed

+22
-5
lines changed

config/software/alertmanager.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
env = {
3939
'GOPATH' => "#{Omnibus::Config.source_dir}/alertmanager",
4040
'GO111MODULE' => 'on',
41+
'GOTOOLCHAIN' => 'local',
4142
}
4243
exporter_source_dir = "#{Omnibus::Config.source_dir}/alertmanager"
4344
cwd = "#{exporter_source_dir}/src/#{go_source}"

config/software/consul.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
build do
3434
env = {}
3535
env['GOPATH'] = "#{Omnibus::Config.source_dir}/consul"
36+
env['GOTOOLCHAIN'] = 'local'
3637
env['PATH'] = "#{Gitlab::Util.get_env('PATH')}:#{env['GOPATH']}/bin"
38+
3739
command 'make dev', env: env
3840
mkdir "#{install_dir}/embedded/bin"
3941
copy 'bin/consul', "#{install_dir}/embedded/bin/"

config/software/docker-distribution-pruner.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
relative_path 'src/gitlab.com/gitlab-org/docker-distribution-pruner'
3030

3131
build do
32-
env = { 'GOPATH' => "#{Omnibus::Config.source_dir}/docker-distribution-pruner" }
32+
env = {
33+
'GOPATH' => "#{Omnibus::Config.source_dir}/docker-distribution-pruner",
34+
'GOTOOLCHAIN' => 'local',
35+
}
3336

3437
command "go build -ldflags '-s -w' ./cmds/docker-distribution-pruner", env: env
3538

config/software/gitlab-pages.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@
2929
relative_path 'src/gitlab.com/gitlab-org/gitlab-pages'
3030

3131
build do
32-
# This is required for GO15VENDOREXPERIMENT=1 to work properly,
33-
# since it requires the package to be in $GOPATH/src/package
34-
env = { 'GOPATH' => "#{Omnibus::Config.source_dir}/gitlab-pages" }
32+
env = {
33+
# This is required for GO15VENDOREXPERIMENT=1 to work properly,
34+
# since it requires the package to be in $GOPATH/src/package
35+
'GOPATH' => "#{Omnibus::Config.source_dir}/gitlab-pages",
36+
'GOTOOLCHAIN' => 'local',
37+
}
3538

3639
# Pages compiles with CGO_ENABLED=0 by default, so we need to activate
3740
# FIPS mode explicitly.

config/software/go-crond.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
build do
2929
env = {
3030
'GOPATH' => "#{Omnibus::Config.source_dir}/go-crond",
31+
'GOTOOLCHAIN' => 'local',
3132
}
3233

3334
make 'build', env: env

config/software/node-exporter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
'GOPATH' => "#{Omnibus::Config.source_dir}/node-exporter",
3838
'CGO_ENABLED' => '0', # Details: https://github.com/prometheus/node_exporter/issues/870
3939
'GO111MODULE' => 'on',
40+
'GOTOOLCHAIN' => 'local',
4041
}
4142

4243
prom_version = Prometheus::VersionFlags.new(version)

config/software/pgbouncer-exporter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
env = {
3838
'GOPATH' => "#{Omnibus::Config.source_dir}/pgbouncer-exporter",
3939
'GO111MODULE' => 'on',
40+
'GOTOOLCHAIN' => 'local',
4041
}
4142
prom_version = Prometheus::VersionFlags.new(version)
4243

config/software/postgres-exporter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
build do
3535
env = {
3636
'GOPATH' => "#{Omnibus::Config.source_dir}/postgres-exporter",
37+
'GOTOOLCHAIN' => 'local',
3738
}
3839

3940
prom_version = Prometheus::VersionFlags.new(version)

config/software/prometheus.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
env = {
4040
'GOPATH' => prometheus_source_dir,
4141
'GO111MODULE' => 'on',
42+
'GOTOOLCHAIN' => 'local',
4243
}
4344

4445
prom_version = Prometheus::VersionFlags.new(version)

config/software/redis-exporter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
env = {
3535
'GOPATH' => "#{Omnibus::Config.source_dir}/redis-exporter",
3636
'GO111MODULE' => 'on',
37+
'GOTOOLCHAIN' => 'local',
3738
}
3839

3940
ldflags = [

0 commit comments

Comments
 (0)