drone/types/enum/path.go
Johannes Batzill 8c2f900c80 Principals, ServiceAccounts, Tokens and auth.Sessions (#15)
This change introduces the concept of a principal (abstraction of call identity), and adds a new service account type principal. Also adds support for different tokens (session, PAT, SAT, OAuth2) and adds auth.Session which is being used to capture information about the caller and call method.
2022-09-25 23:44:51 -07:00

68 lines
1.6 KiB
Go

// Copyright 2021 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"
// PathTargetType defines the type of the target of a path.
type PathTargetType string
const (
PathTargetTypeRepo PathTargetType = "repo"
PathTargetTypeSpace PathTargetType = "space"
)
// TODO: Should we replace Path.IsAlias with a Path.Type property? Unless needed, bool would be more efficient
// // Defines the type of a path
// type PathType string
// const (
// // Path is only an alias - it doesn't dictate where the target is actually residing.
// PathTypeAlias PathTargetType = "alias"
// // Path is representing the residency of a resource (e.g. chain of parent spaces)
// PathTypePrimary PathTargetType = "primary"
// )
// PathAttr defines path attributes that can be used for sorting and filtering.
type PathAttr int
// Order enumeration.
const (
PathAttrNone PathAttr = iota
PathAttrID
PathAttrPath
PathAttrCreated
PathAttrUpdated
)
const (
id = "id"
path = "path"
name = "name"
pathName = "path_name"
created = "created"
createdAt = "created_at"
updated = "updated"
updatedAt = "updated_at"
)
// ParsePathAttr parses the path attribute string
// and returns the equivalent enumeration.
func ParsePathAttr(s string) PathAttr {
switch strings.ToLower(s) {
case id:
return PathAttrID
case path:
return PathAttrPath
case created, createdAt:
return PathAttrCreated
case updated, updatedAt:
return PathAttrUpdated
default:
return PathAttrNone
}
}