make controllerinformer interface private;

use named regexp groups
This commit is contained in:
Murat Kabilov
2017-08-15 14:07:16 +02:00
parent 228639b839
commit 38e0ffecf7
3 changed files with 66 additions and 14 deletions
+28
View File
@@ -10,6 +10,8 @@ import (
"github.com/motomux/pretty"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"regexp"
"github.com/zalando-incubator/postgres-operator/pkg/spec"
)
@@ -71,3 +73,29 @@ OUTER:
}
return result, len(result) == 0
}
func FindNamedStringSubmatch(r *regexp.Regexp, s string) map[string]string {
matches := r.FindStringSubmatch(s)
grNames := r.SubexpNames()
if matches == nil {
return nil
}
groupMatches := 0
res := make(map[string]string, len(grNames))
for i, n := range grNames {
if n == "" {
continue
}
res[n] = matches[i]
groupMatches++
}
if groupMatches == 0 {
return nil
}
return res
}