fix route for proc logs

This commit is contained in:
Brad Rydzewski 2017-08-24 17:03:11 -07:00
parent f43e1e6c33
commit 7d245e7b27
4 changed files with 46 additions and 13 deletions

View file

@ -46,16 +46,6 @@ pipeline:
branch: master branch: master
event: push event: push
publish_agent:
image: plugins/docker
repo: drone/agent
dockerfile: Dockerfile.agent
secrets: [ docker_username, docker_password ]
tag: [ latest ]
when:
branch: master
event: push
publish_agent_arm: publish_agent_arm:
image: plugins/docker image: plugins/docker
repo: drone/agent repo: drone/agent
@ -76,6 +66,16 @@ pipeline:
branch: master branch: master
event: push event: push
publish_agent_amd64:
image: plugins/docker
repo: drone/agent
dockerfile: Dockerfile.agent
secrets: [ docker_username, docker_password ]
tag: [ latest ]
when:
branch: master
event: push
release_server: release_server:
image: plugins/docker image: plugins/docker
repo: drone/drone repo: drone/drone

View file

@ -80,7 +80,8 @@ func Load(mux *httptreemux.ContextMux, middleware ...gin.HandlerFunc) http.Handl
repo.GET("", server.GetRepo) repo.GET("", server.GetRepo)
repo.GET("/builds", server.GetBuilds) repo.GET("/builds", server.GetBuilds)
repo.GET("/builds/:number", server.GetBuild) repo.GET("/builds/:number", server.GetBuild)
repo.GET("/logs/:number/:ppid/:proc", server.GetBuildLogs) repo.GET("/logs/:number/:pid", server.GetProcLogs)
repo.GET("/logs/:number/:pid/:proc", server.GetBuildLogs)
repo.GET("/files/:number", server.FileList) repo.GET("/files/:number", server.FileList)
repo.GET("/files/:number/:proc/*file", server.FileGet) repo.GET("/files/:number/:proc/*file", server.FileGet)

View file

@ -79,7 +79,7 @@ func GetBuildLogs(c *gin.Context) {
// parse the build number and job sequence number from // parse the build number and job sequence number from
// the repquest parameter. // the repquest parameter.
num, _ := strconv.Atoi(c.Params.ByName("number")) num, _ := strconv.Atoi(c.Params.ByName("number"))
ppid, _ := strconv.Atoi(c.Params.ByName("ppid")) ppid, _ := strconv.Atoi(c.Params.ByName("pid"))
name := c.Params.ByName("proc") name := c.Params.ByName("proc")
build, err := store.GetBuildNumber(c, repo, num) build, err := store.GetBuildNumber(c, repo, num)
@ -106,6 +106,38 @@ func GetBuildLogs(c *gin.Context) {
io.Copy(c.Writer, rc) io.Copy(c.Writer, rc)
} }
func GetProcLogs(c *gin.Context) {
repo := session.Repo(c)
// parse the build number and job sequence number from
// the repquest parameter.
num, _ := strconv.Atoi(c.Params.ByName("number"))
pid, _ := strconv.Atoi(c.Params.ByName("pid"))
build, err := store.GetBuildNumber(c, repo, num)
if err != nil {
c.AbortWithError(404, err)
return
}
proc, err := store.FromContext(c).ProcFind(build, pid)
if err != nil {
c.AbortWithError(404, err)
return
}
rc, err := store.FromContext(c).LogFind(proc)
if err != nil {
c.AbortWithError(404, err)
return
}
defer rc.Close()
c.Header("Content-Type", "application/json")
io.Copy(c.Writer, rc)
}
func DeleteBuild(c *gin.Context) { func DeleteBuild(c *gin.Context) {
repo := session.Repo(c) repo := session.Repo(c)

View file

@ -187,7 +187,7 @@ func DeleteRepo(c *gin.Context) {
} }
remote.Deactivate(user, repo, httputil.GetURL(c.Request)) remote.Deactivate(user, repo, httputil.GetURL(c.Request))
c.Writer.WriteHeader(http.StatusOK) c.JSON(200, repo)
} }
func RepairRepo(c *gin.Context) { func RepairRepo(c *gin.Context) {