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/dchest/jsmin
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/russross/blackfriday

View file

@ -5,6 +5,7 @@ import (
"strconv"
"time"
log "github.com/Sirupsen/logrus"
"github.com/gin-gonic/gin"
"github.com/drone/drone/model"
@ -22,7 +23,10 @@ func ShowIndex(c *gin.Context) {
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{
"User": user,

View file

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

View file

@ -17,6 +17,7 @@ import (
"github.com/drone/drone/model"
"github.com/drone/drone/remote"
"github.com/drone/drone/shared/docker"
"github.com/drone/drone/shared/envconfig"
"github.com/samalba/dockerclient"
)
@ -54,18 +55,31 @@ type engine struct {
bus *eventbus
updater *updater
pool *pool
envs []string
}
// 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(db *sql.DB, remote remote.Remote) Engine {
func Load(db *sql.DB, env envconfig.Env, remote remote.Remote) Engine {
engine := &engine{}
engine.bus = newEventbus()
engine.pool = newPool()
engine.db = db
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)
if err != nil {
log.Fatalf("failed to get nodes from database. %s", err)
@ -174,7 +188,7 @@ func (e *engine) Schedule(req *Task) {
// run all bulid jobs
for _, job := range req.Jobs {
req.Job = job
runJob(req, e.updater, client)
e.runJob(req, e.updater, client)
}
// update overall status based on each job
@ -192,7 +206,7 @@ func (e *engine) Schedule(req *Task) {
}
// run notifications
err = runJobNotify(req, client)
err = e.runJobNotify(req, client)
if err != nil {
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)
}
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)
@ -281,6 +295,7 @@ func runJob(r *Task, updater *updater, client dockerclient.Client) error {
Image: DefaultAgent,
Entrypoint: DefaultEntrypoint,
Cmd: args,
Env: e.envs,
HostConfig: dockerclient.HostConfig{
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
}
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)
@ -383,6 +398,7 @@ func runJobNotify(r *Task, client dockerclient.Client) error {
Image: DefaultAgent,
Entrypoint: DefaultEntrypoint,
Cmd: args,
Env: e.envs,
HostConfig: dockerclient.HostConfig{
Binds: []string{"/var/run/docker.sock:/var/run/docker.sock"},
},