From 7aff3513c29b21ca0748b1d483c9ce0e2ff6975d Mon Sep 17 00:00:00 2001 From: Amogh Rathore Date: Sat, 29 Apr 2023 00:03:43 +0000 Subject: [PATCH] Sync vendor and use WithHandler function --- agent/handlers/task_server_setup.go | 2 +- .../aws/amazon-ecs-agent/ecs-agent/tmds/server.go | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/agent/handlers/task_server_setup.go b/agent/handlers/task_server_setup.go index 3ad6d3f8d70..672d2de0983 100644 --- a/agent/handlers/task_server_setup.go +++ b/agent/handlers/task_server_setup.go @@ -79,7 +79,7 @@ func taskServerSetup(credentialsManager credentials.Manager, agentAPIV1HandlersSetup(muxRouter, state, credentialsManager, cluster, region, apiEndpoint, acceptInsecureCert) return tmds.NewServer(auditLogger, - tmds.WithRouter(muxRouter), + tmds.WithHandler(muxRouter), tmds.WithListenAddress(tmds.AddressIPv4()), tmds.WithReadTimeout(readTimeout), tmds.WithWriteTimeout(writeTimeout), diff --git a/agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/tmds/server.go b/agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/tmds/server.go index fa3de539a04..197c3307c1a 100644 --- a/agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/tmds/server.go +++ b/agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/tmds/server.go @@ -45,7 +45,7 @@ type Config struct { writeTimeout time.Duration // http server write timeout steadyStateRate float64 // steady request rate limit burstRate int // burst request rate limit - router *mux.Router // router with routes configured + handler http.Handler // HTTP handler with routes configured } // Function type for updating TMDS config @@ -86,10 +86,10 @@ func WithBurstRate(burstRate int) ConfigOpt { } } -// Set TMDS router -func WithRouter(router *mux.Router) ConfigOpt { +// Set TMDS handler +func WithHandler(handler http.Handler) ConfigOpt { return func(c *Config) { - c.router = router + c.handler = handler } } @@ -104,8 +104,8 @@ func NewServer(auditLogger audit.AuditLogger, options ...ConfigOpt) (*http.Serve } func setup(auditLogger audit.AuditLogger, config *Config) (*http.Server, error) { - if config.router == nil { - return nil, errors.New("router cannot be nil") + if config.handler == nil { + return nil, errors.New("handler cannot be nil") } // Define a reqeuest rate limiter @@ -120,7 +120,7 @@ func setup(auditLogger audit.AuditLogger, config *Config) (*http.Server, error) // rootPath is a path for any traffic to this endpoint rootPath := "/" + muxutils.ConstructMuxVar("root", muxutils.AnythingRegEx) loggingMuxRouter.Handle(rootPath, tollbooth.LimitHandler( - limiter, logging.NewLoggingHandler(config.router))) + limiter, logging.NewLoggingHandler(config.handler))) // explicitly enable path cleaning loggingMuxRouter.SkipClean(false)