github.com/rawahars/moby@v24.0.4+incompatible/libnetwork/drivers/host/host.go (about)

     1  package host
     2  
     3  import (
     4  	"sync"
     5  
     6  	"github.com/docker/docker/libnetwork/datastore"
     7  	"github.com/docker/docker/libnetwork/discoverapi"
     8  	"github.com/docker/docker/libnetwork/driverapi"
     9  	"github.com/docker/docker/libnetwork/types"
    10  )
    11  
    12  const networkType = "host"
    13  
    14  type driver struct {
    15  	network string
    16  	sync.Mutex
    17  }
    18  
    19  // Init registers a new instance of host driver.
    20  //
    21  // Deprecated: use [Register].
    22  func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
    23  	return Register(dc, config)
    24  }
    25  
    26  func Register(r driverapi.Registerer, config map[string]interface{}) error {
    27  	c := driverapi.Capability{
    28  		DataScope:         datastore.LocalScope,
    29  		ConnectivityScope: datastore.LocalScope,
    30  	}
    31  	return r.RegisterDriver(networkType, &driver{}, c)
    32  }
    33  
    34  func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
    35  	return nil, types.NotImplementedErrorf("not implemented")
    36  }
    37  
    38  func (d *driver) NetworkFree(id string) error {
    39  	return types.NotImplementedErrorf("not implemented")
    40  }
    41  
    42  func (d *driver) EventNotify(etype driverapi.EventType, nid, tableName, key string, value []byte) {
    43  }
    44  
    45  func (d *driver) DecodeTableEntry(tablename string, key string, value []byte) (string, map[string]string) {
    46  	return "", nil
    47  }
    48  
    49  func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error {
    50  	d.Lock()
    51  	defer d.Unlock()
    52  
    53  	if d.network != "" {
    54  		return types.ForbiddenErrorf("only one instance of \"%s\" network is allowed", networkType)
    55  	}
    56  
    57  	d.network = id
    58  
    59  	return nil
    60  }
    61  
    62  func (d *driver) DeleteNetwork(nid string) error {
    63  	return types.ForbiddenErrorf("network of type \"%s\" cannot be deleted", networkType)
    64  }
    65  
    66  func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error {
    67  	return nil
    68  }
    69  
    70  func (d *driver) DeleteEndpoint(nid, eid string) error {
    71  	return nil
    72  }
    73  
    74  func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
    75  	return make(map[string]interface{}), nil
    76  }
    77  
    78  // Join method is invoked when a Sandbox is attached to an endpoint.
    79  func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
    80  	return nil
    81  }
    82  
    83  // Leave method is invoked when a Sandbox detaches from an endpoint.
    84  func (d *driver) Leave(nid, eid string) error {
    85  	return nil
    86  }
    87  
    88  func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
    89  	return nil
    90  }
    91  
    92  func (d *driver) RevokeExternalConnectivity(nid, eid string) error {
    93  	return nil
    94  }
    95  
    96  func (d *driver) Type() string {
    97  	return networkType
    98  }
    99  
   100  func (d *driver) IsBuiltIn() bool {
   101  	return true
   102  }
   103  
   104  // DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster
   105  func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error {
   106  	return nil
   107  }
   108  
   109  // DiscoverDelete is a notification for a discovery delete event, such as a node leaving a cluster
   110  func (d *driver) DiscoverDelete(dType discoverapi.DiscoveryType, data interface{}) error {
   111  	return nil
   112  }