pathexp

package
v0.31.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2018 License: BSD-3-Clause Imports: 4 Imported by: 23

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func GlobContains added in v0.19.0

func GlobContains(value, subject string) bool

GlobContains returns whether a glob, built from the value, contains the subject

func Split added in v0.13.0

func Split(name, segment string) ([]string, error)

Split separates alternation

func ValidSecret added in v0.19.0

func ValidSecret(subject string) bool

ValidSecret returns whether the subject is a valid secret name value

func ValidSlug added in v0.19.0

func ValidSlug(subject string) bool

ValidSlug returns whether the subject is a valid slug value

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

func New(org, project string, envs, services, identities, instances []string) (*PathExp, error)

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

func Parse(raw string) (*PathExp, error)

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

func ParsePartial(raw string) (*PathExp, error)

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

func (pe *PathExp) CompareSpecificity(other *PathExp) int

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) Contains added in v0.25.0

func (pe *PathExp) Contains(other *PathExp) bool

Contains returns whether this path contains the subject. A path Contains another if it resolves to the other or they are equal.

func (*PathExp) Equal

func (pe *PathExp) Equal(other *PathExp) bool

Equal returns a bool indicating if the two PathExps are equivalent.

func (*PathExp) MarshalText

func (pe *PathExp) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface. This will be used in json encoding.

func (*PathExp) String

func (pe *PathExp) String() string

String returns the unparsed string representation of the path expression

func (*PathExp) UnmarshalText

func (pe *PathExp) UnmarshalText(b []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface. This will be used in json decoding.

func (*PathExp) WithInstance

func (pe *PathExp) WithInstance(instance string) (*PathExp, error)

WithInstance clones a PathExp, replacing its instance with the parsed value from the argument.

XXX: this isn't really great. it would be nice to support all path types.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL