-
Notifications
You must be signed in to change notification settings - Fork 16
/
main.go
36 lines (27 loc) · 861 Bytes
/
main.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
package main // import "github.com/costela/docker-volume-hetzner"
import (
"fmt"
"os"
"github.com/docker/go-plugins-helpers/volume"
"github.com/sirupsen/logrus"
)
const socketAddress = "/run/docker/plugins/hetzner.sock"
const propagatedMountPath = "/mnt"
func main() {
logrus.SetFormatter(&bareFormatter{})
logLevel, err := logrus.ParseLevel(os.Getenv("loglevel"))
if err != nil {
logrus.Fatalf("could not parse log level %s", os.Getenv("loglevel"))
}
logrus.SetLevel(logLevel)
hd := newHetznerDriver()
h := volume.NewHandler(hd)
logrus.Infof("listening on %s", socketAddress)
if err := h.ServeUnix(socketAddress, 0); err != nil {
logrus.Fatalf("error serving docker socket: %v", err)
}
}
type bareFormatter struct{}
func (bareFormatter) Format(e *logrus.Entry) ([]byte, error) {
return []byte(fmt.Sprintf("%s\n", e.Message)), nil
}