зеркало из https://github.com/golang/build.git
all: change dashboard.BuildConfig to be a pointer type, like HostConfig
BuildConfig grew way too large and has too many slices & such to be a value type. Make it a pointer type, which matches HostConfig. Change-Id: Ie625bece9d6d8c1ec6cff26e77416bd9b1f256d8 Reviewed-on: https://go-review.googlesource.com/c/145077 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
Родитель
c8126a05c0
Коммит
5eb896e234
|
@ -15,7 +15,7 @@ import (
|
|||
func handleBuilders(w http.ResponseWriter, r *http.Request) {
|
||||
var buf bytes.Buffer
|
||||
if err := buildersTmpl.Execute(&buf, struct {
|
||||
Builders map[string]dashboard.BuildConfig
|
||||
Builders map[string]*dashboard.BuildConfig
|
||||
Hosts map[string]*dashboard.HostConfig
|
||||
}{dashboard.Builders, dashboard.Hosts}); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
|
|
@ -124,8 +124,8 @@ var (
|
|||
)
|
||||
|
||||
var (
|
||||
tryBuilders []dashboard.BuildConfig // for testing the go repo
|
||||
subTryBuilders []dashboard.BuildConfig // for testing sub-repos
|
||||
tryBuilders []*dashboard.BuildConfig // for testing the go repo
|
||||
subTryBuilders []*dashboard.BuildConfig // for testing sub-repos
|
||||
)
|
||||
|
||||
var maintnerClient apipb.MaintnerServiceClient
|
||||
|
@ -391,8 +391,8 @@ func handleDebugWatcher(w http.ResponseWriter, r *http.Request) {
|
|||
watcherProxy.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
func stagingClusterBuilders() map[string]dashboard.BuildConfig {
|
||||
m := map[string]dashboard.BuildConfig{}
|
||||
func stagingClusterBuilders() map[string]*dashboard.BuildConfig {
|
||||
m := map[string]*dashboard.BuildConfig{}
|
||||
for _, name := range []string{
|
||||
"linux-amd64",
|
||||
"linux-amd64-sid",
|
||||
|
@ -1470,9 +1470,9 @@ func GetBuildlets(ctx context.Context, pool BuildletPool, n int, hostType string
|
|||
return ch
|
||||
}
|
||||
|
||||
var testPoolHook func(dashboard.BuildConfig) BuildletPool
|
||||
var testPoolHook func(*dashboard.BuildConfig) BuildletPool
|
||||
|
||||
func poolForConf(conf dashboard.BuildConfig) BuildletPool {
|
||||
func poolForConf(conf *dashboard.BuildConfig) BuildletPool {
|
||||
if testPoolHook != nil {
|
||||
return testPoolHook(conf)
|
||||
}
|
||||
|
@ -3285,7 +3285,7 @@ type buildStatus struct {
|
|||
buildgo.BuilderRev
|
||||
buildID string // "B" + 9 random hex
|
||||
goBranch string // non-empty for subrepo trybots if not go master branch
|
||||
conf dashboard.BuildConfig
|
||||
conf *dashboard.BuildConfig
|
||||
startTime time.Time // actually time of newBuild (~same thing); TODO(bradfitz): rename this createTime
|
||||
trySet *trySet // or nil
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ func TestHandleBuildletCreateOldVersion(t *testing.T) {
|
|||
}
|
||||
|
||||
func addBuilder(name string) {
|
||||
dashboard.Builders[name] = dashboard.BuildConfig{
|
||||
dashboard.Builders[name] = &dashboard.BuildConfig{
|
||||
Name: name,
|
||||
HostType: "test-host",
|
||||
Notes: "Dummy client for testing",
|
||||
|
@ -119,7 +119,7 @@ func TestHandleBuildletCreate(t *testing.T) {
|
|||
log.SetOutput(tlogger{t})
|
||||
defer log.SetOutput(os.Stderr)
|
||||
addBuilder(buildName)
|
||||
testPoolHook = func(_ dashboard.BuildConfig) BuildletPool { return testPool }
|
||||
testPoolHook = func(_ *dashboard.BuildConfig) BuildletPool { return testPool }
|
||||
defer func() {
|
||||
removeBuilder(buildName)
|
||||
testPoolHook = nil
|
||||
|
|
|
@ -44,7 +44,7 @@ func main() {
|
|||
buildenv.RegisterFlags()
|
||||
flag.Parse()
|
||||
|
||||
var bconf dashboard.BuildConfig
|
||||
var bconf *dashboard.BuildConfig
|
||||
if *runBuild != "" {
|
||||
var ok bool
|
||||
bconf, ok = dashboard.Builders[*runBuild]
|
||||
|
|
|
@ -50,7 +50,7 @@ func list(args []string) error {
|
|||
// As a special case, if name contains '@', the name is expected to be
|
||||
// of the form <build-config-name>@ip[:port]. For example,
|
||||
// "windows-amd64-race@10.0.0.1".
|
||||
func clientAndConf(name string) (bc *buildlet.Client, conf dashboard.BuildConfig, err error) {
|
||||
func clientAndConf(name string) (bc *buildlet.Client, conf *dashboard.BuildConfig, err error) {
|
||||
var ok bool
|
||||
|
||||
if strings.Contains(name, "@") {
|
||||
|
|
|
@ -42,7 +42,7 @@ func run(args []string) error {
|
|||
}
|
||||
name, cmd := fs.Arg(0), fs.Arg(1)
|
||||
|
||||
var conf dashboard.BuildConfig
|
||||
var conf *dashboard.BuildConfig
|
||||
|
||||
bc, conf, err := clientAndConf(name)
|
||||
if err != nil {
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
// The keys are like "darwin-amd64" or "linux-386-387".
|
||||
// This map should not be modified by other packages.
|
||||
// Initialization happens below, via calls to addBuilder.
|
||||
var Builders = map[string]BuildConfig{}
|
||||
var Builders = map[string]*BuildConfig{}
|
||||
|
||||
// Hosts contains the names and configs of all the types of
|
||||
// buildlets. They can be VMs, containers, or dedicated machines.
|
||||
|
@ -1695,7 +1695,7 @@ func addBuilder(c BuildConfig) {
|
|||
panic(fmt.Sprintf("build config %q host type inconsistent (must be Reverse, Image, or VM)", c.Name))
|
||||
}
|
||||
|
||||
Builders[c.Name] = c
|
||||
Builders[c.Name] = &c
|
||||
}
|
||||
|
||||
// TrybotBuilderNames returns the names of the builder configs
|
||||
|
|
|
@ -41,7 +41,7 @@ func (b *BenchmarkItem) Name() string {
|
|||
}
|
||||
|
||||
// buildGo1 builds the Go 1 benchmarks.
|
||||
func buildGo1(conf dashboard.BuildConfig, bc *buildlet.Client, goroot string, w io.Writer) (remoteErr, err error) {
|
||||
func buildGo1(conf *dashboard.BuildConfig, bc *buildlet.Client, goroot string, w io.Writer) (remoteErr, err error) {
|
||||
workDir, err := bc.WorkDir()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -67,7 +67,7 @@ func buildGo1(conf dashboard.BuildConfig, bc *buildlet.Client, goroot string, w
|
|||
}
|
||||
|
||||
// buildPkg builds a package's benchmarks.
|
||||
func buildPkg(conf dashboard.BuildConfig, bc *buildlet.Client, goroot string, w io.Writer, pkg, name string) (remoteErr, err error) {
|
||||
func buildPkg(conf *dashboard.BuildConfig, bc *buildlet.Client, goroot string, w io.Writer, pkg, name string) (remoteErr, err error) {
|
||||
workDir, err := bc.WorkDir()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -80,7 +80,7 @@ func buildPkg(conf dashboard.BuildConfig, bc *buildlet.Client, goroot string, w
|
|||
}
|
||||
|
||||
// buildXBenchmark builds a benchmark from x/benchmarks.
|
||||
func buildXBenchmark(sl spanlog.Logger, conf dashboard.BuildConfig, bc *buildlet.Client, goroot string, w io.Writer, rev, pkg, name string) (remoteErr, err error) {
|
||||
func buildXBenchmark(sl spanlog.Logger, conf *dashboard.BuildConfig, bc *buildlet.Client, goroot string, w io.Writer, rev, pkg, name string) (remoteErr, err error) {
|
||||
workDir, err := bc.WorkDir()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -198,7 +198,7 @@ func (gb GoBuilder) EnumerateBenchmarks(bc *buildlet.Client, benchmarksRev strin
|
|||
// runOneBenchBinary runs a binary on the buildlet and writes its output to w with a trailing newline.
|
||||
//
|
||||
// TODO: this signature is too big. Make it a method of something?
|
||||
func runOneBenchBinary(conf dashboard.BuildConfig, bc *buildlet.Client, w io.Writer, goroot, dir, binaryPath string, args []string) (remoteErr, err error) {
|
||||
func runOneBenchBinary(conf *dashboard.BuildConfig, bc *buildlet.Client, w io.Writer, goroot, dir, binaryPath string, args []string) (remoteErr, err error) {
|
||||
defer w.Write([]byte{'\n'})
|
||||
workDir, err := bc.WorkDir()
|
||||
if err != nil {
|
||||
|
@ -226,7 +226,7 @@ func runOneBenchBinary(conf dashboard.BuildConfig, bc *buildlet.Client, w io.Wri
|
|||
})
|
||||
}
|
||||
|
||||
func buildRev(buildEnv *buildenv.Environment, sl spanlog.Logger, conf dashboard.BuildConfig, bc *buildlet.Client, w io.Writer, goroot string, br BuilderRev) error {
|
||||
func buildRev(buildEnv *buildenv.Environment, sl spanlog.Logger, conf *dashboard.BuildConfig, bc *buildlet.Client, w io.Writer, goroot string, br BuilderRev) error {
|
||||
if br.SnapshotExists(context.TODO(), buildEnv) {
|
||||
return bc.PutTarFromURL(br.SnapshotURL(buildEnv), goroot)
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ func buildRev(buildEnv *buildenv.Environment, sl spanlog.Logger, conf dashboard.
|
|||
// Build output is sent to w. Benchmark output is stored in b.output.
|
||||
// revs must contain exactly two revs. The first rev is assumed to be present in "go", and the second will be placed into "go-parent".
|
||||
// TODO(quentin): Support len(revs) != 2.
|
||||
func (b *BenchmarkItem) Run(buildEnv *buildenv.Environment, sl spanlog.Logger, conf dashboard.BuildConfig, bc *buildlet.Client, w io.Writer, revs []BuilderRev) (remoteErr, err error) {
|
||||
func (b *BenchmarkItem) Run(buildEnv *buildenv.Environment, sl spanlog.Logger, conf *dashboard.BuildConfig, bc *buildlet.Client, w io.Writer, revs []BuilderRev) (remoteErr, err error) {
|
||||
// Ensure we have a built parent repo.
|
||||
if err := bc.ListDir("go-parent", buildlet.ListDirOpts{}, func(buildlet.DirEntry) {}); err != nil {
|
||||
pbr := revs[1]
|
||||
|
|
|
@ -89,7 +89,7 @@ func (br *BuilderRev) SnapshotExists(ctx context.Context, buildEnv *buildenv.Env
|
|||
type GoBuilder struct {
|
||||
spanlog.Logger
|
||||
BuilderRev
|
||||
Conf dashboard.BuildConfig
|
||||
Conf *dashboard.BuildConfig
|
||||
// Goroot is a Unix-style path relative to the work directory of the builder (e.g. "go").
|
||||
Goroot string
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче