github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/volume/drivers/proxy.go (about) 1 // generated code - DO NOT EDIT 2 3 package drivers // import "github.com/demonoid81/moby/volume/drivers" 4 5 import ( 6 "errors" 7 "time" 8 9 "github.com/demonoid81/moby/pkg/plugins" 10 "github.com/demonoid81/moby/volume" 11 ) 12 13 const ( 14 longTimeout = 2 * time.Minute 15 shortTimeout = 1 * time.Minute 16 ) 17 18 type client interface { 19 CallWithOptions(string, interface{}, interface{}, ...func(*plugins.RequestOpts)) error 20 } 21 22 type volumeDriverProxy struct { 23 client 24 } 25 26 type volumeDriverProxyCreateRequest struct { 27 Name string 28 Opts map[string]string 29 } 30 31 type volumeDriverProxyCreateResponse struct { 32 Err string 33 } 34 35 func (pp *volumeDriverProxy) Create(name string, opts map[string]string) (err error) { 36 var ( 37 req volumeDriverProxyCreateRequest 38 ret volumeDriverProxyCreateResponse 39 ) 40 41 req.Name = name 42 req.Opts = opts 43 44 if err = pp.CallWithOptions("VolumeDriver.Create", req, &ret, plugins.WithRequestTimeout(longTimeout)); err != nil { 45 return 46 } 47 48 if ret.Err != "" { 49 err = errors.New(ret.Err) 50 } 51 52 return 53 } 54 55 type volumeDriverProxyRemoveRequest struct { 56 Name string 57 } 58 59 type volumeDriverProxyRemoveResponse struct { 60 Err string 61 } 62 63 func (pp *volumeDriverProxy) Remove(name string) (err error) { 64 var ( 65 req volumeDriverProxyRemoveRequest 66 ret volumeDriverProxyRemoveResponse 67 ) 68 69 req.Name = name 70 71 if err = pp.CallWithOptions("VolumeDriver.Remove", req, &ret, plugins.WithRequestTimeout(shortTimeout)); err != nil { 72 return 73 } 74 75 if ret.Err != "" { 76 err = errors.New(ret.Err) 77 } 78 79 return 80 } 81 82 type volumeDriverProxyPathRequest struct { 83 Name string 84 } 85 86 type volumeDriverProxyPathResponse struct { 87 Mountpoint string 88 Err string 89 } 90 91 func (pp *volumeDriverProxy) Path(name string) (mountpoint string, err error) { 92 var ( 93 req volumeDriverProxyPathRequest 94 ret volumeDriverProxyPathResponse 95 ) 96 97 req.Name = name 98 99 if err = pp.CallWithOptions("VolumeDriver.Path", req, &ret, plugins.WithRequestTimeout(shortTimeout)); err != nil { 100 return 101 } 102 103 mountpoint = ret.Mountpoint 104 105 if ret.Err != "" { 106 err = errors.New(ret.Err) 107 } 108 109 return 110 } 111 112 type volumeDriverProxyMountRequest struct { 113 Name string 114 ID string 115 } 116 117 type volumeDriverProxyMountResponse struct { 118 Mountpoint string 119 Err string 120 } 121 122 func (pp *volumeDriverProxy) Mount(name string, id string) (mountpoint string, err error) { 123 var ( 124 req volumeDriverProxyMountRequest 125 ret volumeDriverProxyMountResponse 126 ) 127 128 req.Name = name 129 req.ID = id 130 131 if err = pp.CallWithOptions("VolumeDriver.Mount", req, &ret, plugins.WithRequestTimeout(longTimeout)); err != nil { 132 return 133 } 134 135 mountpoint = ret.Mountpoint 136 137 if ret.Err != "" { 138 err = errors.New(ret.Err) 139 } 140 141 return 142 } 143 144 type volumeDriverProxyUnmountRequest struct { 145 Name string 146 ID string 147 } 148 149 type volumeDriverProxyUnmountResponse struct { 150 Err string 151 } 152 153 func (pp *volumeDriverProxy) Unmount(name string, id string) (err error) { 154 var ( 155 req volumeDriverProxyUnmountRequest 156 ret volumeDriverProxyUnmountResponse 157 ) 158 159 req.Name = name 160 req.ID = id 161 162 if err = pp.CallWithOptions("VolumeDriver.Unmount", req, &ret, plugins.WithRequestTimeout(shortTimeout)); err != nil { 163 return 164 } 165 166 if ret.Err != "" { 167 err = errors.New(ret.Err) 168 } 169 170 return 171 } 172 173 type volumeDriverProxyListRequest struct { 174 } 175 176 type volumeDriverProxyListResponse struct { 177 Volumes []*proxyVolume 178 Err string 179 } 180 181 func (pp *volumeDriverProxy) List() (volumes []*proxyVolume, err error) { 182 var ( 183 req volumeDriverProxyListRequest 184 ret volumeDriverProxyListResponse 185 ) 186 187 if err = pp.CallWithOptions("VolumeDriver.List", req, &ret, plugins.WithRequestTimeout(shortTimeout)); err != nil { 188 return 189 } 190 191 volumes = ret.Volumes 192 193 if ret.Err != "" { 194 err = errors.New(ret.Err) 195 } 196 197 return 198 } 199 200 type volumeDriverProxyGetRequest struct { 201 Name string 202 } 203 204 type volumeDriverProxyGetResponse struct { 205 Volume *proxyVolume 206 Err string 207 } 208 209 func (pp *volumeDriverProxy) Get(name string) (volume *proxyVolume, err error) { 210 var ( 211 req volumeDriverProxyGetRequest 212 ret volumeDriverProxyGetResponse 213 ) 214 215 req.Name = name 216 217 if err = pp.CallWithOptions("VolumeDriver.Get", req, &ret, plugins.WithRequestTimeout(shortTimeout)); err != nil { 218 return 219 } 220 221 volume = ret.Volume 222 223 if ret.Err != "" { 224 err = errors.New(ret.Err) 225 } 226 227 return 228 } 229 230 type volumeDriverProxyCapabilitiesRequest struct { 231 } 232 233 type volumeDriverProxyCapabilitiesResponse struct { 234 Capabilities volume.Capability 235 Err string 236 } 237 238 func (pp *volumeDriverProxy) Capabilities() (capabilities volume.Capability, err error) { 239 var ( 240 req volumeDriverProxyCapabilitiesRequest 241 ret volumeDriverProxyCapabilitiesResponse 242 ) 243 244 if err = pp.CallWithOptions("VolumeDriver.Capabilities", req, &ret, plugins.WithRequestTimeout(shortTimeout)); err != nil { 245 return 246 } 247 248 capabilities = ret.Capabilities 249 250 if ret.Err != "" { 251 err = errors.New(ret.Err) 252 } 253 254 return 255 }