mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-26 10:20:29 +00:00
ability to encrypt the .drone.sec file
This commit is contained in:
parent
dc96183f2f
commit
5f802056e0
3 changed files with 13 additions and 2 deletions
|
@ -80,7 +80,7 @@
|
|||
* @param {string} Plaintext to encrypt.
|
||||
*/
|
||||
this.encrypt = function (repoName, plaintext) {
|
||||
return $http.post('/api/repos/' + repoName + '/encrypt', plaintext);
|
||||
return $http.post('/api/repos/' + repoName + '/encrypt', btoa(plaintext));
|
||||
};
|
||||
|
||||
var callback,
|
||||
|
|
|
@ -255,6 +255,7 @@ func (r *Runner) Logs(job *types.Job) (io.ReadCloser, error) {
|
|||
// make sure this container actually exists
|
||||
info, err := client.InspectContainer(cname(job))
|
||||
if err != nil {
|
||||
|
||||
// add a small exponential backoff since there
|
||||
// is a small window when the container hasn't
|
||||
// been created yet, but the build is about to start
|
||||
|
@ -264,7 +265,9 @@ func (r *Runner) Logs(job *types.Job) (io.ReadCloser, error) {
|
|||
if err != nil && i == 5 {
|
||||
return nil, err
|
||||
}
|
||||
break
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
||||
|
@ -254,6 +256,12 @@ func Encrypt(c *gin.Context) {
|
|||
c.Fail(500, err)
|
||||
return
|
||||
}
|
||||
in, err = base64.StdEncoding.DecodeString(string(in))
|
||||
if err != nil {
|
||||
c.Fail(500, err)
|
||||
return
|
||||
}
|
||||
in = bytes.Replace(in, []byte{'\xA0'}, []byte{' '}, -1)
|
||||
out, err := secure.Encrypt(string(in), repo.Keys.Private)
|
||||
if err != nil {
|
||||
c.Fail(500, err)
|
||||
|
|
Loading…
Reference in a new issue