From af215780397863a8f009c4313535c953955ebcc4 Mon Sep 17 00:00:00 2001 From: Dhia Ayachi Date: Wed, 15 Sep 2021 10:24:04 -0400 Subject: [PATCH] use const instead of literals for `tableIndex` (#11039) --- agent/consul/state/acl.go | 2 +- agent/consul/state/acl_oss.go | 2 +- agent/consul/state/system_metadata.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/agent/consul/state/acl.go b/agent/consul/state/acl.go index 46a2cba454..b8e4370e09 100644 --- a/agent/consul/state/acl.go +++ b/agent/consul/state/acl.go @@ -12,7 +12,7 @@ import ( // ACLTokens is used when saving a snapshot func (s *Snapshot) ACLTokens() (memdb.ResultIterator, error) { - iter, err := s.tx.Get(tableACLTokens, "id") + iter, err := s.tx.Get(tableACLTokens, indexID) if err != nil { return nil, err } diff --git a/agent/consul/state/acl_oss.go b/agent/consul/state/acl_oss.go index 4db7897364..05a45b33bd 100644 --- a/agent/consul/state/acl_oss.go +++ b/agent/consul/state/acl_oss.go @@ -75,7 +75,7 @@ func aclTokenGetFromIndex(tx ReadTxn, id string, index string, entMeta *structs. } 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) { diff --git a/agent/consul/state/system_metadata.go b/agent/consul/state/system_metadata.go index c0c9c24f0e..029ab8898b 100644 --- a/agent/consul/state/system_metadata.go +++ b/agent/consul/state/system_metadata.go @@ -98,7 +98,7 @@ func systemMetadataSetTxn(tx WriteTxn, idx uint64, entry *structs.SystemMetadata if err := tx.Insert(tableSystemMetadata, entry); err != nil { 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) } @@ -184,7 +184,7 @@ func systemMetadataDeleteTxn(tx WriteTxn, idx uint64, key string) error { if err := tx.Delete(tableSystemMetadata, existing); err != nil { 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 nil