Documentation
¶
Overview ¶
Package pathexp provides a representation of path expressions; locations of secrets within the org/project/environment/service/identity/instance hierarchy supporting globs and alternation.
Paths being parsed support <double-glob> but will be converted to <full-glob> in the resulting pathexp
Grammar:
<pathexp> ::= "/" <org> "/" <project> "/" <environment> "/" <service> "/" <identity> "/" <instance> <org> ::= <literal> <project> ::= <literal> <environment> ::= <multiple> <service> ::= <multiple> <identity> ::= <multiple> <instance> ::= <multiple> <multiple> ::= <alternation> | <glob-or-literal> | <full-glob> <alternation> ::= "[" <alternation-body> "]" <alternation-body> ::= <glob-or-literal> | <glob-or-literal> "|" <alternation-body> <glob-or-literal> ::= <glob> | <literal> <glob> ::= <literal> "*" <literal> ::= [a-z0-9][a-z0-9\-\_]{0,63} <fullglob> ::= "*"
Index ¶
- func GlobContains(value, subject string) bool
- func Split(name, segment string) ([]string, error)
- func ValidSlug(subject string) bool
- type PathExp
- func (pe *PathExp) CompareSpecificity(other *PathExp) int
- func (pe *PathExp) Equal(other *PathExp) bool
- func (pe *PathExp) MarshalText() ([]byte, error)
- func (pe *PathExp) String() string
- func (pe *PathExp) UnmarshalText(b []byte) error
- func (pe *PathExp) WithInstance(instance string) (*PathExp, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GlobContains ¶ added in v0.19.0
GlobContains returns whether a glob, built from the value, contains the subject
Types ¶
type PathExp ¶
type PathExp struct { Org literal Project literal Envs segment Services segment Identities segment Instances segment }
PathExp is a path expression
func New ¶
New creates a new path expression from the given path segments It returns an error if any of the values fail to validate and it must contain all relevant parts
func NewPartial ¶ added in v0.13.0
func NewPartial(org, project string, envs, services, identities, instances []string) (*PathExp, error)
NewPartial creates a new path expression from the given path segments It returns an error if any of the values fail to validate but does not require any segments
func Parse ¶
Parse parses a string into a path expression. It returns an error if the string is not a valid path expression.
func ParsePartial ¶ added in v0.19.0
ParsePartial parses a string into a path expression. It returns an error if the string is not a valid path expression, but allows missing segments
func (*PathExp) CompareSpecificity ¶
CompareSpecificity returns an int indicating if this PathExp is more specific than PathExp b.
PathExp A is more specific then PathExp B if, for each segment in the PathExp, A's segment is as specific or more specific than B's segment.
Segment specificity is, from most to least specific:
- <literal>
- <glob>
- <alternation>
- <fullglob>
It is assumed that the provided PathExps are not disjoint.
func (*PathExp) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface. This will be used in json encoding.
func (*PathExp) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface. This will be used in json decoding.