add mapstructure tags to types,
improve function documentation
This commit is contained in:
+10
-2
@@ -5,15 +5,21 @@ import (
|
||||
"regexp"
|
||||
)
|
||||
|
||||
// Converts input groupname object to string representation.
|
||||
// Uses the format gid-realm.
|
||||
func (g Groupname) ToString() string {
|
||||
return fmt.Sprintf("%s-%s", g.GroupID, g.Realm)
|
||||
}
|
||||
|
||||
// Converts input username object to string representation.
|
||||
// Uses the format uid@realm.
|
||||
func (u Username) ToString() string {
|
||||
return fmt.Sprintf("%s-%s", u.UserID, u.Realm)
|
||||
}
|
||||
|
||||
// returns an error if the groupname format was not correct
|
||||
// Parses input groupname string to gid and realm.
|
||||
// Assumes the format gid-realm or gid if realm is implicitly pve.
|
||||
// Returns an error if the groupname format was not correct.
|
||||
func ParseGroupname(groupname string) (Groupname, error) {
|
||||
g := Groupname{}
|
||||
// <groupid>-<realm>
|
||||
@@ -36,7 +42,9 @@ func ParseGroupname(groupname string) (Groupname, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// returns an error if the username format was not correct
|
||||
// Parses input username string to uid and realm.
|
||||
// Assumes the format uid@realm.
|
||||
// Returns an error if the username format was not correct.
|
||||
func ParseUsername(username string) (Username, error) {
|
||||
u := Username{}
|
||||
m := regexp.MustCompilePOSIX("([[:alnum:]]+)@([[:alnum:]]+)")
|
||||
|
||||
Reference in New Issue
Block a user