Skip to content

Commit

Permalink
fixed some build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bradrydzewski committed May 17, 2015
1 parent 07b9106 commit 64663e9
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 24 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 6 additions & 14 deletions cmd/drone-build/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
4 changes: 2 additions & 2 deletions cmd/drone-build/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 5 additions & 5 deletions common/sshutil/sshutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions runner/builtin/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion runner/builtin/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down
4 changes: 2 additions & 2 deletions server/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 64663e9

Please sign in to comment.