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

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