mirror of
https://github.com/harness/drone.git
synced 2025-05-04 14:43:47 +00:00
44 lines
919 B
Go
44 lines
919 B
Go
// Copyright 2022 Harness Inc. All rights reserved.
|
|
// Use of this source code is governed by the Polyform Free Trial License
|
|
// that can be found in the LICENSE.md file for this repository.
|
|
|
|
package enum
|
|
|
|
import "strings"
|
|
|
|
// UserAttr defines user attributes that can be
|
|
// used for sorting and filtering.
|
|
type UserAttr int
|
|
|
|
// Order enumeration.
|
|
const (
|
|
UserAttrNone UserAttr = iota
|
|
UserAttrUID
|
|
UserAttrName
|
|
UserAttrEmail
|
|
UserAttrAdmin
|
|
UserAttrCreated
|
|
UserAttrUpdated
|
|
)
|
|
|
|
// ParseUserAttr parses the user attribute string
|
|
// and returns the equivalent enumeration.
|
|
func ParseUserAttr(s string) UserAttr {
|
|
switch strings.ToLower(s) {
|
|
case uid:
|
|
return UserAttrUID
|
|
case name:
|
|
return UserAttrName
|
|
case email:
|
|
return UserAttrEmail
|
|
case admin:
|
|
return UserAttrAdmin
|
|
case created, createdAt:
|
|
return UserAttrCreated
|
|
case updated, updatedAt:
|
|
return UserAttrUpdated
|
|
default:
|
|
return UserAttrNone
|
|
}
|
|
}
|