fixed some build issues

This commit is contained in:
Brad Rydzewski 2015-05-16 17:46:29 -07:00
parent 07b910644b
commit 64663e9742
7 changed files with 19 additions and 24 deletions

View file

@ -13,6 +13,7 @@ test:
go test -cover -short ./... go test -cover -short ./...
build: build:
mkdir -p bin
go build -o bin/drone -ldflags "-X main.revision $(SHA) -X main.version $(VERSION).$(SHA)" go build -o bin/drone -ldflags "-X main.revision $(SHA) -X main.version $(VERSION).$(SHA)"
clean: clean:

View file

@ -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 . # 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"]

View file

@ -32,12 +32,12 @@ func setup(c *Context) error {
// if repository is trusted the build may specify // if repository is trusted the build may specify
// custom volumes, networking and run in trusted mode. // custom volumes, networking and run in trusted mode.
if c.Repo.Trusted { 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 // inject the matrix parameters into the yaml
injected := inject.Inject(string(c.Yaml), c.Build.Environment) 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 { if err != nil {
return err return err
} }

View file

@ -21,19 +21,19 @@ func GeneratePrivateKey() (*rsa.PrivateKey, error) {
// helper function that marshalls an RSA Public Key to an SSH // helper function that marshalls an RSA Public Key to an SSH
// .authorized_keys format // .authorized_keys format
func MarshalPublicKey(pubkey *rsa.PublicKey) string { func MarshalPublicKey(pubkey *rsa.PublicKey) []byte {
pk, err := ssh.NewPublicKey(pubkey) pk, err := ssh.NewPublicKey(pubkey)
if err != nil { if err != nil {
return "" return []byte{}
} }
return string(ssh.MarshalAuthorizedKey(pk)) return ssh.MarshalAuthorizedKey(pk)
} }
// helper function that marshalls an RSA Private Key to // helper function that marshalls an RSA Private Key to
// a PEM encoded file. // a PEM encoded file.
func MarshalPrivateKey(privkey *rsa.PrivateKey) string { func MarshalPrivateKey(privkey *rsa.PrivateKey) []byte {
privateKeyMarshaled := x509.MarshalPKCS1PrivateKey(privkey) privateKeyMarshaled := x509.MarshalPKCS1PrivateKey(privkey)
privateKeyPEM := pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Headers: nil, Bytes: privateKeyMarshaled}) privateKeyPEM := pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Headers: nil, Bytes: privateKeyMarshaled})
return string(privateKeyPEM) return privateKeyPEM
} }

View file

@ -60,12 +60,14 @@ func (r *Runner) Run(w *queue.Work) error {
b.State = common.StateError b.State = common.StateError
b.Finished = time.Now().UTC().Unix() b.Finished = time.Now().UTC().Unix()
b.Duration = b.Finished - b.Started b.Duration = b.Finished - b.Started
b.ExitCode = 255
} }
if b.State == common.StatePending { if b.State == common.StatePending {
b.State = common.StateError b.State = common.StateError
b.Started = time.Now().UTC().Unix() b.Started = time.Now().UTC().Unix()
b.Finished = time.Now().UTC().Unix() b.Finished = time.Now().UTC().Unix()
b.Duration = 0 b.Duration = 0
b.ExitCode = 255
} }
r.SetBuild(w.Repo, w.Commit, b) r.SetBuild(w.Repo, w.Commit, b)
} }

View file

@ -36,7 +36,7 @@ var (
DefaultAgent = "drone/drone-build:latest" DefaultAgent = "drone/drone-build:latest"
// default name of the build agent executable // default name of the build agent executable
DefaultEntrypoint = []string{"/go/bin/drone-build"} DefaultEntrypoint = []string{"/bin/drone-build"}
// default argument to invoke build steps // default argument to invoke build steps
DefaultBuildArgs = []string{"--build", "--clone", "--publish", "--deploy"} DefaultBuildArgs = []string{"--build", "--clone", "--publish", "--deploy"}

View file

@ -223,8 +223,8 @@ func PostRepo(c *gin.Context) {
c.Fail(400, err) c.Fail(400, err)
return return
} }
r.PublicKey = sshutil.MarshalPublicKey(&key.PublicKey) r.PublicKey = string(sshutil.MarshalPublicKey(&key.PublicKey))
r.PrivateKey = sshutil.MarshalPrivateKey(key) r.PrivateKey = string(sshutil.MarshalPrivateKey(key))
keypair := &common.Keypair{ keypair := &common.Keypair{
Public: r.PublicKey, Public: r.PublicKey,
Private: r.PrivateKey, Private: r.PrivateKey,