Simplify parsing

This commit is contained in:
Phani Teja Marupaka
2020-06-19 17:17:32 -07:00
parent e994b3b566
commit 28307bc435
13 changed files with 47 additions and 98 deletions

View File

@@ -123,7 +123,7 @@ func (r *LocalPackageReadWriter) Write(nodes []*yaml.RNode) error {
func (r *LocalPackageReadWriter) getFiles(nodes []*yaml.RNode) (sets.String, error) {
val := sets.String{}
for _, n := range nodes {
path, _, _, err := kioutil.GetFileAnnotations(n)
path, _, err := kioutil.GetFileAnnotations(n)
if err != nil {
return nil, errors.Wrap(err)
}
@@ -246,25 +246,10 @@ func (r *LocalPackageReader) readFile(path string, _ os.FileInfo) ([]*yaml.RNode
Reader: f,
OmitReaderAnnotations: r.OmitReaderAnnotations,
SetAnnotations: r.SetAnnotations,
AcceptJSON: r.acceptJSON(path),
}
return rr.Read()
}
// acceptJSON returns true if the input path has json ext and if the MatchFilesGlob
// has any of the JSONMatch ext
func (r *LocalPackageReader) acceptJSON(path string) bool {
for _, gm := range r.MatchFilesGlob {
for _, jm := range JSONMatch {
if filepath.Ext(path) == filepath.Ext(jm) &&
filepath.Ext(gm) == filepath.Ext(jm) {
return true
}
}
}
return false
}
// ShouldSkipFile returns true if the file should be skipped
func (r *LocalPackageReader) ShouldSkipFile(info os.FileInfo) (bool, error) {
// check if the files are in scope