propogate HTTP_PROXY environment variables throuhgout build

This commit is contained in:
Brad Rydzewski 2015-10-06 15:50:15 -07:00
parent acb27f4f1e
commit 0943117ad7
4 changed files with 28 additions and 8 deletions

View file

@ -14,7 +14,7 @@ deps:
go get -u github.com/elazarl/go-bindata-assetfs/... go get -u github.com/elazarl/go-bindata-assetfs/...
go get -u github.com/dchest/jsmin go get -u github.com/dchest/jsmin
go get -u github.com/franela/goblin go get -u github.com/franela/goblin
go get -u github.com/go-swagger/go-swagger go get -u github.com/go-swagger/go-swagger/...
go get -u github.com/PuerkitoBio/goquery go get -u github.com/PuerkitoBio/goquery
go get -u github.com/russross/blackfriday go get -u github.com/russross/blackfriday

View file

@ -5,6 +5,7 @@ import (
"strconv" "strconv"
"time" "time"
log "github.com/Sirupsen/logrus"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/drone/drone/model" "github.com/drone/drone/model"
@ -22,7 +23,10 @@ func ShowIndex(c *gin.Context) {
return return
} }
repos, _ := model.GetRepoList(db, user) repos, err := model.GetRepoList(db, user)
if err != nil {
log.Errorf(err)
}
c.HTML(200, "repos.html", gin.H{ c.HTML(200, "repos.html", gin.H{
"User": user, "User": user,

View file

@ -37,7 +37,7 @@ func main() {
remote_ := remote.Load(env) remote_ := remote.Load(env)
// setup the runner // setup the runner
engine_ := engine.Load(database_, remote_) engine_ := engine.Load(database_, env, remote_)
// setup the server and start the listener // setup the server and start the listener
server_ := server.Load(env) server_ := server.Load(env)

View file

@ -17,6 +17,7 @@ import (
"github.com/drone/drone/model" "github.com/drone/drone/model"
"github.com/drone/drone/remote" "github.com/drone/drone/remote"
"github.com/drone/drone/shared/docker" "github.com/drone/drone/shared/docker"
"github.com/drone/drone/shared/envconfig"
"github.com/samalba/dockerclient" "github.com/samalba/dockerclient"
) )
@ -54,18 +55,31 @@ type engine struct {
bus *eventbus bus *eventbus
updater *updater updater *updater
pool *pool pool *pool
envs []string
} }
// Load creates a new build engine, loaded with registered nodes from the // 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 // database. The registered nodes are added to the pool of nodes to immediately
// start accepting workloads. // start accepting workloads.
func Load(db *sql.DB, remote remote.Remote) Engine { func Load(db *sql.DB, env envconfig.Env, remote remote.Remote) Engine {
engine := &engine{} engine := &engine{}
engine.bus = newEventbus() engine.bus = newEventbus()
engine.pool = newPool() engine.pool = newPool()
engine.db = db engine.db = db
engine.updater = &updater{engine.bus, db, remote} engine.updater = &updater{engine.bus, db, remote}
// quick fix to propogate HTTP_PROXY variables
// throughout the build environment.
if env := env.Get("HTTP_PROXY"); len(env) != 0 {
engine.envs = append(engine.envs, "HTTP_PROXY="+env)
}
if env := env.Get("HTTPS_PROXY"); len(env) != 0 {
engine.envs = append(engine.envs, "HTTPS_PROXY="+env)
}
if env := env.Get("NO_PROXY"); len(env) != 0 {
engine.envs = append(engine.envs, "NO_PROXY="+env)
}
nodes, err := model.GetNodeList(db) nodes, err := model.GetNodeList(db)
if err != nil { if err != nil {
log.Fatalf("failed to get nodes from database. %s", err) log.Fatalf("failed to get nodes from database. %s", err)
@ -174,7 +188,7 @@ func (e *engine) Schedule(req *Task) {
// run all bulid jobs // run all bulid jobs
for _, job := range req.Jobs { for _, job := range req.Jobs {
req.Job = job req.Job = job
runJob(req, e.updater, client) e.runJob(req, e.updater, client)
} }
// update overall status based on each job // update overall status based on each job
@ -192,7 +206,7 @@ func (e *engine) Schedule(req *Task) {
} }
// run notifications // run notifications
err = runJobNotify(req, client) err = e.runJobNotify(req, client)
if err != nil { if err != nil {
log.Errorf("error executing notification step. %s", err) log.Errorf("error executing notification step. %s", err)
} }
@ -235,7 +249,7 @@ func newDockerClient(addr, cert, key, ca string) (dockerclient.Client, error) {
return dockerclient.NewDockerClient(addr, tlc) return dockerclient.NewDockerClient(addr, tlc)
} }
func runJob(r *Task, updater *updater, client dockerclient.Client) error { func (e *engine) runJob(r *Task, updater *updater, client dockerclient.Client) error {
name := fmt.Sprintf("drone_build_%d_job_%d", r.Build.ID, r.Job.ID) name := fmt.Sprintf("drone_build_%d_job_%d", r.Build.ID, r.Job.ID)
@ -281,6 +295,7 @@ func runJob(r *Task, updater *updater, client dockerclient.Client) error {
Image: DefaultAgent, Image: DefaultAgent,
Entrypoint: DefaultEntrypoint, Entrypoint: DefaultEntrypoint,
Cmd: args, Cmd: args,
Env: e.envs,
HostConfig: dockerclient.HostConfig{ HostConfig: dockerclient.HostConfig{
Binds: []string{"/var/run/docker.sock:/var/run/docker.sock"}, Binds: []string{"/var/run/docker.sock:/var/run/docker.sock"},
}, },
@ -358,7 +373,7 @@ func runJob(r *Task, updater *updater, client dockerclient.Client) error {
return nil return nil
} }
func runJobNotify(r *Task, client dockerclient.Client) error { func (e *engine) runJobNotify(r *Task, client dockerclient.Client) error {
name := fmt.Sprintf("drone_build_%d_notify", r.Build.ID) name := fmt.Sprintf("drone_build_%d_notify", r.Build.ID)
@ -383,6 +398,7 @@ func runJobNotify(r *Task, client dockerclient.Client) error {
Image: DefaultAgent, Image: DefaultAgent,
Entrypoint: DefaultEntrypoint, Entrypoint: DefaultEntrypoint,
Cmd: args, Cmd: args,
Env: e.envs,
HostConfig: dockerclient.HostConfig{ HostConfig: dockerclient.HostConfig{
Binds: []string{"/var/run/docker.sock:/var/run/docker.sock"}, Binds: []string{"/var/run/docker.sock:/var/run/docker.sock"},
}, },