pathexp

package
v0.10.2-rc Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2016 License: AGPL-3.0 Imports: 4 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

This section is empty.

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 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) 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) 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) 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