fix drone agent issue

This commit is contained in:
Brad Rydzewski 2016-05-03 23:36:23 -07:00
parent 4040dfceb8
commit 1d508fb792
5 changed files with 12 additions and 2 deletions

View file

@ -245,7 +245,7 @@ func (c *client) open(rawurl, method string, in, out interface{}) (io.ReadCloser
if resp.StatusCode > http.StatusPartialContent {
defer resp.Body.Close()
out, _ := ioutil.ReadAll(resp.Body)
return nil, fmt.Errorf(string(out))
return nil, fmt.Errorf("client error %d: %s", resp.StatusCode, string(out))
}
return resp.Body, nil
}

View file

@ -52,6 +52,12 @@ var AgentCmd = cli.Command{
Usage: "docker architecture system",
Value: "amd64",
},
cli.StringFlag{
EnvVar: "DOCKER_STORAGE_DRIVER",
Name: "docker-storage-driver",
Usage: "docker storage driver",
Value: "overlay",
},
cli.StringFlag{
EnvVar: "DRONE_SERVER",
Name: "drone-server",

View file

@ -17,6 +17,7 @@ import (
"github.com/drone/drone/engine/runner/docker"
"github.com/drone/drone/model"
"github.com/drone/drone/queue"
"github.com/drone/drone/version"
"github.com/drone/drone/yaml/expander"
"github.com/samalba/dockerclient"
@ -255,6 +256,7 @@ func toEnv(w *queue.Work) map[string]string {
"DRONE_YAML_SIGNED": fmt.Sprintf("%v", w.Signed),
"DRONE_BRANCH": w.Build.Branch,
"DRONE_COMMIT": w.Build.Commit,
"DRONE_VERSION": version.Version,
}
if w.Build.Event == model.EventTag {

View file

@ -18,7 +18,7 @@ func Agents(cli *cli.Context) gin.HandlerFunc {
logrus.Fatalf("failed to generate token from DRONE_AGENT_SECRET")
}
t := token.New(secret, "")
t := token.New(token.AgentToken, secret)
s, err := t.Sign(secret)
if err != nil {
logrus.Fatalf("failed to generate token from DRONE_AGENT_SECRET. %s", err)

View file

@ -18,8 +18,10 @@ func AuthorizeAgent(c *gin.Context) {
})
if err != nil {
c.String(500, "invalid or empty token. %s", err)
c.Abort()
} else if parsed.Kind != token.AgentToken {
c.String(403, "invalid token. please use an agent token")
c.Abort()
} else {
c.Next()
}