From 2b47cc00af6db9c74e27ba186b9ca75a728efac7 Mon Sep 17 00:00:00 2001 From: Evan Van Dam Date: Wed, 6 Sep 2023 09:55:26 -0700 Subject: [PATCH] pass multiple envfiles in start command --- cmd/commandfuncs.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go index 87e09b3e31b..8963988616e 100644 --- a/cmd/commandfuncs.go +++ b/cmd/commandfuncs.go @@ -46,7 +46,14 @@ func cmdStart(fl Flags) (int, error) { startCmdConfigAdapterFlag := fl.String("adapter") startCmdPidfileFlag := fl.String("pidfile") startCmdWatchFlag := fl.Bool("watch") - startCmdEnvfileFlag := fl.String("envfile") + + var err error + var startCmdEnvfileFlag []string + startCmdEnvfileFlag, err = fl.GetStringSlice("envfile") + if err != nil { + return caddy.ExitCodeFailedStartup, + fmt.Errorf("reading envfile flag: %v", err) + } // open a listener to which the child process will connect when // it is ready to confirm that it has successfully started @@ -70,8 +77,9 @@ func cmdStart(fl Flags) (int, error) { if startCmdConfigFlag != "" { cmd.Args = append(cmd.Args, "--config", startCmdConfigFlag) } - if startCmdEnvfileFlag != "" { - cmd.Args = append(cmd.Args, "--envfile", startCmdEnvfileFlag) + + for _, envFile := range startCmdEnvfileFlag { + cmd.Args = append(cmd.Args, "--envfile", envFile) } if startCmdConfigAdapterFlag != "" { cmd.Args = append(cmd.Args, "--adapter", startCmdConfigAdapterFlag)