drone/types/enum/user.go
Enver Bisevac 00647d7d1b [MAINT] golangci-lint config changed (#31)
* goheader linter added

* file header consistency
2022-10-13 14:39:15 +02:00

44 lines
937 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"
// UserField 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 "id":
return UserAttrUID
case "name":
return UserAttrName
case "email":
return UserAttrEmail
case "admin":
return UserAttrAdmin
case "created", "created_at":
return UserAttrCreated
case "updated", "updated_at":
return UserAttrUpdated
default:
return UserAttrNone
}
}