multi: rename ActionsDB to ActionsListDB

To better represent the interface and to free up the use of the
ActionsDB name as this will be used to represent the full Actions DB in
an upcoming commit.
This commit is contained in:
Elle Mouton 2025-04-19 14:02:04 +02:00
parent 412b4f038e
commit b4aadaa4bd
No known key found for this signature in database
GPG key ID: D7D916376026F177
5 changed files with 19 additions and 19 deletions

View file

@ -109,10 +109,10 @@ type RuleAction struct {
PerformedAt time.Time
}
// ActionsDB represents a DB backend that contains Action entries that can
// ActionsListDB represents a DB backend that contains Action entries that can
// be queried. It allows us to abstract away the details of the data storage
// method.
type ActionsDB interface {
type ActionsListDB interface {
// ListActions returns a list of past Action items.
ListActions(ctx context.Context) ([]*RuleAction, error)
}
@ -120,8 +120,8 @@ type ActionsDB interface {
// ActionsReadDB is an abstraction gives a caller access to either a group
// specific or group and feature specific rules.ActionDB.
type ActionsReadDB interface {
GroupActionsDB() ActionsDB
GroupFeatureActionsDB() ActionsDB
GroupActionsDB() ActionsListDB
GroupFeatureActionsDB() ActionsListDB
}
// ActionReadDBGetter represents a function that can be used to construct
@ -150,25 +150,25 @@ type allActionsReadDB struct {
var _ ActionsReadDB = (*allActionsReadDB)(nil)
// GroupActionsDB returns a rules.ActionsDB that will give the caller access
// GroupActionsDB returns a rules.ActionsListDB that will give the caller access
// to all of a groups Actions.
func (a *allActionsReadDB) GroupActionsDB() ActionsDB {
func (a *allActionsReadDB) GroupActionsDB() ActionsListDB {
return &groupActionsReadDB{a}
}
// GroupFeatureActionsDB returns a rules.ActionsDB that will give the caller
// GroupFeatureActionsDB returns a rules.ActionsListDB that will give the caller
// access to only a specific features Actions in a specific group.
func (a *allActionsReadDB) GroupFeatureActionsDB() ActionsDB {
func (a *allActionsReadDB) GroupFeatureActionsDB() ActionsListDB {
return &groupFeatureActionsReadDB{a}
}
// groupActionsReadDB is an implementation of the rules.ActionsDB that will
// groupActionsReadDB is an implementation of the rules.ActionsListDB that will
// provide read access to all the Actions of a particular group.
type groupActionsReadDB struct {
*allActionsReadDB
}
var _ ActionsDB = (*groupActionsReadDB)(nil)
var _ ActionsListDB = (*groupActionsReadDB)(nil)
// ListActions will return all the Actions for a particular group.
func (s *groupActionsReadDB) ListActions(ctx context.Context) ([]*RuleAction,
@ -191,14 +191,14 @@ func (s *groupActionsReadDB) ListActions(ctx context.Context) ([]*RuleAction,
return actions, nil
}
// groupFeatureActionsReadDB is an implementation of the rules.ActionsDB that
// groupFeatureActionsReadDB is an implementation of the rules.ActionsListDB that
// will provide read access to all the Actions of a feature within a particular
// group.
type groupFeatureActionsReadDB struct {
*allActionsReadDB
}
var _ ActionsDB = (*groupFeatureActionsReadDB)(nil)
var _ ActionsListDB = (*groupFeatureActionsReadDB)(nil)
// ListActions will return all the Actions for a particular group that were
// executed by a particular feature.

View file

@ -39,7 +39,7 @@ var (
}
)
// TestActionStorage tests that the ActionsDB CRUD logic.
// TestActionStorage tests that the ActionsListDB CRUD logic.
func TestActionStorage(t *testing.T) {
tmpDir := t.TempDir()

View file

@ -16,7 +16,7 @@ type Config interface {
// GetActionsDB can be used by rules to list any past actions that were
// made for the specific session or feature.
GetActionsDB() firewalldb.ActionsDB
GetActionsDB() firewalldb.ActionsListDB
// GetMethodPerms returns a map that contains URIs and the permissions
// required to use them.
@ -48,7 +48,7 @@ type ConfigImpl struct {
// ActionsDB can be used by rules to list any past actions that were
// made for the specific session or feature.
ActionsDB firewalldb.ActionsDB
ActionsDB firewalldb.ActionsListDB
// MethodPerms is a function that can be used to fetch the permissions
// required for a URI.
@ -76,7 +76,7 @@ func (c *ConfigImpl) GetStores() firewalldb.KVStores {
}
// GetActionsDB returns the list of past actions.
func (c *ConfigImpl) GetActionsDB() firewalldb.ActionsDB {
func (c *ConfigImpl) GetActionsDB() firewalldb.ActionsListDB {
return c.ActionsDB
}

View file

@ -87,7 +87,7 @@ func (r *RateLimitMgr) EmptyValue() Values {
// rateLimitConfig is the config required by RateLimitMgr. It can be derived
// from the main rules Config struct.
type rateLimitConfig interface {
GetActionsDB() firewalldb.ActionsDB
GetActionsDB() firewalldb.ActionsListDB
GetMethodPerms() func(string) ([]bakery.Op, bool)
}

View file

@ -216,7 +216,7 @@ type mockRateLimitCfg struct {
var _ rateLimitConfig = (*mockRateLimitCfg)(nil)
func (m *mockRateLimitCfg) GetActionsDB() firewalldb.ActionsDB {
func (m *mockRateLimitCfg) GetActionsDB() firewalldb.ActionsListDB {
return m.db
}
@ -233,7 +233,7 @@ type mockActionsDB struct {
actions []*firewalldb.RuleAction
}
var _ firewalldb.ActionsDB = (*mockActionsDB)(nil)
var _ firewalldb.ActionsListDB = (*mockActionsDB)(nil)
func (m *mockActionsDB) addAction(uri string, timestamp time.Time) {
m.actions = append(m.actions, &firewalldb.RuleAction{