github.com/cilium/cilium@v1.16.2/pkg/ipam/noop_allocator.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright Authors of Cilium
     3  
     4  package ipam
     5  
     6  import (
     7  	"errors"
     8  	"net"
     9  )
    10  
    11  var errNotSupported = errors.New("Operation not supported")
    12  
    13  // noOpAllocator implements ipam.Allocator with no-op behavior.
    14  // It is used for IPAMDelegatedPlugin, where the CNI binary is responsible for assigning IPs
    15  // without relying on the cilium daemon or operator.
    16  type noOpAllocator struct{}
    17  
    18  func (n *noOpAllocator) Allocate(ip net.IP, owner string, pool Pool) (*AllocationResult, error) {
    19  	return nil, errNotSupported
    20  }
    21  
    22  func (n *noOpAllocator) AllocateWithoutSyncUpstream(ip net.IP, owner string, pool Pool) (*AllocationResult, error) {
    23  	return nil, errNotSupported
    24  }
    25  
    26  func (n *noOpAllocator) Release(ip net.IP, pool Pool) error {
    27  	return errNotSupported
    28  }
    29  
    30  func (n *noOpAllocator) AllocateNext(owner string, pool Pool) (*AllocationResult, error) {
    31  	return nil, errNotSupported
    32  }
    33  
    34  func (n *noOpAllocator) AllocateNextWithoutSyncUpstream(owner string, pool Pool) (*AllocationResult, error) {
    35  	return nil, errNotSupported
    36  }
    37  
    38  func (n *noOpAllocator) Dump() (map[Pool]map[string]string, string) {
    39  	return nil, "delegated to plugin"
    40  }
    41  
    42  func (n *noOpAllocator) Capacity() uint64 {
    43  	return uint64(0)
    44  }
    45  
    46  func (n *noOpAllocator) RestoreFinished() {
    47  }