List setters in subpackages

This commit is contained in:
Phani Teja Marupaka
2020-08-25 16:20:08 -07:00
parent 30b58e90a3
commit 9d65dd0786
16 changed files with 368 additions and 36 deletions

View File

@@ -15,9 +15,13 @@ import (
)
// List lists the setters specified in the OpenAPI
// excludes the subpackages which contain file with
// name OpenAPIFileName in them
type List struct {
Name string
OpenAPIFileName string
Setters []SetterDefinition
Substitutions []SubstitutionDefinition
@@ -181,12 +185,13 @@ func (l *List) listSubst(object *yaml.RNode) error {
}
// count returns the number of fields set by the setter with name
// this excludes all the subpackages with openAPI file in them
// set filter is leveraged for this but the resources are not written
// back to files as only LocalPackageReader is invoked and not writer
func (l *List) count(path, name string) (int, error) {
s := &Set{Name: name}
err := kio.Pipeline{
Inputs: []kio.Reader{&kio.LocalPackageReader{PackagePath: path}},
Inputs: []kio.Reader{&kio.LocalPackageReader{PackagePath: path, PackageFileName: l.OpenAPIFileName}},
Filters: []kio.Filter{kio.FilterAll(s)},
}.Execute()