regex matchstring error parsing

Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
This commit is contained in:
Anshul Ahuja
2023-07-13 10:10:37 +05:30
parent 4a28b3b16f
commit 16ec2db1f7
3 changed files with 38 additions and 1 deletions

View File

@@ -85,7 +85,10 @@ func (r *ResourceModifierRule) Apply(obj *unstructured.Unstructured, groupResour
return nil
}
if r.Conditions.ResourceNameRegex != "" {
match, _ := regexp.MatchString(r.Conditions.ResourceNameRegex, obj.GetName())
match, err := regexp.MatchString(r.Conditions.ResourceNameRegex, obj.GetName())
if err != nil {
return errors.Errorf("error in matching regex %s", err.Error())
}
if !match {
return nil
}