From fc7a47f7d866126b88613db7746e2e9f5f02e391 Mon Sep 17 00:00:00 2001 From: Pavel Okhlopkov <36456348+ldmonster@users.noreply.github.com> Date: Mon, 2 Dec 2024 12:02:33 +0300 Subject: [PATCH] rollback keep-tmp-files flag(#693) Signed-off-by: Pavel Okhlopkov Co-authored-by: Pavel Okhlopkov --- pkg/app/debug.go | 6 +----- pkg/hook/hook.go | 3 ++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/pkg/app/debug.go b/pkg/app/debug.go index 19860a08..434300a3 100644 --- a/pkg/app/debug.go +++ b/pkg/app/debug.go @@ -30,11 +30,7 @@ func DefineDebugFlags(kpApp *kingpin.Application, cmd *kingpin.CmdClause) { cmd.Flag("debug-keep-tmp-files", "set to yes to disable cleanup of temporary files"). Envar("DEBUG_KEEP_TMP_FILES"). Hidden(). - Default(DebugKeepTmpFilesVar).Action(func(_ *kingpin.ParseContext) error { - DebugKeepTmpFiles = DebugKeepTmpFilesVar == "yes" - - return nil - }). + Default(DebugKeepTmpFilesVar). StringVar(&DebugKeepTmpFilesVar) cmd.Flag("debug-kubernetes-api", "enable client-go debug messages"). diff --git a/pkg/hook/hook.go b/pkg/hook/hook.go index af857e60..b0d30ab9 100644 --- a/pkg/hook/hook.go +++ b/pkg/hook/hook.go @@ -13,6 +13,7 @@ import ( "github.com/kennygrant/sanitize" "golang.org/x/time/rate" + "github.com/flant/shell-operator/pkg/app" "github.com/flant/shell-operator/pkg/executor" bctx "github.com/flant/shell-operator/pkg/hook/binding_context" "github.com/flant/shell-operator/pkg/hook/config" @@ -124,7 +125,7 @@ func (h *Hook) Run(_ htypes.BindingType, context []bctx.BindingContext, logLabel // remove tmp file on hook exit defer func() { - if h.KeepTemporaryHookFiles { + if app.DebugKeepTmpFilesVar != "yes" { _ = os.Remove(contextPath) _ = os.Remove(metricsPath) _ = os.Remove(conversionPath)