refactor(state): extract getMissingFileHandler method for clarity (#2133)

* refactor(state): extract getMissingFileHandler method for clarity

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero 2025-08-14 21:10:44 +08:00 committed by GitHub
parent bb6df72463
commit 8c123dcdda
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View File

@ -28,6 +28,8 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: check disk usage
run: df -h
- uses: goreleaser/goreleaser-action@v6
with:
version: latest

View File

@ -3210,7 +3210,7 @@ func (st *HelmState) ExpandedHelmfiles() ([]SubHelmfileSpec, error) {
}
if len(matches) == 0 {
err := fmt.Errorf("no matches for path: %s", hf.Path)
if *st.MissingFileHandler == "Error" {
if *st.getMissingFileHandler() == "Error" {
return nil, err
}
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) {
generatedFiles := []string{}