Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Commit

Permalink
use docker-plugins-helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Tsang committed Jan 12, 2016
1 parent 118fdd0 commit c600827
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
34 changes: 17 additions & 17 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"sync"
"time"

"github.com/calavera/dkvolume"
"github.com/docker/go-plugins-helpers/volume"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse/nodefs"
"github.com/square/keywhiz-fs"
Expand Down Expand Up @@ -48,11 +48,11 @@ func newKeywhizDriver(root string, config keywhizConfig) keywhizDriver {
}
}

func (d keywhizDriver) Create(r dkvolume.Request) dkvolume.Response {
return dkvolume.Response{}
func (d keywhizDriver) Create(r volume.Request) volume.Response {
return volume.Response{}
}

func (d keywhizDriver) Remove(r dkvolume.Request) dkvolume.Response {
func (d keywhizDriver) Remove(r volume.Request) volume.Response {
d.m.Lock()
defer d.m.Unlock()
m := d.mountpoint(r.Name)
Expand All @@ -62,14 +62,14 @@ func (d keywhizDriver) Remove(r dkvolume.Request) dkvolume.Response {
delete(d.servers, m)
}
}
return dkvolume.Response{}
return volume.Response{}
}

func (d keywhizDriver) Path(r dkvolume.Request) dkvolume.Response {
return dkvolume.Response{Mountpoint: d.mountpoint(r.Name)}
func (d keywhizDriver) Path(r volume.Request) volume.Response {
return volume.Response{Mountpoint: d.mountpoint(r.Name)}
}

func (d keywhizDriver) Mount(r dkvolume.Request) dkvolume.Response {
func (d keywhizDriver) Mount(r volume.Request) volume.Response {
d.m.Lock()
defer d.m.Unlock()
m := d.mountpoint(r.Name)
Expand All @@ -78,34 +78,34 @@ func (d keywhizDriver) Mount(r dkvolume.Request) dkvolume.Response {
s, ok := d.servers[m]
if ok && s.connections > 0 {
s.connections++
return dkvolume.Response{Mountpoint: m}
return volume.Response{Mountpoint: m}
}

fi, err := os.Lstat(m)

if os.IsNotExist(err) {
if err := os.MkdirAll(m, 0755); err != nil {
return dkvolume.Response{Err: err.Error()}
return volume.Response{Err: err.Error()}
}
} else if err != nil {
return dkvolume.Response{Err: err.Error()}
return volume.Response{Err: err.Error()}
}

if fi != nil && !fi.IsDir() {
return dkvolume.Response{Err: fmt.Sprintf("%v already exist and it's not a directory", m)}
return volume.Response{Err: fmt.Sprintf("%v already exist and it's not a directory", m)}
}

server, err := d.mountServer(m)
if err != nil {
return dkvolume.Response{Err: err.Error()}
return volume.Response{Err: err.Error()}
}

d.servers[m] = &keywhizServer{Server: server, connections: 1}

return dkvolume.Response{Mountpoint: m}
return volume.Response{Mountpoint: m}
}

func (d keywhizDriver) Unmount(r dkvolume.Request) dkvolume.Response {
func (d keywhizDriver) Unmount(r volume.Request) volume.Response {
d.m.Lock()
defer d.m.Unlock()
m := d.mountpoint(r.Name)
Expand All @@ -117,10 +117,10 @@ func (d keywhizDriver) Unmount(r dkvolume.Request) dkvolume.Response {
}
s.connections--
} else {
return dkvolume.Response{Err: fmt.Sprintf("Unable to find volume mounted on %s", m)}
return volume.Response{Err: fmt.Sprintf("Unable to find volume mounted on %s", m)}
}

return dkvolume.Response{}
return volume.Response{}
}

func (d *keywhizDriver) mountpoint(name string) string {
Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"path/filepath"
"time"

"github.com/calavera/dkvolume"
"github.com/docker/go-plugins-helpers/volume"
klog "github.com/square/keywhiz-fs/log"
"golang.org/x/sys/unix"
)
Expand All @@ -19,7 +19,7 @@ const (
)

var (
defaultPath = filepath.Join(dkvolume.DefaultDockerRootDirectory, keywhizId)
defaultPath = filepath.Join(volume.DefaultDockerRootDirectory, keywhizId)

root = flag.String("root", defaultPath, "Docker volumes root directory")
certFile = flag.String("cert", "", "PEM-encoded certificate file")
Expand Down Expand Up @@ -59,7 +59,7 @@ func main() {
lockMemory(config.Debug)

d := newKeywhizDriver(*root, config)
h := dkvolume.NewHandler(d)
h := volume.NewHandler(d)
fmt.Printf("Listening on %s\n", socketAddress)
fmt.Println(h.ServeUnix("root", socketAddress))
}
Expand Down

0 comments on commit c600827

Please sign in to comment.