From 64663e974201642e3de0f867e59b935a1b7bb620 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Sat, 16 May 2015 17:46:29 -0700 Subject: [PATCH] fixed some build issues --- Makefile | 1 + cmd/drone-build/Dockerfile | 20 ++++++-------------- cmd/drone-build/run.go | 4 ++-- common/sshutil/sshutil.go | 10 +++++----- runner/builtin/runner.go | 2 ++ runner/builtin/worker.go | 2 +- server/repos.go | 4 ++-- 7 files changed, 19 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 690b15ba..f66b0f89 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ test: go test -cover -short ./... build: + mkdir -p bin go build -o bin/drone -ldflags "-X main.revision $(SHA) -X main.version $(VERSION).$(SHA)" clean: diff --git a/cmd/drone-build/Dockerfile b/cmd/drone-build/Dockerfile index 3715317f..8adb479d 100644 --- a/cmd/drone-build/Dockerfile +++ b/cmd/drone-build/Dockerfile @@ -1,18 +1,10 @@ -# Docker image for Drone's git-clone plugin +# Docker image for Drone's slack notification plugin # +# CGO_ENABLED=0 go build -a -tags netgo # docker build --rm=true -t drone/drone-build . -FROM library/golang:1.4 +FROM gliderlabs/alpine:3.1 +RUN apk-install ca-certificates +ADD drone-build /bin/ +ENTRYPOINT ["/bin/drone-build"] -# copy the local package files to the container's workspace. -#ADD . /go/src/github.com/drone/drone-build/ - -# build the program inside the container. -#RUN go get github.com/drone/drone-build/... && \ -# go install github.com/drone/drone-build - - -ADD drone-build /go/bin/ - -# run the git-clone plugin when the container starts -ENTRYPOINT ["/go/bin/drone-build"] diff --git a/cmd/drone-build/run.go b/cmd/drone-build/run.go index 93a848c6..5f2c0a1a 100644 --- a/cmd/drone-build/run.go +++ b/cmd/drone-build/run.go @@ -32,12 +32,12 @@ func setup(c *Context) error { // if repository is trusted the build may specify // custom volumes, networking and run in trusted mode. if c.Repo.Trusted { - opts = &parser.Opts{true, true, true} + opts = &parser.Opts{Network: true, Privileged: true, Volumes: true} } // inject the matrix parameters into the yaml injected := inject.Inject(string(c.Yaml), c.Build.Environment) - c.Conf, err = parser.ParseSingle(injected, parser.DefaultOpts) + c.Conf, err = parser.ParseSingle(injected, opts) if err != nil { return err } diff --git a/common/sshutil/sshutil.go b/common/sshutil/sshutil.go index 2d6be01a..a55fd511 100644 --- a/common/sshutil/sshutil.go +++ b/common/sshutil/sshutil.go @@ -21,19 +21,19 @@ func GeneratePrivateKey() (*rsa.PrivateKey, error) { // helper function that marshalls an RSA Public Key to an SSH // .authorized_keys format -func MarshalPublicKey(pubkey *rsa.PublicKey) string { +func MarshalPublicKey(pubkey *rsa.PublicKey) []byte { pk, err := ssh.NewPublicKey(pubkey) if err != nil { - return "" + return []byte{} } - return string(ssh.MarshalAuthorizedKey(pk)) + return ssh.MarshalAuthorizedKey(pk) } // helper function that marshalls an RSA Private Key to // a PEM encoded file. -func MarshalPrivateKey(privkey *rsa.PrivateKey) string { +func MarshalPrivateKey(privkey *rsa.PrivateKey) []byte { privateKeyMarshaled := x509.MarshalPKCS1PrivateKey(privkey) privateKeyPEM := pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Headers: nil, Bytes: privateKeyMarshaled}) - return string(privateKeyPEM) + return privateKeyPEM } diff --git a/runner/builtin/runner.go b/runner/builtin/runner.go index 70cc3fb8..cc1196e2 100644 --- a/runner/builtin/runner.go +++ b/runner/builtin/runner.go @@ -60,12 +60,14 @@ func (r *Runner) Run(w *queue.Work) error { b.State = common.StateError b.Finished = time.Now().UTC().Unix() b.Duration = b.Finished - b.Started + b.ExitCode = 255 } if b.State == common.StatePending { b.State = common.StateError b.Started = time.Now().UTC().Unix() b.Finished = time.Now().UTC().Unix() b.Duration = 0 + b.ExitCode = 255 } r.SetBuild(w.Repo, w.Commit, b) } diff --git a/runner/builtin/worker.go b/runner/builtin/worker.go index af82d077..9a368811 100644 --- a/runner/builtin/worker.go +++ b/runner/builtin/worker.go @@ -36,7 +36,7 @@ var ( DefaultAgent = "drone/drone-build:latest" // default name of the build agent executable - DefaultEntrypoint = []string{"/go/bin/drone-build"} + DefaultEntrypoint = []string{"/bin/drone-build"} // default argument to invoke build steps DefaultBuildArgs = []string{"--build", "--clone", "--publish", "--deploy"} diff --git a/server/repos.go b/server/repos.go index 660ba33f..5e139410 100644 --- a/server/repos.go +++ b/server/repos.go @@ -223,8 +223,8 @@ func PostRepo(c *gin.Context) { c.Fail(400, err) return } - r.PublicKey = sshutil.MarshalPublicKey(&key.PublicKey) - r.PrivateKey = sshutil.MarshalPrivateKey(key) + r.PublicKey = string(sshutil.MarshalPublicKey(&key.PublicKey)) + r.PrivateKey = string(sshutil.MarshalPrivateKey(key)) keypair := &common.Keypair{ Public: r.PublicKey, Private: r.PrivateKey,