github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/volume/drivers/proxy.go (about) 1 // generated code - DO NOT EDIT 2 3 package drivers // import "github.com/Prakhar-Agarwal-byte/moby/volume/drivers" 4 5 import ( 6 "errors" 7 "time" 8 9 "github.com/Prakhar-Agarwal-byte/moby/pkg/plugins" 10 "github.com/Prakhar-Agarwal-byte/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 type volumeDriverProxyListResponse struct { 176 Volumes []*proxyVolume 177 Err string 178 } 179 180 func (pp *volumeDriverProxy) List() (volumes []*proxyVolume, err error) { 181 var ( 182 req volumeDriverProxyListRequest 183 ret volumeDriverProxyListResponse 184 ) 185 186 if err = pp.CallWithOptions("VolumeDriver.List", req, &ret, plugins.WithRequestTimeout(shortTimeout)); err != nil { 187 return 188 } 189 190 volumes = ret.Volumes 191 192 if ret.Err != "" { 193 err = errors.New(ret.Err) 194 } 195 196 return 197 } 198 199 type volumeDriverProxyGetRequest struct { 200 Name string 201 } 202 203 type volumeDriverProxyGetResponse struct { 204 Volume *proxyVolume 205 Err string 206 } 207 208 func (pp *volumeDriverProxy) Get(name string) (volume *proxyVolume, err error) { 209 var ( 210 req volumeDriverProxyGetRequest 211 ret volumeDriverProxyGetResponse 212 ) 213 214 req.Name = name 215 216 if err = pp.CallWithOptions("VolumeDriver.Get", req, &ret, plugins.WithRequestTimeout(shortTimeout)); err != nil { 217 return 218 } 219 220 volume = ret.Volume 221 222 if ret.Err != "" { 223 err = errors.New(ret.Err) 224 } 225 226 return 227 } 228 229 type volumeDriverProxyCapabilitiesRequest struct{} 230 231 type volumeDriverProxyCapabilitiesResponse struct { 232 Capabilities volume.Capability 233 Err string 234 } 235 236 func (pp *volumeDriverProxy) Capabilities() (capabilities volume.Capability, err error) { 237 var ( 238 req volumeDriverProxyCapabilitiesRequest 239 ret volumeDriverProxyCapabilitiesResponse 240 ) 241 242 if err = pp.CallWithOptions("VolumeDriver.Capabilities", req, &ret, plugins.WithRequestTimeout(shortTimeout)); err != nil { 243 return 244 } 245 246 capabilities = ret.Capabilities 247 248 if ret.Err != "" { 249 err = errors.New(ret.Err) 250 } 251 252 return 253 }