From ce39f522e58c8c0cfb78badc393039ccbd15f74b Mon Sep 17 00:00:00 2001 From: yxxhero Date: Fri, 6 Jun 2025 07:06:29 +0800 Subject: [PATCH] refactor(helm3): optimize manifest extraction logic Signed-off-by: yxxhero --- cmd/helm3.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/helm3.go b/cmd/helm3.go index 1e9df931..f624656a 100644 --- a/cmd/helm3.go +++ b/cmd/helm3.go @@ -355,13 +355,21 @@ func extractManifestFromHelmUpgradeDryRunOutput(s []byte, noHooks bool) []byte { return s } + var ( + hooks []byte + manifest []byte + ) + i := bytes.Index(s, []byte("HOOKS:")) - hooks := s[i:] + if i > -1 { + hooks = s[i:] + } j := bytes.Index(hooks, []byte("MANIFEST:")) - - manifest := hooks[j:] - hooks = hooks[:j] + if j > -1 { + manifest = hooks[j:] + hooks = hooks[:j] + } k := bytes.Index(manifest, []byte("\nNOTES:"))