From 70c0d45d942dc03abfea710e50646dd39aa4719c Mon Sep 17 00:00:00 2001 From: Thomas Parrott Date: Thu, 27 Jun 2024 13:15:06 +0100 Subject: [PATCH] lxd-agent: Ignore linter complaints about deep exit In this case we need it to ensure non-zero exit code is returned. Signed-off-by: Thomas Parrott --- lxd-agent/main.go | 3 ++- lxd-agent/main_agent.go | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lxd-agent/main.go b/lxd-agent/main.go index 4f023a8605e3..54b24d5b6953 100644 --- a/lxd-agent/main.go +++ b/lxd-agent/main.go @@ -45,6 +45,7 @@ func main() { // Run the main command and handle errors err := app.Execute() if err != nil { - os.Exit(1) + // Ensure we exit with a non-zero exit code. + os.Exit(1) //nolint:revive } } diff --git a/lxd-agent/main_agent.go b/lxd-agent/main_agent.go index 4568ac11e116..db9750663808 100644 --- a/lxd-agent/main_agent.go +++ b/lxd-agent/main_agent.go @@ -51,7 +51,8 @@ func (c *cmdAgent) Run(cmd *cobra.Command, args []string) error { // Setup logger. err := logger.InitLogger("", "lxd-agent", c.global.flagLogVerbose, c.global.flagLogDebug, nil) if err != nil { - os.Exit(1) + // Ensure we exit with a non-zero exit code. + os.Exit(1) //nolint:revive } logger.Info("Starting") @@ -196,7 +197,8 @@ func (c *cmdAgent) Run(cmd *cobra.Command, args []string) error { cancelStatusNotifier() // Ensure STOPPED status is written to QEMU status ringbuffer. cancelFunc() - os.Exit(exitStatus) + // Ensure we exit with a relevant exit code. + os.Exit(exitStatus) //nolint:revive return nil }