From 74c0543ef2442ca243ac88f028cf7f8274c07244 Mon Sep 17 00:00:00 2001 From: Chris Piraino Date: Mon, 11 May 2020 14:04:59 -0500 Subject: [PATCH] PR comment and better formatting --- agent/consul/state/catalog.go | 21 +++++++++++++++++++-- agent/consul/state/catalog_test.go | 1 - 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/agent/consul/state/catalog.go b/agent/consul/state/catalog.go index 36912dfbfc..9b8dc39755 100644 --- a/agent/consul/state/catalog.go +++ b/agent/consul/state/catalog.go @@ -2524,7 +2524,15 @@ func (s *Store) updateGatewayServices(tx *memdb.Txn, idx uint64, conf structs.Co return nil } -func (s *Store) ingressConfigGatewayServices(tx *memdb.Txn, gateway structs.ServiceID, conf structs.ConfigEntry, entMeta *structs.EnterpriseMeta) (bool, structs.GatewayServices, error) { +// ingressConfigGatewayServices constructs a list of GatewayService structs for +// insertion into the memdb table, specific to ingress gateways. The boolean +// returned indicates that there are no changes necessary to the memdb table. +func (s *Store) ingressConfigGatewayServices( + tx *memdb.Txn, + gateway structs.ServiceID, + conf structs.ConfigEntry, + entMeta *structs.EnterpriseMeta, +) (bool, structs.GatewayServices, error) { entry, ok := conf.(*structs.IngressGatewayConfigEntry) if !ok { return false, nil, fmt.Errorf("unexpected config entry type: %T", conf) @@ -2560,7 +2568,16 @@ func (s *Store) ingressConfigGatewayServices(tx *memdb.Txn, gateway structs.Serv return false, gatewayServices, nil } -func (s *Store) terminatingConfigGatewayServices(tx *memdb.Txn, gateway structs.ServiceID, conf structs.ConfigEntry, entMeta *structs.EnterpriseMeta) (bool, structs.GatewayServices, error) { +// terminatingConfigGatewayServices constructs a list of GatewayService structs +// for insertion into the memdb table, specific to terminating gateways. The +// boolean returned indicates that there are no changes necessary to the memdb +// table. +func (s *Store) terminatingConfigGatewayServices( + tx *memdb.Txn, + gateway structs.ServiceID, + conf structs.ConfigEntry, + entMeta *structs.EnterpriseMeta, +) (bool, structs.GatewayServices, error) { entry, ok := conf.(*structs.TerminatingGatewayConfigEntry) if !ok { return false, nil, fmt.Errorf("unexpected config entry type: %T", conf) diff --git a/agent/consul/state/catalog_test.go b/agent/consul/state/catalog_test.go index 0067911c57..c5e14d1f74 100644 --- a/agent/consul/state/catalog_test.go +++ b/agent/consul/state/catalog_test.go @@ -4545,7 +4545,6 @@ func TestStateStore_GatewayServices_Terminating(t *testing.T) { }, nil)) assert.False(t, watchFired(ws)) - ws = memdb.NewWatchSet() idx, out, err = s.GatewayServices(ws, "gateway", nil) assert.Nil(t, err) assert.Equal(t, idx, uint64(21))