Merge pull request #2853 from phanimarupaka/WarnIfNoSubstMatch

Print message if subst doesn't match any field value
This commit is contained in:
Kubernetes Prow Robot
2020-08-17 10:00:19 -07:00
committed by GitHub
2 changed files with 18 additions and 10 deletions

View File

@@ -78,7 +78,8 @@ func (c SetterCreator) Create(openAPIPath, resourcesPath string) error {
Outputs: []kio.Writer{inout},
}.Execute()
if a.Count == 0 {
fmt.Printf("setter %s doesn't match any field in resources, but creating setter definition\n", c.Name)
fmt.Printf("setter %s doesn't match any field in resource configs, "+
"but creating setter definition\n", c.Name)
}
if err != nil {
return err

View File

@@ -123,18 +123,25 @@ func (c SubstitutionCreator) Create(openAPIPath, resourcesPath string) error {
return err
}
// Update the resources with the setter reference
a := &setters2.Add{
FieldName: c.FieldName,
FieldValue: c.FieldValue,
Ref: fieldmeta.DefinitionsPrefix + fieldmeta.SubstitutionDefinitionPrefix + c.Name,
}
// Update the resources with the substitution reference
inout := &kio.LocalPackageReadWriter{PackagePath: resourcesPath}
return kio.Pipeline{
Inputs: []kio.Reader{inout},
Filters: []kio.Filter{kio.FilterAll(
&setters2.Add{
FieldName: c.FieldName,
FieldValue: c.FieldValue,
Ref: fieldmeta.DefinitionsPrefix + fieldmeta.SubstitutionDefinitionPrefix + c.Name,
})},
err = kio.Pipeline{
Inputs: []kio.Reader{inout},
Filters: []kio.Filter{kio.FilterAll(a)},
Outputs: []kio.Writer{inout},
}.Execute()
if a.Count == 0 {
fmt.Printf("substitution %s doesn't match any field value in resource configs, "+
"but creating substitution definition\n", c.Name)
}
return err
}
// createMarkersAndRefs takes the input pattern, creates setter/substitution markers