use const instead of literals for `tableIndex` (#11039)

This commit is contained in:
Dhia Ayachi 2021-09-15 10:24:04 -04:00 committed by GitHub
parent ffe3806aaf
commit 25ea1a9276
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -12,7 +12,7 @@ import (
// ACLTokens is used when saving a snapshot // ACLTokens is used when saving a snapshot
func (s *Snapshot) ACLTokens() (memdb.ResultIterator, error) { func (s *Snapshot) ACLTokens() (memdb.ResultIterator, error) {
iter, err := s.tx.Get(tableACLTokens, "id") iter, err := s.tx.Get(tableACLTokens, indexID)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -75,7 +75,7 @@ func aclTokenGetFromIndex(tx ReadTxn, id string, index string, entMeta *structs.
} }
func aclTokenListAll(tx ReadTxn, _ *structs.EnterpriseMeta) (memdb.ResultIterator, error) { func aclTokenListAll(tx ReadTxn, _ *structs.EnterpriseMeta) (memdb.ResultIterator, error) {
return tx.Get(tableACLTokens, "id") return tx.Get(tableACLTokens, indexID)
} }
func aclTokenListByPolicy(tx ReadTxn, policy string, _ *structs.EnterpriseMeta) (memdb.ResultIterator, error) { func aclTokenListByPolicy(tx ReadTxn, policy string, _ *structs.EnterpriseMeta) (memdb.ResultIterator, error) {

View File

@ -98,7 +98,7 @@ func systemMetadataSetTxn(tx WriteTxn, idx uint64, entry *structs.SystemMetadata
if err := tx.Insert(tableSystemMetadata, entry); err != nil { if err := tx.Insert(tableSystemMetadata, entry); err != nil {
return fmt.Errorf("failed inserting system metadata: %s", err) return fmt.Errorf("failed inserting system metadata: %s", err)
} }
if err := tx.Insert("index", &IndexEntry{tableSystemMetadata, idx}); err != nil { if err := tx.Insert(tableIndex, &IndexEntry{tableSystemMetadata, idx}); err != nil {
return fmt.Errorf("failed updating index: %v", err) return fmt.Errorf("failed updating index: %v", err)
} }
@ -184,7 +184,7 @@ func systemMetadataDeleteTxn(tx WriteTxn, idx uint64, key string) error {
if err := tx.Delete(tableSystemMetadata, existing); err != nil { if err := tx.Delete(tableSystemMetadata, existing); err != nil {
return fmt.Errorf("failed removing system metadata: %s", err) return fmt.Errorf("failed removing system metadata: %s", err)
} }
if err := tx.Insert("index", &IndexEntry{tableSystemMetadata, idx}); err != nil { if err := tx.Insert(tableIndex, &IndexEntry{tableSystemMetadata, idx}); err != nil {
return fmt.Errorf("failed updating index: %s", err) return fmt.Errorf("failed updating index: %s", err)
} }
return nil return nil