pathexp

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2016 License: BSD-3-Clause Imports: 5 Imported by: 0

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.

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 Split added in v0.13.0

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

Split separates alternation

Types

type PathExp

type PathExp struct {
	// contains filtered or unexported fields
}

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

func NewPartial added in v0.13.0

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

NewPartial creates a new path expression from the given path segments It returns an error if any of the values fail to validate

func NewPartialFromPath added in v0.13.0

func NewPartialFromPath(value string) (*PathExp, *int, error)

NewPartialFromPath creates a PathExp object from a cpath string that may be an incomplete path, resulting in added asterisks

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 (*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) Envs added in v0.13.0

func (pe *PathExp) Envs() string

Envs returns the envs set for this pathexp

func (*PathExp) Equal

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

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

func (*PathExp) Identities added in v0.13.0

func (pe *PathExp) Identities() string

Identities returns the identities set for this pathexp

func (*PathExp) Instances added in v0.13.0

func (pe *PathExp) Instances() string

Instances returns the instances set for this pathexp

func (*PathExp) MarshalText

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

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

func (*PathExp) Org added in v0.8.0

func (pe *PathExp) Org() string

Org returns the org set for this pathexp

func (*PathExp) Project added in v0.8.0

func (pe *PathExp) Project() string

Project returns the project set for this pathexp

func (*PathExp) Services added in v0.13.0

func (pe *PathExp) Services() string

Services returns the services set for this pathexp

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