Suggested changes

This commit is contained in:
Phani Teja Marupaka
2020-06-07 15:13:21 -07:00
parent dc4bf03da2
commit b39c522cc1
12 changed files with 379 additions and 122 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)
}
@@ -240,16 +240,31 @@ func (r *LocalPackageReader) readFile(path string, _ os.FileInfo) ([]*yaml.RNode
return nil, err
}
defer f.Close()
rr := &ByteReader{
DisableUnwrapping: true,
Reader: f,
OmitReaderAnnotations: r.OmitReaderAnnotations,
SetAnnotations: r.SetAnnotations,
Path: path,
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