Skip to content

Commit

Permalink
[SVLS-4183] Movies setup into run function for serverless-init
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanpharvey committed Nov 22, 2023
1 parent 18e0d81 commit b356632
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions cmd/serverless-init/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 := &params{
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) {
Expand Down

0 comments on commit b356632

Please sign in to comment.