diff --git a/internal/instructions/config.go b/internal/instructions/config.go index 02c6ff8..4a8f5b5 100644 --- a/internal/instructions/config.go +++ b/internal/instructions/config.go @@ -134,7 +134,7 @@ 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, @@ -142,15 +142,17 @@ func (cfg *Config) ReadAdHocPaths(i *Instructions) error { }, } - 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() } diff --git a/internal/instructions/yamlfile.go b/internal/instructions/yamlfile.go index aed28b7..09e9e75 100644 --- a/internal/instructions/yamlfile.go +++ b/internal/instructions/yamlfile.go @@ -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) @@ -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