Merge pull request #1338 from bradrydzewski/master

ability to replace repository private key
This commit is contained in:
Brad Rydzewski 2015-11-20 10:50:24 -08:00
commit 241e84608f
4 changed files with 28 additions and 2 deletions

View file

@ -160,12 +160,36 @@ func GetRepoKey(c *gin.Context) {
repo := session.Repo(c)
keys, err := store.GetKey(c, repo)
if err != nil {
c.AbortWithError(http.StatusNotFound, err)
c.String(404, "Error fetching repository key")
} else {
c.String(http.StatusOK, keys.Public)
}
}
func PostRepoKey(c *gin.Context) {
repo := session.Repo(c)
keys, err := store.GetKey(c, repo)
if err != nil {
c.String(404, "Error fetching repository key")
return
}
body, _ := ioutil.ReadAll(c.Request.Body)
pkey := crypto.UnmarshalPrivateKey(body)
if pkey == nil {
c.String(500, "Cannot unmarshal private key. Invalid format.")
return
}
keys.Public = string(crypto.MarshalPublicKey(&pkey.PublicKey))
keys.Private = string(crypto.MarshalPrivateKey(pkey))
err = store.UpdateKey(c, keys)
if err != nil {
c.String(500, "Error updating repository key")
return
}
}
func DeleteRepo(c *gin.Context) {
remote := remote.FromContext(c)
repo := session.Repo(c)

2
docs/build/cache.md vendored
View file

@ -2,7 +2,7 @@
> This feature is still considered experimental
Drone allows you to cache directories within the build workspace. When a build successfully completes, the named directories are gzipped and stored on the host machine. When a new build starts, the named directories are restored from the gzipped files. This can be used to improve the performance of your builds.
Drone allows you to cache directories within the build workspace (`/drone`). When a build successfully completes, the named directories are gzipped and stored on the host machine. When a new build starts, the named directories are restored from the gzipped files. This can be used to improve the performance of your builds.
Below is an example `.drone.yml` configured to cache the `.git` and the `node_modules` directory:

1
docs/build/env.md vendored
View file

@ -31,6 +31,7 @@ Drone also injects `CI_` prefixed variables for compatibility with other systems
A subset of variables may be substituted directly into the Yaml at runtime using the `$$` notation:
* `$$BUILD_NUMBER` build number for the current build
* `$$COMMIT` git sha for the current build, long format
* `$$BRANCH` git branch for the current build
* `$$BUILD_NUMBER` build number for the current build

View file

@ -99,6 +99,7 @@ func Load(middleware ...gin.HandlerFunc) http.Handler {
repo.GET("", controller.GetRepo)
repo.GET("/key", controller.GetRepoKey)
repo.POST("/key", controller.PostRepoKey)
repo.GET("/builds", controller.GetBuilds)
repo.GET("/builds/:number", controller.GetBuild)
repo.GET("/logs/:number/:job", controller.GetBuildLogs)