Skip to content

Commit 3c4195f

Browse files
authored
refactor(helm3): optimize manifest extraction logic (#797)
Signed-off-by: yxxhero <[email protected]>
1 parent 941b532 commit 3c4195f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

cmd/helm3.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,21 @@ func extractManifestFromHelmUpgradeDryRunOutput(s []byte, noHooks bool) []byte {
355355
return s
356356
}
357357

358+
var (
359+
hooks []byte
360+
manifest []byte
361+
)
362+
358363
i := bytes.Index(s, []byte("HOOKS:"))
359-
hooks := s[i:]
364+
if i > -1 {
365+
hooks = s[i:]
366+
}
360367

361368
j := bytes.Index(hooks, []byte("MANIFEST:"))
362-
363-
manifest := hooks[j:]
364-
hooks = hooks[:j]
369+
if j > -1 {
370+
manifest = hooks[j:]
371+
hooks = hooks[:j]
372+
}
365373

366374
k := bytes.Index(manifest, []byte("\nNOTES:"))
367375

0 commit comments

Comments
 (0)