From 25ea1a9276e03cc7f25e44fa16f6a00c401b36fd 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 46a2cba45..b8e4370e0 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 4db789736..05a45b33b 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 c0c9c24f0..029ab8898 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