Explorar o código

feature(manager): add fields in mirrorStatus

walkerning %!s(int64=9) %!d(string=hai) anos
pai
achega
4ea26921e7
Modificáronse 1 ficheiros con 14 adicións e 0 borrados
  1. 14 0
      manager/status.go

+ 14 - 0
manager/status.go

@@ -49,6 +49,20 @@ func (s *mirrorStatus) UnmarshalJSON(v []byte) error {
 	} else {
 		return errors.New("key `name` does not exist in the json")
 	}
+	if isMaster, ok := m["is_master"]; ok {
+		if s.IsMaster, ok = isMaster.(bool); !ok {
+			return errors.New("is_master should be a string")
+		}
+	} else {
+		return errors.New("key `is_master` does not exist in the json")
+	}
+	if _worker, ok := m["worker"]; ok {
+		if s.Worker, ok = _worker.(string); !ok {
+			return errors.New("worker should be a string")
+		}
+	} else {
+		return errors.New("key `worker` does not exist in the json")
+	}
 	if upstream, ok := m["upstream"]; ok {
 		if s.Upstream, ok = upstream.(string); !ok {
 			return errors.New("upstream should be a string")