@@ -4,10 +4,12 @@ import (
44 "errors"
55 log "github.com/Sirupsen/logrus"
66 "github.com/docker/go-plugins-helpers/volume"
7+ "strings"
78)
89
910const (
1011 ShareOpt = "share"
12+ CreateOpt = "create"
1113)
1214
1315type mount struct {
@@ -66,6 +68,14 @@ func (m *mountManager) GetOption(name, key string) string {
6668 return ""
6769}
6870
71+ func (m * mountManager ) GetOptionAsBool (name , key string ) bool {
72+ rv := strings .ToLower (m .GetOption (name , key ))
73+ if rv == "yes" || rv == "true" {
74+ return true
75+ }
76+ return false
77+ }
78+
6979func (m * mountManager ) IsActiveMount (name string ) bool {
7080 c , found := m .mounts [name ]
7181 return found && c .connections > 0
@@ -88,12 +98,15 @@ func (m *mountManager) Add(name, hostdir string) {
8898 }
8999}
90100
91- func (m * mountManager ) Create (name , hostdir string , opts map [string ]string ) {
101+ func (m * mountManager ) Create (name , hostdir string , opts map [string ]string ) * mount {
92102 c , found := m .mounts [name ]
93103 if found && c .connections > 0 {
94104 c .opts = opts
105+ return c
95106 } else {
96- m .mounts [name ] = & mount {name : name , hostdir : hostdir , managed : true , opts : opts , connections : 0 }
107+ mnt := & mount {name : name , hostdir : hostdir , managed : true , opts : opts , connections : 0 }
108+ m .mounts [name ] = mnt
109+ return mnt
97110 }
98111}
99112
0 commit comments