// Load creates a new build engine, loaded with registered nodes from the // database. The registered nodes are added to the pool of nodes to immediately // start accepting workloads. func Load(env envconfig.Env, s store.Store) Engine { engine := &engine{} engine.bus = newEventbus() engine.pool = newPool() engine.updater = &updater{engine.bus} // quick fix to propogate HTTP_PROXY variables // throughout the build environment. var proxyVars = []string{"HTTP_PROXY", "http_proxy", "HTTPS_PROXY", "https_proxy", "NO_PROXY", "no_proxy"} for _, proxyVar := range proxyVars { proxyVal := env.Get(proxyVar) if len(proxyVal) != 0 { engine.envs = append(engine.envs, proxyVar+"="+proxyVal) } } nodes, err := s.Nodes().GetList() if err != nil { log.Fatalf("failed to get nodes from database. %s", err) } for _, node := range nodes { engine.pool.allocate(node) log.Infof("registered docker daemon %s", node.Addr) } return engine }
func Load(env envconfig.Env) Remote { driver := env.Get("REMOTE_DRIVER") switch driver { case "bitbucket": return bitbucket.Load(env) case "github": return github.Load(env) case "gitlab": return gitlab.Load(env) case "gogs": return gogs.Load(env) default: log.Fatalf("unknown remote driver %s", driver) } return nil }