@@ -169,7 +169,10 @@ type tableEntry struct {
169169 value []byte
170170}
171171
172- // Info returns certain operational data belonging to this endpoint.
172+ // Info hydrates the endpoint and returns certain operational data belonging
173+ // to this endpoint.
174+ //
175+ // TODO(thaJeztah): make sure that Endpoint is always fully hydrated, and remove the EndpointInfo interface, and use Endpoint directly.
173176func (ep * Endpoint ) Info () EndpointInfo {
174177 if ep .sandboxID != "" {
175178 return ep
@@ -194,6 +197,9 @@ func (ep *Endpoint) Info() EndpointInfo {
194197 return sb .getEndpoint (ep .ID ())
195198}
196199
200+ // Iface returns information about the interface which was assigned to
201+ // the endpoint by the driver. This can be used after the
202+ // endpoint has been created.
197203func (ep * Endpoint ) Iface () * EndpointInterface {
198204 ep .mu .Lock ()
199205 defer ep .mu .Unlock ()
@@ -290,6 +296,8 @@ func (ep *Endpoint) InterfaceName() driverapi.InterfaceNameInfo {
290296 return nil
291297}
292298
299+ // AddStaticRoute adds a route to the sandbox.
300+ // It may be used in addition to or instead of a default gateway (as above).
293301func (ep * Endpoint ) AddStaticRoute (destination * net.IPNet , routeType int , nextHop net.IP ) error {
294302 ep .mu .Lock ()
295303 defer ep .mu .Unlock ()
@@ -306,6 +314,8 @@ func (ep *Endpoint) AddStaticRoute(destination *net.IPNet, routeType int, nextHo
306314 return nil
307315}
308316
317+ // AddTableEntry adds a table entry to the gossip layer
318+ // passing the table name, key and an opaque value.
309319func (ep * Endpoint ) AddTableEntry (tableName , key string , value []byte ) error {
310320 ep .mu .Lock ()
311321 defer ep .mu .Unlock ()
@@ -319,6 +329,7 @@ func (ep *Endpoint) AddTableEntry(tableName, key string, value []byte) error {
319329 return nil
320330}
321331
332+ // Sandbox returns the attached sandbox if there, nil otherwise.
322333func (ep * Endpoint ) Sandbox () * Sandbox {
323334 cnt , ok := ep .getSandbox ()
324335 if ! ok {
@@ -327,12 +338,15 @@ func (ep *Endpoint) Sandbox() *Sandbox {
327338 return cnt
328339}
329340
341+ // LoadBalancer returns whether the endpoint is the load balancer endpoint for the network.
330342func (ep * Endpoint ) LoadBalancer () bool {
331343 ep .mu .Lock ()
332344 defer ep .mu .Unlock ()
333345 return ep .loadBalancer
334346}
335347
348+ // StaticRoutes returns the list of static routes configured by the network
349+ // driver when the container joins a network
336350func (ep * Endpoint ) StaticRoutes () []* types.StaticRoute {
337351 ep .mu .Lock ()
338352 defer ep .mu .Unlock ()
@@ -344,6 +358,8 @@ func (ep *Endpoint) StaticRoutes() []*types.StaticRoute {
344358 return ep .joinInfo .StaticRoutes
345359}
346360
361+ // Gateway returns the IPv4 gateway assigned by the driver.
362+ // This will only return a valid value if a container has joined the endpoint.
347363func (ep * Endpoint ) Gateway () net.IP {
348364 ep .mu .Lock ()
349365 defer ep .mu .Unlock ()
@@ -355,6 +371,8 @@ func (ep *Endpoint) Gateway() net.IP {
355371 return types .GetIPCopy (ep .joinInfo .gw )
356372}
357373
374+ // GatewayIPv6 returns the IPv6 gateway assigned by the driver.
375+ // This will only return a valid value if a container has joined the endpoint.
358376func (ep * Endpoint ) GatewayIPv6 () net.IP {
359377 ep .mu .Lock ()
360378 defer ep .mu .Unlock ()
@@ -366,6 +384,7 @@ func (ep *Endpoint) GatewayIPv6() net.IP {
366384 return types .GetIPCopy (ep .joinInfo .gw6 )
367385}
368386
387+ // SetGateway sets the default IPv4 gateway when a container joins the endpoint.
369388func (ep * Endpoint ) SetGateway (gw net.IP ) error {
370389 ep .mu .Lock ()
371390 defer ep .mu .Unlock ()
@@ -374,6 +393,7 @@ func (ep *Endpoint) SetGateway(gw net.IP) error {
374393 return nil
375394}
376395
396+ // SetGatewayIPv6 sets the default IPv6 gateway when a container joins the endpoint.
377397func (ep * Endpoint ) SetGatewayIPv6 (gw6 net.IP ) error {
378398 ep .mu .Lock ()
379399 defer ep .mu .Unlock ()
@@ -390,6 +410,7 @@ func (ep *Endpoint) retrieveFromStore() (*Endpoint, error) {
390410 return n .getEndpointFromStore (ep .ID ())
391411}
392412
413+ // DisableGatewayService tells libnetwork not to provide Default GW for the container
393414func (ep * Endpoint ) DisableGatewayService () {
394415 ep .mu .Lock ()
395416 defer ep .mu .Unlock ()
0 commit comments