Skip to content

Commit

Permalink
allow empty cuegen.yaml file
Browse files Browse the repository at this point in the history
  • Loading branch information
nxcc committed Jun 2, 2023
1 parent 7a3714f commit 293bb2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 4 additions & 0 deletions internal/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"errors"
"flag"
"fmt"
"io"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -172,6 +173,9 @@ func loadYamlConfig(file string) (string, cuegen.Config, error) {
decoder := yaml.NewDecoder(fh)
decoder.KnownFields(true)
if err := decoder.Decode(&config); err != nil {
if errors.Is(err, io.EOF) {
return file, cuegen.Config{}, nil
}
return "", cuegen.Config{}, err
}
return file, config, nil
Expand Down
6 changes: 2 additions & 4 deletions tests/local/config-objectsPath.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ exec cuegen chart/cuegen3.yaml
stdout 'c: d'

# config: no objectsPath
! exec cuegen chart/cuegen4.yaml
stderr 'loadconfig: EOF'
! exec cuegen chart/cuegen1.yaml
stderr 'objectsPath is not set'

-- chart/cuegen1.yaml --
secretDataPath: dummy
Expand All @@ -25,8 +25,6 @@ objectsPath: objects
-- chart/cuegen3.yaml --
objectsPath: otherPath

-- chart/cuegen4.yaml --

-- chart/a.cue --
package kube

Expand Down

0 comments on commit 293bb2d

Please sign in to comment.