mirror of
https://github.com/harness/drone.git
synced 2025-05-22 03:49:54 +08:00
fix drone agent issue
This commit is contained in:
parent
4040dfceb8
commit
1d508fb792
@ -245,7 +245,7 @@ func (c *client) open(rawurl, method string, in, out interface{}) (io.ReadCloser
|
|||||||
if resp.StatusCode > http.StatusPartialContent {
|
if resp.StatusCode > http.StatusPartialContent {
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
out, _ := ioutil.ReadAll(resp.Body)
|
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
|
return resp.Body, nil
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,12 @@ var AgentCmd = cli.Command{
|
|||||||
Usage: "docker architecture system",
|
Usage: "docker architecture system",
|
||||||
Value: "amd64",
|
Value: "amd64",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
EnvVar: "DOCKER_STORAGE_DRIVER",
|
||||||
|
Name: "docker-storage-driver",
|
||||||
|
Usage: "docker storage driver",
|
||||||
|
Value: "overlay",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
EnvVar: "DRONE_SERVER",
|
EnvVar: "DRONE_SERVER",
|
||||||
Name: "drone-server",
|
Name: "drone-server",
|
||||||
|
@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/drone/drone/engine/runner/docker"
|
"github.com/drone/drone/engine/runner/docker"
|
||||||
"github.com/drone/drone/model"
|
"github.com/drone/drone/model"
|
||||||
"github.com/drone/drone/queue"
|
"github.com/drone/drone/queue"
|
||||||
|
"github.com/drone/drone/version"
|
||||||
"github.com/drone/drone/yaml/expander"
|
"github.com/drone/drone/yaml/expander"
|
||||||
|
|
||||||
"github.com/samalba/dockerclient"
|
"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_YAML_SIGNED": fmt.Sprintf("%v", w.Signed),
|
||||||
"DRONE_BRANCH": w.Build.Branch,
|
"DRONE_BRANCH": w.Build.Branch,
|
||||||
"DRONE_COMMIT": w.Build.Commit,
|
"DRONE_COMMIT": w.Build.Commit,
|
||||||
|
"DRONE_VERSION": version.Version,
|
||||||
}
|
}
|
||||||
|
|
||||||
if w.Build.Event == model.EventTag {
|
if w.Build.Event == model.EventTag {
|
||||||
|
@ -18,7 +18,7 @@ func Agents(cli *cli.Context) gin.HandlerFunc {
|
|||||||
logrus.Fatalf("failed to generate token from DRONE_AGENT_SECRET")
|
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)
|
s, err := t.Sign(secret)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatalf("failed to generate token from DRONE_AGENT_SECRET. %s", err)
|
logrus.Fatalf("failed to generate token from DRONE_AGENT_SECRET. %s", err)
|
||||||
|
@ -18,8 +18,10 @@ func AuthorizeAgent(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.String(500, "invalid or empty token. %s", err)
|
c.String(500, "invalid or empty token. %s", err)
|
||||||
|
c.Abort()
|
||||||
} else if parsed.Kind != token.AgentToken {
|
} else if parsed.Kind != token.AgentToken {
|
||||||
c.String(403, "invalid token. please use an agent token")
|
c.String(403, "invalid token. please use an agent token")
|
||||||
|
c.Abort()
|
||||||
} else {
|
} else {
|
||||||
c.Next()
|
c.Next()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user