Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
fix: read all yaml files in directory for given path parameter (#97)
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Davis <[email protected]>
  • Loading branch information
JefeDavis authored Jun 15, 2021
1 parent 5bf6bdc commit c442dba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
12 changes: 7 additions & 5 deletions internal/instructions/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,25 @@ func (cfg *Config) encodeNodes(nodes []*yaml.Node) (*bytes.Buffer, error) {

func (cfg *Config) ReadAdHocPaths(i *Instructions) error {
if cfg.Path != "" {
yf := YamlFiles{
yfs := YamlFiles{
&YamlFile{
Name: "StdIn",
Path: cfg.Path,
OutputPath: determinePath(cfg.Path),
},
}

if err := yf.expandDirectories(); err != nil {
if err := yfs.expandDirectories(); err != nil {
return fmt.Errorf("%w", err)
}

if err := yf[0].readYamlFile(); err != nil {
return err
for _, yf := range yfs {
if err := yf.readYamlFile(); err != nil {
return err
}
}

i.YamlFiles = append(i.YamlFiles, yf...)
i.YamlFiles = append(i.YamlFiles, yfs...)

i.YamlFiles.mergeDuplicates()
}
Expand Down
7 changes: 0 additions & 7 deletions internal/instructions/yamlfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ func (yfs *YamlFiles) expandDirectories() error {

var paths []string

var removeItems []int

for i := 0; i <= len(y)-1; i++ {
if !path.IsAbs(y[i].Path) {
y[i].Path = path.Join(viper.GetString("instructionsDir"), y[i].Path)
Expand Down Expand Up @@ -154,11 +152,6 @@ func (yfs *YamlFiles) expandDirectories() error {
}
}

for _, remove := range removeItems {
y[remove] = y[len(y)-1]
y = y[:len(y)-1]
}

*yfs = y

return nil
Expand Down

0 comments on commit c442dba

Please sign in to comment.