add func
This commit is contained in:
@@ -2,6 +2,7 @@ package peer
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
@@ -33,12 +34,23 @@ const (
|
||||
PENDING_PARTNER
|
||||
)
|
||||
|
||||
var path = []string{"unknown", "self", "partner", "blacklist", "pending_parthner"}
|
||||
|
||||
func GetPath(str string) int {
|
||||
for i, p := range path {
|
||||
if str == p {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
func (m PeerRelation) Path() string {
|
||||
return [...]string{"unknown", "self", "partner", "blacklist", "pending_parthner"}[m]
|
||||
return path[m]
|
||||
}
|
||||
|
||||
func (m PeerRelation) String() string {
|
||||
return [...]string{"NONE", "SELF", "PARTNER", "BLACKLIST", "PENDING_PARTNER"}[m]
|
||||
return strings.ToUpper(path[m])
|
||||
}
|
||||
|
||||
func (m PeerRelation) EnumIndex() int {
|
||||
|
||||
Reference in New Issue
Block a user