harness-drone/pkg/server/agent.go

21 lines
380 B
Go
Raw Normal View History

2015-04-30 21:41:52 +00:00
package server
import (
2015-05-17 20:51:42 +00:00
"github.com/drone/drone/pkg/types"
2015-04-30 21:41:52 +00:00
"github.com/gin-gonic/gin"
)
// GET /api/agents/token
func GetAgentToken(c *gin.Context) {
sess := ToSession(c)
2015-05-17 20:51:42 +00:00
token := &types.Token{}
token.Kind = types.TokenAgent
2015-04-30 21:57:53 +00:00
token.Label = "drone-agent"
2015-04-30 21:41:52 +00:00
tokenstr, err := sess.GenerateToken(token)
if err != nil {
c.Fail(500, err)
} else {
c.JSON(200, tokenstr)
}
}