Last active
January 24, 2017 10:33
-
-
Save hackintoshrao/3a22f3b9433c6d2a2dbfa382d33ef116 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "github.com/docker/go-plugins-helpers/volume" | |
| ) | |
| const ( | |
| sshfsID = "_sshfs" | |
| socketAddress = "/run/docker/plugins/my-dummy-fs.sock" | |
| ) | |
| type myTestDriver struct { | |
| } | |
| func newMyTestDriver(root string) *myTestDriver { | |
| d := &myTestDriver{ | |
| } | |
| return d | |
| } | |
| func (d *myTestDriver) Create(r volume.Request) volume.Response { | |
| return volume.Response{} | |
| } | |
| func (d *myTestDriver) Remove(r volume.Request) volume.Response { | |
| return volume.Response{} | |
| } | |
| func (d *myTestDriver) Path(r volume.Request) volume.Response { | |
| return volume.Response{} | |
| } | |
| func (d *myTestDriver) Mount(r volume.MountRequest) volume.Response { | |
| return volume.Response{Mountpoint: v.mountpoint} | |
| } | |
| func (d *myTestDriver) Unmount(r volume.UnmountRequest) volume.Response { | |
| return volume.Response{} | |
| } | |
| func (d *myTestDriver) Get(r volume.Request) volume.Response { | |
| return volume.Response{} | |
| } | |
| func (d *myTestDriver) List(r volume.Request) volume.Response { | |
| return volume.Response{} | |
| } | |
| func (d *myTestDriver) Capabilities(r volume.Request) volume.Response { | |
| return volume.Response{Capabilities: volume.Capability{Scope: "local"}} | |
| } | |
| func main() { | |
| // obtain an instance of your struct which implements the `volume.Driver` interface. | |
| d := newMyTestDriver() | |
| // Pass it to the volume.NewHandler function which does all initialization including registering of the end points. | |
| h := volume.NewHandler(d) | |
| // create a unix socket in the path "/run/docker/plugins/", | |
| // this creates the unix socket ""/run/docker/plugins/my-dummy-plugin.sock", | |
| // by the presense of the socket file docker detects the presense of the plugin, | |
| // when an attempt to create a volume using that plugin is made. | |
| logrus.Error(h.ServeUnix(socketAddress,0)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment