mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 20:01:02 +00:00
Merge remote-tracking branch 'upstream/0.4.0' into 0.4.0
This commit is contained in:
commit
9c62d0b883
1 changed files with 32 additions and 22 deletions
|
@ -44,10 +44,38 @@ type Runner struct {
|
||||||
Updater
|
Updater
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newDockerClient() (dockerclient.Client, error) {
|
||||||
|
var tlc *tls.Config
|
||||||
|
|
||||||
|
// create the Docket client TLS config
|
||||||
|
if len(DockerHostCert) > 0 && len(DockerHostKey) > 0 && len(DockerHostCa) > 0 {
|
||||||
|
cert, err := tls.LoadX509KeyPair(DockerHostCert, DockerHostKey)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("failure to load SSL cert and key. %s", err)
|
||||||
|
return dockerclient.NewDockerClient(DockerHost, nil)
|
||||||
|
}
|
||||||
|
caCert, err := ioutil.ReadFile(DockerHostCa)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("failure to load SSL CA cert. %s", err)
|
||||||
|
return dockerclient.NewDockerClient(DockerHost, nil)
|
||||||
|
}
|
||||||
|
caCertPool := x509.NewCertPool()
|
||||||
|
caCertPool.AppendCertsFromPEM(caCert)
|
||||||
|
tlc = &tls.Config{
|
||||||
|
Certificates: []tls.Certificate{cert},
|
||||||
|
RootCAs: caCertPool,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the Docker client. In this version of Drone (alpha)
|
||||||
|
// we do not spread builds across clients, but this can and
|
||||||
|
// (probably) will change in the future.
|
||||||
|
return dockerclient.NewDockerClient(DockerHost, tlc)
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Runner) Run(w *queue.Work) error {
|
func (r *Runner) Run(w *queue.Work) error {
|
||||||
var workers []*worker
|
var workers []*worker
|
||||||
var client dockerclient.Client
|
var client dockerclient.Client
|
||||||
var tlc *tls.Config
|
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
recover()
|
recover()
|
||||||
|
@ -98,28 +126,10 @@ func (r *Runner) Run(w *queue.Work) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the Docket client TLS config
|
|
||||||
if len(DockerHostCert) > 0 && len(DockerHostKey) > 0 && len(DockerHostCa) > 0 {
|
|
||||||
cert, err := tls.LoadX509KeyPair(DockerHostCert, DockerHostKey)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("failure to load SSL cert and key. %s", err)
|
|
||||||
}
|
|
||||||
caCert, err := ioutil.ReadFile(DockerHostCa)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("failure to load SSL CA cert. %s", err)
|
|
||||||
}
|
|
||||||
caCertPool := x509.NewCertPool()
|
|
||||||
caCertPool.AppendCertsFromPEM(caCert)
|
|
||||||
tlc = &tls.Config{
|
|
||||||
Certificates: []tls.Certificate{cert},
|
|
||||||
RootCAs: caCertPool,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// create the Docker client. In this version of Drone (alpha)
|
// create the Docker client. In this version of Drone (alpha)
|
||||||
// we do not spread builds across clients, but this can and
|
// we do not spread builds across clients, but this can and
|
||||||
// (probably) will change in the future.
|
// (probably) will change in the future.
|
||||||
client, err = dockerclient.NewDockerClient(DockerHost, tlc)
|
client, err = newDockerClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failure to connect to docker. %s", err)
|
log.Errorf("failure to connect to docker. %s", err)
|
||||||
return err
|
return err
|
||||||
|
@ -240,7 +250,7 @@ func (r *Runner) Run(w *queue.Work) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runner) Cancel(job *types.Job) error {
|
func (r *Runner) Cancel(job *types.Job) error {
|
||||||
client, err := dockerclient.NewDockerClient(DockerHost, nil)
|
client, err := newDockerClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -248,7 +258,7 @@ func (r *Runner) Cancel(job *types.Job) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runner) Logs(job *types.Job) (io.ReadCloser, error) {
|
func (r *Runner) Logs(job *types.Job) (io.ReadCloser, error) {
|
||||||
client, err := dockerclient.NewDockerClient(DockerHost, nil)
|
client, err := newDockerClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue