From b3566324c64bf714b80432ce7ab6a5205071df78 Mon Sep 17 00:00:00 2001 From: Duncan Harvey Date: Wed, 22 Nov 2023 14:25:28 -0500 Subject: [PATCH] [SVLS-4183] Movies setup into run function for serverless-init --- cmd/serverless-init/main.go | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/cmd/serverless-init/main.go b/cmd/serverless-init/main.go index 0a56b3aae3705..f0e9cbaa958bb 100644 --- a/cmd/serverless-init/main.go +++ b/cmd/serverless-init/main.go @@ -38,36 +38,26 @@ const ( loggerName = "SERVERLESS_INIT" ) -type params struct { - cloudService cloudservice.CloudService - logConfig *log.Config - traceAgent *trace.ServerlessTraceAgent - metricAgent *metrics.ServerlessMetricAgent - logsAgent logsAgent.ServerlessLogsAgent - args []string +type cliParams struct { + args []string } func main() { if len(os.Args) < 2 { panic("[datadog init process] invalid argument count, did you forget to set CMD ?") } else { - cloudService, logConfig, traceAgent, metricAgent, logsAgent := setup() - - params := ¶ms{ - cloudService: cloudService, - logConfig: logConfig, - traceAgent: traceAgent, - metricAgent: metricAgent, - logsAgent: logsAgent, - args: os.Args[1:], + + cliParams := &cliParams{ + args: os.Args[1:], } - fxutil.OneShot(run, fx.Supply(params)) + fxutil.OneShot(run, fx.Supply(cliParams)) } } -func run(params *params) { - initcontainer.Run(params.cloudService, params.logConfig, params.metricAgent, params.traceAgent, params.logsAgent, params.args) +func run(cliParams *cliParams) { + cloudService, logConfig, traceAgent, metricAgent, logsAgent := setup() + initcontainer.Run(cloudService, logConfig, metricAgent, traceAgent, logsAgent, cliParams.args) } func setup() (cloudservice.CloudService, *log.Config, *trace.ServerlessTraceAgent, *metrics.ServerlessMetricAgent, logsAgent.ServerlessLogsAgent) {