-
Notifications
You must be signed in to change notification settings - Fork 4
/
builder.go
42 lines (37 loc) · 1.24 KB
/
builder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Package pkg provides common libraries for the Drycc builder.
//
// The Drycc builder is responsible for building buildpack and container images for use in the Drycc
// on the Drycc PaaS platform.
package pkg
import (
"fmt"
"github.com/drycc/builder/pkg/sshd"
"github.com/drycc/pkg/log"
)
// Return codes that will be sent to the shell.
const (
StatusOk = iota
StatusLocalError
)
// RunBuilder starts the Builder service.
//
// The Builder service is responsible for setting up the local container
// environment and then listening for new builds. The main listening service
// is SSH. Builder listens for new Git commands and then sends those on to
// Git.
//
// Run returns on of the Status* status code constants.
func RunBuilder(cnf *sshd.Config, gitHomeDir string, sshServerCircuit *sshd.Circuit, pushLock sshd.RepositoryLock) int {
address := fmt.Sprintf("%s:%d", cnf.SSHHostIP, cnf.SSHHostPort)
cfg, err := sshd.Configure(cnf)
if err != nil {
log.Err("SSH server configuration failed: %s", err)
return StatusLocalError
}
receivetype := "gitreceive"
if err := sshd.Serve(cfg, sshServerCircuit, gitHomeDir, pushLock, address, receivetype); err != nil {
log.Err("SSH server failed: %s", err)
return StatusLocalError
}
return StatusOk
}