Skip to content

Commit

Permalink
refactoring input and configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
bradrydzewski committed Apr 29, 2016
1 parent 4d4003a commit 082570f
Show file tree
Hide file tree
Showing 34 changed files with 1,732 additions and 1,293 deletions.
43 changes: 0 additions & 43 deletions api/repo.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package api

import (
"bytes"
"fmt"
"io/ioutil"
"net/http"

"github.com/gin-gonic/gin"
"gopkg.in/yaml.v2"

"github.com/drone/drone/cache"
"github.com/drone/drone/model"
Expand Down Expand Up @@ -210,44 +208,3 @@ func DeleteRepo(c *gin.Context) {
remote.Deactivate(user, repo, httputil.GetURL(c.Request))
c.Writer.WriteHeader(http.StatusOK)
}

func PostSecure(c *gin.Context) {
repo := session.Repo(c)

in, err := ioutil.ReadAll(c.Request.Body)
if err != nil {
c.AbortWithError(http.StatusBadRequest, err)
return
}

// we found some strange characters included in
// the yaml file when entered into a browser textarea.
// these need to be removed
in = bytes.Replace(in, []byte{'\xA0'}, []byte{' '}, -1)

// make sure the Yaml is valid format to prevent
// a malformed value from being used in the build
err = yaml.Unmarshal(in, &yaml.MapSlice{})
if err != nil {
c.String(http.StatusBadRequest, err.Error())
return
}

key, err := store.GetKey(c, repo)
if err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
return
}

// encrypts using go-jose
out, err := crypto.Encrypt(string(in), key.Private)
if err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
return
}
c.String(http.StatusOK, out)
}

func PostReactivate(c *gin.Context) {

}
6 changes: 3 additions & 3 deletions drone/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ func start(c *cli.Context) {
c.String("drone-token"),
)

tls, _ := dockerclient.TLSConfigFromCertPath(c.String("docker-cert-path"))
if c.Bool("docker-host") {
tls.InsecureSkipVerify = true
tls, err := dockerclient.TLSConfigFromCertPath(c.String("docker-cert-path"))
if err == nil {
tls.InsecureSkipVerify = c.Bool("docker-tls-verify")
}
docker, err := dockerclient.NewDockerClient(c.String("docker-host"), tls)
if err != nil {
Expand Down
Loading

0 comments on commit 082570f

Please sign in to comment.