From c44f87775856083c2acaff324ca7b0525b23dd24 Mon Sep 17 00:00:00 2001 From: Chris Piraino Date: Thu, 30 Apr 2020 09:32:09 -0500 Subject: [PATCH] Comment why it is ok to expect upstreams slice to not be empty --- agent/xds/listeners.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/agent/xds/listeners.go b/agent/xds/listeners.go index f39895b712..fabd94f916 100644 --- a/agent/xds/listeners.go +++ b/agent/xds/listeners.go @@ -272,6 +272,9 @@ func (s *Server) listenersFromSnapshotIngressGateway(cfgSnap *proxycfg.ConfigSna var resources []proto.Message for listenerKey, upstreams := range cfgSnap.IngressGateway.Upstreams { if listenerKey.Protocol == "tcp" { + // We rely on the invariant of upstreams slice always having at least 1 + // member, because this key/value pair is created only when a + // GatewayService is returned in the RPC u := upstreams[0] id := u.Identifier()