etcd: Add world API changes for watching member status

This adds some useful functionality so that anyone with access to the
world API, can learn information about the changing etcd cluster it's
using.
This commit is contained in:
James Shubin
2018-04-12 03:27:05 -04:00
parent 0c751ea14f
commit 738485a655
7 changed files with 192 additions and 0 deletions

View File

@@ -82,6 +82,21 @@ func cmpURLs(u1, u2 etcdtypes.URLs) error {
return nil
}
// FromStringListToURLs takes a list of string urls and converts them into the
// native type.
func FromStringListToURLs(surls []string) (etcdtypes.URLs, error) {
result := []url.URL{}
for _, s := range surls { // flatten map
u, err := url.Parse(s)
if err != nil {
return nil, err
}
result = append(result, *u)
}
return result, nil
}
// CmpURLsMap compares two URLsMap's, and returns nil if they are the same.
func CmpURLsMap(m1, m2 etcdtypes.URLsMap) error {
if (m1 == nil) != (m2 == nil) { // xor