xds: remove Server.Initialize

Requiring a call to initialize to set a single field is not really substantially different
from having to set that field to a value.
This commit is contained in:
Daniel Nephin 2020-12-23 13:08:23 -05:00
parent 2e2ee41390
commit 4b8b2a4291
3 changed files with 6 additions and 18 deletions

View File

@ -650,13 +650,13 @@ func (a *Agent) listenAndServeGRPC() error {
} }
xdsServer := &xds.Server{ xdsServer := &xds.Server{
Logger: a.logger.Named(logging.Envoy), Logger: a.logger.Named(logging.Envoy),
CfgMgr: a.proxyConfig, CfgMgr: a.proxyConfig,
ResolveToken: a.resolveToken, ResolveToken: a.resolveToken,
CheckFetcher: a, CheckFetcher: a,
CfgFetcher: a, CfgFetcher: a,
AuthCheckFrequency: xds.DefaultAuthCheckFrequency,
} }
xdsServer.Initialize()
var err error var err error
if a.config.HTTPSPort > 0 { if a.config.HTTPSPort > 0 {

View File

@ -125,13 +125,6 @@ type Server struct {
CfgFetcher ConfigFetcher CfgFetcher ConfigFetcher
} }
// Initialize will finish configuring the Server for first use.
func (s *Server) Initialize() {
if s.AuthCheckFrequency == 0 {
s.AuthCheckFrequency = DefaultAuthCheckFrequency
}
}
// StreamAggregatedResources implements // StreamAggregatedResources implements
// envoydisco.AggregatedDiscoveryServiceServer. This is the ADS endpoint which is // envoydisco.AggregatedDiscoveryServiceServer. This is the ADS endpoint which is
// the only xDS API we directly support for now. // the only xDS API we directly support for now.

View File

@ -102,7 +102,6 @@ func TestServer_StreamAggregatedResources_BasicProtocol(t *testing.T) {
CfgMgr: mgr, CfgMgr: mgr,
ResolveToken: aclResolve, ResolveToken: aclResolve,
} }
s.Initialize()
sid := structs.NewServiceID("web-sidecar-proxy", nil) sid := structs.NewServiceID("web-sidecar-proxy", nil)
@ -454,7 +453,6 @@ func TestServer_StreamAggregatedResources_ACLEnforcement(t *testing.T) {
CfgMgr: mgr, CfgMgr: mgr,
ResolveToken: aclResolve, ResolveToken: aclResolve,
} }
s.Initialize()
errCh := make(chan error, 1) errCh := make(chan error, 1)
go func() { go func() {
@ -528,7 +526,6 @@ func TestServer_StreamAggregatedResources_ACLTokenDeleted_StreamTerminatedDuring
ResolveToken: aclResolve, ResolveToken: aclResolve,
AuthCheckFrequency: 1 * time.Hour, // make sure this doesn't kick in AuthCheckFrequency: 1 * time.Hour, // make sure this doesn't kick in
} }
s.Initialize()
errCh := make(chan error, 1) errCh := make(chan error, 1)
go func() { go func() {
@ -622,7 +619,6 @@ func TestServer_StreamAggregatedResources_ACLTokenDeleted_StreamTerminatedInBack
ResolveToken: aclResolve, ResolveToken: aclResolve,
AuthCheckFrequency: 100 * time.Millisecond, // Make this short. AuthCheckFrequency: 100 * time.Millisecond, // Make this short.
} }
s.Initialize()
errCh := make(chan error, 1) errCh := make(chan error, 1)
go func() { go func() {
@ -707,7 +703,6 @@ func TestServer_StreamAggregatedResources_IngressEmptyResponse(t *testing.T) {
CfgMgr: mgr, CfgMgr: mgr,
ResolveToken: aclResolve, ResolveToken: aclResolve,
} }
s.Initialize()
sid := structs.NewServiceID("ingress-gateway", nil) sid := structs.NewServiceID("ingress-gateway", nil)