state: use index constants for ConfigEntry indexes

This commit is contained in:
Daniel Nephin 2021-04-15 13:26:53 -04:00
parent 8293eedace
commit eb7f4b7ea4
2 changed files with 4 additions and 5 deletions

View File

@ -16,7 +16,6 @@ type ConfigEntryLinkIndex struct {
} }
type discoveryChainConfigEntry interface { type discoveryChainConfigEntry interface {
structs.ConfigEntry
// ListRelatedServices returns a list of other names of services referenced // ListRelatedServices returns a list of other names of services referenced
// in this config entry. // in this config entry.
ListRelatedServices() []structs.ServiceID ListRelatedServices() []structs.ServiceID
@ -426,7 +425,7 @@ func (s *Store) discoveryChainSourcesTxn(tx ReadTxn, ws memdb.WatchSet, dc strin
queue := []structs.ServiceName{destination} queue := []structs.ServiceName{destination}
for len(queue) > 0 { for len(queue) > 0 {
// The "link" index returns config entries that reference a service // The "link" index returns config entries that reference a service
iter, err := tx.Get(tableConfigEntries, "link", queue[0].ToServiceID()) iter, err := tx.Get(tableConfigEntries, indexLink, queue[0].ToServiceID())
if err != nil { if err != nil {
return 0, nil, err return 0, nil, err
} }
@ -598,7 +597,7 @@ func validateProposedConfigEntryInServiceGraph(
sid := structs.NewServiceID(name, entMeta) sid := structs.NewServiceID(name, entMeta)
checkChains[sid] = struct{}{} checkChains[sid] = struct{}{}
iter, err := tx.Get(tableConfigEntries, "link", sid) iter, err := tx.Get(tableConfigEntries, indexLink, sid)
if err != nil { if err != nil {
return err return err
} }

View File

@ -150,7 +150,7 @@ func configIntentionGetTxn(tx ReadTxn, ws memdb.WatchSet, id string) (uint64, *s
idx = 1 idx = 1
} }
watchCh, existing, err := tx.FirstWatch(tableConfigEntries, "intention-legacy-id", id) watchCh, existing, err := tx.FirstWatch(tableConfigEntries, indexIntentionLegacyID, id)
if err != nil { if err != nil {
return 0, nil, nil, fmt.Errorf("failed config entry lookup: %s", err) return 0, nil, nil, fmt.Errorf("failed config entry lookup: %s", err)
} }
@ -265,7 +265,7 @@ func readSourceIntentionsFromConfigEntriesTxn(tx ReadTxn, ws memdb.WatchSet, ser
func readSourceIntentionsFromConfigEntriesForServiceTxn(tx ReadTxn, ws memdb.WatchSet, serviceName string, entMeta *structs.EnterpriseMeta, results structs.Intentions) (structs.Intentions, error) { func readSourceIntentionsFromConfigEntriesForServiceTxn(tx ReadTxn, ws memdb.WatchSet, serviceName string, entMeta *structs.EnterpriseMeta, results structs.Intentions) (structs.Intentions, error) {
sn := structs.NewServiceName(serviceName, entMeta) sn := structs.NewServiceName(serviceName, entMeta)
iter, err := tx.Get(tableConfigEntries, "intention-source", sn) iter, err := tx.Get(tableConfigEntries, indexSource, sn)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed config entry lookup: %s", err) return nil, fmt.Errorf("failed config entry lookup: %s", err)
} }