state: use index constants for ConfigEntry indexes

This commit is contained in:
Daniel Nephin 2021-04-15 13:26:53 -04:00
parent 131599bfab
commit 653f41ce41
2 changed files with 4 additions and 5 deletions

View File

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

View File

@ -150,7 +150,7 @@ func configIntentionGetTxn(tx ReadTxn, ws memdb.WatchSet, id string) (uint64, *s
idx = 1
}
watchCh, existing, err := tx.FirstWatch(tableConfigEntries, "intention-legacy-id", id)
watchCh, existing, err := tx.FirstWatch(tableConfigEntries, indexIntentionLegacyID, id)
if err != nil {
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) {
sn := structs.NewServiceName(serviceName, entMeta)
iter, err := tx.Get(tableConfigEntries, "intention-source", sn)
iter, err := tx.Get(tableConfigEntries, indexSource, sn)
if err != nil {
return nil, fmt.Errorf("failed config entry lookup: %s", err)
}