зеркало из https://github.com/golang/build.git
dashboard: set the correct module proxy for EC2 builders
This change sets the default module proxy address for EC2 builders. EC2 builders should have the same proxy address set as reverse builders. Fixes golang/go#40914 Change-Id: I4de2ed178170f60fdbe4e2f9aa6f024bb43ee020 Reviewed-on: https://go-review.googlesource.com/c/build/+/249577 Run-TryBot: Carlos Amedee <carlos@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alexander Rakoczy <alex@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
Родитель
6464c3e642
Коммит
1e76199ae8
|
@ -860,7 +860,9 @@ func (c *BuildConfig) Env() []string {
|
|||
// to append to this builder as a function of the repo being built
|
||||
// ("go", "oauth2", "net", etc).
|
||||
func (c *BuildConfig) ModulesEnv(repo string) (env []string) {
|
||||
if c.IsReverse() && repo != "go" {
|
||||
// EC2 and reverse builders should set the public module proxy
|
||||
// address instead of the internal proxy.
|
||||
if (c.HostConfig().isEC2 || c.IsReverse()) && repo != "go" {
|
||||
env = append(env, "GOPROXY=https://proxy.golang.org")
|
||||
}
|
||||
switch repo {
|
||||
|
|
|
@ -15,6 +15,8 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
)
|
||||
|
||||
func TestOSARCHAccessors(t *testing.T) {
|
||||
|
@ -925,3 +927,110 @@ func TestHostConfigIsVM(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestModulesEnv(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
buildConfig *BuildConfig
|
||||
repo string
|
||||
want []string
|
||||
}{
|
||||
{
|
||||
desc: "ec2-builder-repo-non-go",
|
||||
buildConfig: &BuildConfig{
|
||||
testHostConf: &HostConfig{
|
||||
IsReverse: false,
|
||||
isEC2: true,
|
||||
},
|
||||
},
|
||||
repo: "bar",
|
||||
want: []string{"GOPROXY=https://proxy.golang.org"},
|
||||
},
|
||||
{
|
||||
desc: "reverse-builder-repo-non-go",
|
||||
buildConfig: &BuildConfig{
|
||||
testHostConf: &HostConfig{
|
||||
IsReverse: true,
|
||||
isEC2: false,
|
||||
},
|
||||
},
|
||||
repo: "bar",
|
||||
want: []string{"GOPROXY=https://proxy.golang.org"},
|
||||
},
|
||||
{
|
||||
desc: "reverse-builder-repo-go",
|
||||
buildConfig: &BuildConfig{
|
||||
testHostConf: &HostConfig{
|
||||
IsReverse: true,
|
||||
isEC2: false,
|
||||
},
|
||||
},
|
||||
repo: "go",
|
||||
want: []string{"GOPROXY=off"},
|
||||
},
|
||||
{
|
||||
desc: "builder-repo-go",
|
||||
buildConfig: &BuildConfig{
|
||||
testHostConf: &HostConfig{
|
||||
IsReverse: false,
|
||||
isEC2: false,
|
||||
},
|
||||
},
|
||||
repo: "go",
|
||||
want: []string{"GOPROXY=off"},
|
||||
},
|
||||
{
|
||||
desc: "builder-repo-go-outbound-network-allowed",
|
||||
buildConfig: &BuildConfig{
|
||||
Name: "test-longtest",
|
||||
testHostConf: &HostConfig{
|
||||
IsReverse: false,
|
||||
isEC2: false,
|
||||
},
|
||||
},
|
||||
repo: "go",
|
||||
want: nil,
|
||||
},
|
||||
{
|
||||
desc: "builder-repo-special-case",
|
||||
buildConfig: &BuildConfig{
|
||||
testHostConf: &HostConfig{
|
||||
IsReverse: false,
|
||||
isEC2: false,
|
||||
},
|
||||
},
|
||||
repo: "build",
|
||||
want: []string{"GO111MODULE=on"},
|
||||
},
|
||||
{
|
||||
desc: "reverse-builder-repo-special-case",
|
||||
buildConfig: &BuildConfig{
|
||||
testHostConf: &HostConfig{
|
||||
IsReverse: true,
|
||||
isEC2: false,
|
||||
},
|
||||
},
|
||||
repo: "build",
|
||||
want: []string{"GOPROXY=https://proxy.golang.org", "GO111MODULE=on"},
|
||||
},
|
||||
{
|
||||
desc: "builder-repo-non-special-case",
|
||||
buildConfig: &BuildConfig{
|
||||
testHostConf: &HostConfig{
|
||||
IsReverse: false,
|
||||
isEC2: false,
|
||||
},
|
||||
},
|
||||
repo: "bar",
|
||||
want: nil,
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
got := tc.buildConfig.ModulesEnv(tc.repo)
|
||||
if diff := cmp.Diff(tc.want, got); diff != "" {
|
||||
t.Errorf("BuildConfig.ModulesEnv(%q) mismatch (-want, +got)\n%s", tc.repo, diff)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче