Skip to content

Commit

Permalink
yet another fix, this time with path splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
zen-dog committed Dec 6, 2019
1 parent da27754 commit d98e0ad
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions pkg/kudoctl/packages/reader/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@ package reader

import (
"fmt"
"os"
"path/filepath"
"regexp"
"strings"

"github.com/kudobuilder/kudo/pkg/kudoctl/clog"
"github.com/kudobuilder/kudo/pkg/kudoctl/packages"
"sigs.k8s.io/yaml"
)

const (
operatorFileName = "operator.yaml"
templateFileNameRegex = "templates/.*.yaml"
paramsFileName = "params.yaml"
APIVersion = "kudo.dev/v1beta1"
operatorFileName = "operator.yaml"
paramsFileName = "params.yaml"
templateBase = "templates"
templateFileName = ".*.yaml"
APIVersion = "kudo.dev/v1beta1"
)

func newPackageFiles() packages.Files {
Expand All @@ -28,11 +32,16 @@ func parsePackageFile(filePath string, fileBytes []byte, currentPackage *package
}

isTemplateFile := func(name string) bool {
matched, err := regexp.Match(templateFileNameRegex, []byte(name))
dir, file := filepath.Split(name)
base := filepath.Base(dir)

match, err := regexp.MatchString(templateFileName, file)
if err != nil {
panic(err)
clog.Printf("Failed to parse template file %s, err: %v", name, err)
os.Exit(1)
}
return matched

return base == templateBase && match
}

isParametersFile := func(name string) bool {
Expand Down

0 comments on commit d98e0ad

Please sign in to comment.