refactor(state): extract getMissingFileHandler method for clarity

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero 2025-08-14 13:57:07 +08:00
parent bb6df72463
commit 71fa1900fe
1 changed files with 14 additions and 1 deletions

View File

@ -3210,7 +3210,7 @@ func (st *HelmState) ExpandedHelmfiles() ([]SubHelmfileSpec, error) {
} }
if len(matches) == 0 { if len(matches) == 0 {
err := fmt.Errorf("no matches for path: %s", hf.Path) err := fmt.Errorf("no matches for path: %s", hf.Path)
if *st.MissingFileHandler == "Error" { if *st.getMissingFileHandler() == "Error" {
return nil, err return nil, err
} }
st.logger.Warnf("no matches for path: %s", hf.Path) st.logger.Warnf("no matches for path: %s", hf.Path)
@ -3298,6 +3298,19 @@ func (st *HelmState) getReleaseMissingFileHandler(release *ReleaseSpec) *string
} }
} }
// getMissingFileHandler returns the first non-nil MissingFileHandler in the following order:
// - st.MissingFileHandler
// - "Error"
func (st *HelmState) getMissingFileHandler() *string {
defaultMissingFileHandler := "Error"
switch {
case st.MissingFileHandler != nil:
return st.MissingFileHandler
default:
return &defaultMissingFileHandler
}
}
func (st *HelmState) generateTemporaryReleaseValuesFiles(release *ReleaseSpec, values []any) ([]string, error) { func (st *HelmState) generateTemporaryReleaseValuesFiles(release *ReleaseSpec, values []any) ([]string, error) {
generatedFiles := []string{} generatedFiles := []string{}