libnetwork/datastore: drop (*Store).Scope() method

It unconditionally returned scope.Local.

Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
Cory Snider 2023-10-19 11:56:32 -04:00
parent 4b40d82233
commit 4f4a897dda
4 changed files with 7 additions and 14 deletions

View file

@ -9,7 +9,6 @@ import (
"github.com/docker/docker/libnetwork/discoverapi"
store "github.com/docker/docker/libnetwork/internal/kvstore"
"github.com/docker/docker/libnetwork/internal/kvstore/boltdb"
"github.com/docker/docker/libnetwork/scope"
"github.com/docker/docker/libnetwork/types"
)
@ -21,7 +20,6 @@ var (
type Store struct {
mu sync.Mutex
scope string
store store.Store
cache *cache
}
@ -139,7 +137,7 @@ func newClient(kv string, addr string, config *store.Config) (*Store, error) {
return nil, err
}
return &Store{scope: scope.Local, store: s, cache: newCache(s)}, nil
return &Store{store: s, cache: newCache(s)}, nil
}
// New creates a new Store instance.
@ -182,11 +180,6 @@ func (ds *Store) Close() {
ds.store.Close()
}
// Scope returns the scope of the store.
func (ds *Store) Scope() string {
return ds.scope
}
// PutObjectAtomic provides an atomic add and update operation for a Record.
func (ds *Store) PutObjectAtomic(kvObject KVObject) error {
ds.mu.Lock()

View file

@ -15,7 +15,7 @@ const dummyKey = "dummy"
// NewTestDataStore can be used by other Tests in order to use custom datastore
func NewTestDataStore() *Store {
s := NewMockStore()
return &Store{scope: scope.Local, store: s, cache: newCache(s)}
return &Store{store: s, cache: newCache(s)}
}
func TestKey(t *testing.T) {

View file

@ -184,7 +184,7 @@ func (c *Controller) sandboxCleanup(activeSandboxes map[string]interface{}) erro
// It's normal for no sandboxes to be found. Just bail out.
return nil
}
return fmt.Errorf("failed to get sandboxes for scope %s: %v", store.Scope(), err)
return fmt.Errorf("failed to get sandboxes: %v", err)
}
for _, s := range sandboxStates {

View file

@ -70,7 +70,7 @@ func (c *Controller) getNetworks() ([]*Network, error) {
n.epCnt = ec
if n.scope == "" {
n.scope = store.Scope()
n.scope = scope.Local
}
nl = append(nl, n)
}
@ -107,7 +107,7 @@ func (c *Controller) getNetworksFromStore() []*Network { // FIXME: unify with c.
n.epCnt = ec
}
if n.scope == "" {
n.scope = store.Scope()
n.scope = scope.Local
}
n.mu.Unlock()
nl = append(nl, n)
@ -134,8 +134,8 @@ func (n *Network) getEndpointsFromStore() ([]*Endpoint, error) {
kvol, err := store.List(datastore.Key(tmp.KeyPrefix()...), &Endpoint{network: n})
if err != nil {
if err != datastore.ErrKeyNotFound {
return nil, fmt.Errorf("failed to get endpoints for network %s scope %s: %w",
n.Name(), store.Scope(), err)
return nil, fmt.Errorf("failed to get endpoints for network %s: %w",
n.Name(), err)
}
return nil, nil
}