mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-18 04:36:23 +02:00
make controllerinformer interface private;
use named regexp groups
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user