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

Commit

Permalink
(maint) Workaround for List
Browse files Browse the repository at this point in the history
We are moving to a namespaced directory structure but until all our functions move there, we cannot fix glob to look at 3 levels deep. This recurses the path and looks for all pct-config.yml, which is a bit overkill.
  • Loading branch information
da-ar authored and sanfrancrisko committed Sep 7, 2021
1 parent 8334996 commit 632304b
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion internal/pkg/pct/pct.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"os"
"os/user"
"path/filepath"
"regexp"
"strings"
"text/template"

Expand Down Expand Up @@ -113,7 +114,27 @@ func (p *Pct) GetInfo(templateCache string, selectedTemplate string) (PuppetCont
// debug log events
func (p *Pct) List(templatePath string, templateName string) ([]PuppetContentTemplate, error) {
log.Debug().Msgf("Searching %+v for templates", templatePath)
matches, _ := p.IOFS.Glob(templatePath + "/**/" + TemplateConfigFileName)

var matches []string

// recurse over the templatePath
err := p.AFS.Walk(templatePath,
func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}

// If we find a config file, add it to our matches
if match, _ := regexp.MatchString(".*(/|\\\\)"+TemplateConfigFileName+"$", path); match {
matches = append(matches, path)
}

return nil
})

if err != nil {
return nil, err
}

var tmpls []PuppetContentTemplate
for _, file := range matches {
Expand Down

0 comments on commit 632304b

Please sign in to comment.