Skip to content

fix: propagate kubectl error in GetPodsforDeployment, compile regexp once#839

Open
immanuwell wants to merge 1 commit into
helm:mainfrom
immanuwell:fix/minor-bugs
Open

fix: propagate kubectl error in GetPodsforDeployment, compile regexp once#839
immanuwell wants to merge 1 commit into
helm:mainfrom
immanuwell:fix/minor-bugs

Conversation

@immanuwell
Copy link
Copy Markdown

What this PR does / why we need it:

Two small fixes:

  1. GetPodsforDeployment was silently dropping the error from kubectl get deployment. When kubectl fails you'd get a confusing unexpected end of JSON input instead of the actual error. One-liner fix - just stop ignoring the err.

  2. SanitizeName was calling regexp.MustCompile on every invocation. The regex is constant so it should be compiled once at package level (same pattern already used in account.go right next door).

Bonus: trimmed a stray trailing space off an error string in CheckVersionIncrement.

How to reproduce:

For (1): call GetPodsforDeployment with a deployment name that doesn't exist or when kubectl isn't configured - you'll see unexpected end of JSON input instead of the real kubectl error.

For (2): SanitizeName is called in CreateInstallParams for every chart install, so the regex gets recompiled on each run. No functional impact but wasteful.

Special notes for your reviewer:

All existing tests pass, no behavior change for (2) and (3), (1) now surfaces the real error earlier.

…once

Signed-off-by: immanuwell <pchpr.00@list.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant