Documentation ¶
Overview ¶
Package resourcename implements simple functions to manipulate UTF-8 encoded AIP resource names.
Index ¶
- Constants
- func Ancestor(name, pattern string) (string, bool)
- func ContainsWildcard(name string) bool
- func HasParent(name, parent string) bool
- func Join(elems ...string) string
- func Match(pattern, name string) bool
- func RangeParents(name string, fn func(parent string) bool)
- func Sprint(pattern string, variables ...string) string
- func Sscan(name, pattern string, variables ...*string) (err error)
- func Validate(name string) error
- func ValidatePattern(pattern string) error
- type Literal
- type Scanner
- type Segment
Constants ¶
const RevisionSeparator = '@'
RevisionSeparator is the separator character used to separate resource IDs from revision IDs.
const Wildcard = "-"
Wildcard is the resource name wildcard character "-".
Variables ¶
This section is empty.
Functions ¶
func Ancestor ¶ added in v0.40.0
Ancestor extracts an ancestor from the provided name, using a pattern for the ancestor.
func ContainsWildcard ¶ added in v0.32.0
ContainsWildcard reports whether the specified resource name contains any wildcard segments.
func HasParent ¶ added in v0.28.0
HasParent tests whether name has the specified parent. Wildcard segments (-) are considered. Resource names without revisions are considered parents of the same resource name with a revision.
func Match ¶ added in v0.31.0
Match reports whether the specified resource name matches the specified resource name pattern.
func RangeParents ¶ added in v0.35.0
RangeParents iterates over all parents of the provided resource name. The iteration order is from root ancestor down to the closest parent. Collection segments are included in the iteration, to not require knowing the pattern. For full resource names, the service is omitted.
func Sprint ¶ added in v0.30.0
Sprint formats resource name variables according to a pattern and returns the resulting string.
func Sscan ¶ added in v0.29.0
Sscan scans a resource name, storing successive segments into successive variables as determined by the provided pattern.
func Validate ¶ added in v0.39.0
Validate that a resource name conforms to the restrictions outlined in AIP-122. See: https://google.aip.dev/122
func ValidatePattern ¶ added in v0.41.0
ValidatePattern that a resource name pattern conforms to the restrictions outlined in AIP-122. See: https://google.aip.dev/122
Types ¶
type Literal ¶ added in v0.28.0
type Literal string
Literal is the literal part of a resource name segment.
EBNF
Literal = RESOURCE_ID | RevisionLiteral ; RevisionLiteral = RESOURCE_ID "@" REVISION_ID ;
func (Literal) HasRevision ¶ added in v0.28.0
HasRevision returns true if the literal has a valid revision.
func (Literal) ResourceID ¶ added in v0.28.0
ResourceID returns the literal's resource ID.
func (Literal) RevisionID ¶ added in v0.28.0
RevisionID returns the literal's revision ID.
type Scanner ¶ added in v0.28.0
type Scanner struct {
// contains filtered or unexported fields
}
Scanner scans a resource name.
func (*Scanner) End ¶ added in v0.35.0
End returns the end index (exclusive) of the current segment.
func (*Scanner) Full ¶ added in v0.28.0
Full returns true if the scanner has detected a full resource name.
func (*Scanner) ServiceName ¶ added in v0.28.0
ServiceName returns the service name, when the scanner has detected a full resource name.
type Segment ¶
type Segment string
Segment is a segment of a resource name or a resource name pattern.
EBNF
Segment = Literal | Variable ; Variable = "{" Literal "}" ;
func (Segment) IsVariable ¶ added in v0.28.0
IsVariable reports whether the segment is a variable segment.
func (Segment) IsWildcard ¶ added in v0.28.0
IsWildcard reports whether the segment is a wildcard.