From 3147a013fbd504a055db55404159a4bcc30a9709 Mon Sep 17 00:00:00 2001 From: Albin Kerouanton Date: Wed, 24 Jan 2024 01:30:30 +0100 Subject: [PATCH] libnet/ds: remove unused param `key` from List Since 43dccc6 the `key` param is never used and can be safely removed. Signed-off-by: Albin Kerouanton --- libnetwork/datastore/datastore.go | 2 +- libnetwork/drivers/bridge/bridge_store.go | 4 ++-- libnetwork/drivers/ipvlan/ipvlan_store.go | 4 ++-- libnetwork/drivers/macvlan/macvlan_store.go | 4 ++-- libnetwork/drivers/windows/windows_store.go | 4 ++-- libnetwork/sandbox_store.go | 2 +- libnetwork/store.go | 8 +++----- 7 files changed, 13 insertions(+), 15 deletions(-) diff --git a/libnetwork/datastore/datastore.go b/libnetwork/datastore/datastore.go index cf4489d8a6..b12fdba9e1 100644 --- a/libnetwork/datastore/datastore.go +++ b/libnetwork/datastore/datastore.go @@ -236,7 +236,7 @@ func (ds *Store) ensureParent(parent string) error { // List returns of a list of KVObjects belonging to the parent key. The caller // must pass a KVObject of the same type as the objects that need to be listed. -func (ds *Store) List(key string, kvObject KVObject) ([]KVObject, error) { +func (ds *Store) List(kvObject KVObject) ([]KVObject, error) { ds.mu.Lock() defer ds.mu.Unlock() diff --git a/libnetwork/drivers/bridge/bridge_store.go b/libnetwork/drivers/bridge/bridge_store.go index 46544723aa..2f13fafcba 100644 --- a/libnetwork/drivers/bridge/bridge_store.go +++ b/libnetwork/drivers/bridge/bridge_store.go @@ -50,7 +50,7 @@ func (d *driver) initStore(option map[string]interface{}) error { } func (d *driver) populateNetworks() error { - kvol, err := d.store.List(datastore.Key(bridgePrefix), &networkConfiguration{}) + kvol, err := d.store.List(&networkConfiguration{}) if err != nil && err != datastore.ErrKeyNotFound { return fmt.Errorf("failed to get bridge network configurations from store: %v", err) } @@ -72,7 +72,7 @@ func (d *driver) populateNetworks() error { } func (d *driver) populateEndpoints() error { - kvol, err := d.store.List(datastore.Key(bridgeEndpointPrefix), &bridgeEndpoint{}) + kvol, err := d.store.List(&bridgeEndpoint{}) if err != nil && err != datastore.ErrKeyNotFound { return fmt.Errorf("failed to get bridge endpoints from store: %v", err) } diff --git a/libnetwork/drivers/ipvlan/ipvlan_store.go b/libnetwork/drivers/ipvlan/ipvlan_store.go index e025e2a1cf..068f10edec 100644 --- a/libnetwork/drivers/ipvlan/ipvlan_store.go +++ b/libnetwork/drivers/ipvlan/ipvlan_store.go @@ -69,7 +69,7 @@ func (d *driver) initStore(option map[string]interface{}) error { // populateNetworks is invoked at driver init to recreate persistently stored networks func (d *driver) populateNetworks() error { - kvol, err := d.store.List(datastore.Key(ipvlanNetworkPrefix), &configuration{}) + kvol, err := d.store.List(&configuration{}) if err != nil && err != datastore.ErrKeyNotFound { return fmt.Errorf("failed to get ipvlan network configurations from store: %v", err) } @@ -88,7 +88,7 @@ func (d *driver) populateNetworks() error { } func (d *driver) populateEndpoints() error { - kvol, err := d.store.List(datastore.Key(ipvlanEndpointPrefix), &endpoint{}) + kvol, err := d.store.List(&endpoint{}) if err != nil && err != datastore.ErrKeyNotFound { return fmt.Errorf("failed to get ipvlan endpoints from store: %v", err) } diff --git a/libnetwork/drivers/macvlan/macvlan_store.go b/libnetwork/drivers/macvlan/macvlan_store.go index 7cb1ebb7d2..3b84559126 100644 --- a/libnetwork/drivers/macvlan/macvlan_store.go +++ b/libnetwork/drivers/macvlan/macvlan_store.go @@ -68,7 +68,7 @@ func (d *driver) initStore(option map[string]interface{}) error { // populateNetworks is invoked at driver init to recreate persistently stored networks func (d *driver) populateNetworks() error { - kvol, err := d.store.List(datastore.Key(macvlanPrefix), &configuration{}) + kvol, err := d.store.List(&configuration{}) if err != nil && err != datastore.ErrKeyNotFound { return fmt.Errorf("failed to get macvlan network configurations from store: %v", err) } @@ -87,7 +87,7 @@ func (d *driver) populateNetworks() error { } func (d *driver) populateEndpoints() error { - kvol, err := d.store.List(datastore.Key(macvlanEndpointPrefix), &endpoint{}) + kvol, err := d.store.List(&endpoint{}) if err != nil && err != datastore.ErrKeyNotFound { return fmt.Errorf("failed to get macvlan endpoints from store: %v", err) } diff --git a/libnetwork/drivers/windows/windows_store.go b/libnetwork/drivers/windows/windows_store.go index 594ff71f90..7a43db7140 100644 --- a/libnetwork/drivers/windows/windows_store.go +++ b/libnetwork/drivers/windows/windows_store.go @@ -47,7 +47,7 @@ func (d *driver) initStore(option map[string]interface{}) error { } func (d *driver) populateNetworks() error { - kvol, err := d.store.List(datastore.Key(windowsPrefix), &networkConfiguration{Type: d.name}) + kvol, err := d.store.List(&networkConfiguration{Type: d.name}) if err != nil && err != datastore.ErrKeyNotFound { return fmt.Errorf("failed to get windows network configurations from store: %v", err) } @@ -70,7 +70,7 @@ func (d *driver) populateNetworks() error { } func (d *driver) populateEndpoints() error { - kvol, err := d.store.List(datastore.Key(windowsEndpointPrefix), &hnsEndpoint{Type: d.name}) + kvol, err := d.store.List(&hnsEndpoint{Type: d.name}) if err != nil && err != datastore.ErrKeyNotFound { return fmt.Errorf("failed to get endpoints from store: %v", err) } diff --git a/libnetwork/sandbox_store.go b/libnetwork/sandbox_store.go index a940ffda85..4993481c3d 100644 --- a/libnetwork/sandbox_store.go +++ b/libnetwork/sandbox_store.go @@ -174,7 +174,7 @@ func (c *Controller) sandboxCleanup(activeSandboxes map[string]interface{}) erro return fmt.Errorf("could not find local scope store") } - sandboxStates, err := store.List(datastore.Key(sandboxPrefix), &sbState{c: c}) + sandboxStates, err := store.List(&sbState{c: c}) if err != nil { if err == datastore.ErrKeyNotFound { // It's normal for no sandboxes to be found. Just bail out. diff --git a/libnetwork/store.go b/libnetwork/store.go index e36eb451ab..6f5511fb88 100644 --- a/libnetwork/store.go +++ b/libnetwork/store.go @@ -50,8 +50,7 @@ func (c *Controller) getNetworks() ([]*Network, error) { return nil, nil } - kvol, err := store.List(datastore.Key(datastore.NetworkKeyPrefix), - &Network{ctrlr: c}) + kvol, err := store.List(&Network{ctrlr: c}) if err != nil && err != datastore.ErrKeyNotFound { return nil, fmt.Errorf("failed to get networks: %w", err) } @@ -81,7 +80,7 @@ func (c *Controller) getNetworksFromStore(ctx context.Context) []*Network { // F var nl []*Network store := c.getStore() - kvol, err := store.List(datastore.Key(datastore.NetworkKeyPrefix), &Network{ctrlr: c}) + kvol, err := store.List(&Network{ctrlr: c}) if err != nil { if err != datastore.ErrKeyNotFound { log.G(ctx).Debugf("failed to get networks from store: %v", err) @@ -128,9 +127,8 @@ func (n *Network) getEndpointFromStore(eid string) (*Endpoint, error) { func (n *Network) getEndpointsFromStore() ([]*Endpoint, error) { var epl []*Endpoint - tmp := Endpoint{network: n} store := n.getController().getStore() - kvol, err := store.List(datastore.Key(tmp.KeyPrefix()...), &Endpoint{network: n}) + kvol, err := store.List(&Endpoint{network: n}) if err != nil { if err != datastore.ErrKeyNotFound { return nil, fmt.Errorf("failed to get endpoints for network %s: %w",