mercury

package
v0.12.17 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: MIT Imports: 20 Imported by: 3

Documentation

Index

Constants

View Source
const (
	TypeNamespaceNode  = "node"
	TypeNamespaceStar  = "star"
	TypeNamespaceTrace = "trace"
)

Namespace Spec types

Variables

This section is empty.

Functions

func NodeMercury added in v0.12.4

func NodeMercury(ctx context.Context, id []string) (gql.Node, error)

func Register

func Register(match string, priority int, hdlr Handler)

Register add a handler to registry

Types

type Config

type Config []*Space

func NewConfig

func NewConfig(spaces ...*Space) Config

func (*Config) AddSpace

func (c *Config) AddSpace(spaces ...*Space) *Config

func (Config) EnvString

func (lis Config) EnvString() string

EnvString format config as environ

func (Config) IniString

func (lis Config) IniString() string

IniString format config as ini

func (Config) Len

func (lis Config) Len() int

Len implements Len for sort.interface

func (Config) Less

func (lis Config) Less(i, j int) bool

Less implements Less for sort.interface

func (Config) String

func (lis Config) String() string

String format config as string

func (Config) StringList

func (lis Config) StringList() string

StringList returns the space names as a list

func (Config) Swap

func (lis Config) Swap(i, j int)

Swap implements Swap for sort.interface

func (Config) ToSpaceMap

func (lis Config) ToSpaceMap() SpaceMap

ToSpaceMap formats as SpaceMap

type GraphMercury

type GraphMercury struct{}

GraphMercury implements the resolvers for gqlgen

func (GraphMercury) Config

func (GraphMercury) Config(ctx context.Context, search *string, query *gql.QueryInput) (lis []*Space, err error)

Config returns a list of config items

func (GraphMercury) Value

func (GraphMercury) Value(ctx context.Context, value *Value) (string, error)

Value returns a joined value

func (GraphMercury) WriteConfig

func (GraphMercury) WriteConfig(ctx context.Context, config []*Space) (result string, err error)

WriteConfig saves a space and attributes to database

func (GraphMercury) WriteConfigText

func (g GraphMercury) WriteConfigText(ctx context.Context, config string) (result string, err error)

WriteConfigText saves a config set formated in text

type Handler

type Handler interface {
	GetIndex(NamespaceSearch, *rsql.Program) Config
	GetObjects(NamespaceSearch, *rsql.Program, []string) Config
	WriteObjects(Config) error
	GetRules(ident.Ident) Rules
	GetNotify(string) ListNotify
}

Handler interface for backends

type HandlerItem

type HandlerItem struct {
	Handler
	Match    string
	Priority int
}

HandlerItem a single handler matching

func (HandlerItem) String

func (h HandlerItem) String() string

type HandlerList

type HandlerList []HandlerItem

HandlerList a list of handlers

var Registry HandlerList

Registry handler

func (HandlerList) GetIndex

func (hl HandlerList) GetIndex(match, search string) (lis Config)

GetIndex query each handler that match namespace.

func (HandlerList) GetNotify

func (hl HandlerList) GetNotify(event string) (lis ListNotify, err error)

GetNotify query each of the handlers for rules.

func (HandlerList) GetObjects

func (hl HandlerList) GetObjects(match, search, fields string) (out Config)

GetObjects query each handler that match for fully qualified namespaces.

func (HandlerList) GetRules

func (hl HandlerList) GetRules(user ident.Ident) (lis Rules)

GetRules query each of the handlers for rules.

func (HandlerList) Len

func (hl HandlerList) Len() int

Len implements Len for sort.interface

func (HandlerList) Less

func (hl HandlerList) Less(i, j int) bool

Less implements Less for sort.interface

func (HandlerList) String

func (hl HandlerList) String() string

func (HandlerList) Swap

func (hl HandlerList) Swap(i, j int)

Swap implements Swap for sort.interface

func (HandlerList) WriteObjects

func (hl HandlerList) WriteObjects(spaces Config) error

WriteObjects write objects to backends

type ListNotify

type ListNotify []Notify

ListNotify array of notify

func (ListNotify) Find

func (ln ListNotify) Find(name string) (lis ListNotify)

Find returns list of notify that match name.

type NamespaceNode

type NamespaceNode string

NamespaceNode implements a node search value

func (NamespaceNode) Match

func (n NamespaceNode) Match(s string) bool

Match returns true if any match.

func (NamespaceNode) Quote

func (n NamespaceNode) Quote() string

Quote return quoted value.

func (NamespaceNode) Raw

func (n NamespaceNode) Raw() string

Raw return raw value.

func (NamespaceNode) String

func (n NamespaceNode) String() string

String output string value

func (NamespaceNode) Type

func (NamespaceNode) Type() string

Type to identify the type

func (NamespaceNode) Value

func (n NamespaceNode) Value() string

Value to return the value

type NamespaceSearch

type NamespaceSearch []NamespaceSpec

NamespaceSearch list of namespace specs

func ParseNamespace

func ParseNamespace(ns string) (lis NamespaceSearch)

ParseNamespace returns a list of parsed values

func (NamespaceSearch) Match

func (n NamespaceSearch) Match(s string) bool

Match returns true if any match.

func (NamespaceSearch) String

func (n NamespaceSearch) String() string

String output string value

type NamespaceSpec

type NamespaceSpec interface {
	Type() string
	Value() string
	String() string
	Raw() string
	Match(string) bool
}

NamespaceSpec implements a parsed namespace search

func NewNamespace

func NewNamespace(ns, t string) NamespaceSpec

NewNamespace returns requested type that implements NamespaceSpec

type NamespaceStar

type NamespaceStar string

NamespaceStar implements a trace search value

func (NamespaceStar) Match

func (n NamespaceStar) Match(s string) bool

Match returns true if any match.

func (NamespaceStar) Quote

func (n NamespaceStar) Quote() string

Quote return quoted value.

func (NamespaceStar) Raw

func (n NamespaceStar) Raw() string

Raw return raw value.

func (NamespaceStar) String

func (n NamespaceStar) String() string

String output string value

func (NamespaceStar) Type

func (NamespaceStar) Type() string

Type returns the type of the value

func (NamespaceStar) Value

func (n NamespaceStar) Value() string

Value to return the value

type NamespaceTrace

type NamespaceTrace string

NamespaceTrace implements a trace search value

func (NamespaceTrace) Match

func (n NamespaceTrace) Match(s string) bool

Match returns true if any match.

func (NamespaceTrace) Quote

func (n NamespaceTrace) Quote() string

Quote return quoted value.

func (NamespaceTrace) Raw

func (n NamespaceTrace) Raw() string

Raw return raw value.

func (NamespaceTrace) String

func (n NamespaceTrace) String() string

String output string value

func (NamespaceTrace) Type

func (NamespaceTrace) Type() string

Type returns the type of the value

func (NamespaceTrace) Value

func (n NamespaceTrace) Value() string

Value to return the value

type Notify

type Notify struct {
	Name   string
	Match  string
	Event  string
	Method string
	URL    string
}

Notify stores the attributes for a registry space

func (Notify) Check

func (n Notify) Check(name string) bool

Check if name matches notify

type Roles

type Roles map[string]struct{}

Roles is a list of roles for a resource

func (Roles) HasRole

func (r Roles) HasRole(roles ...string) bool

HasRole is a valid role

type Rule

type Rule struct {
	Role  string
	Type  string
	Match string
}

Rule is a type of rule

func (Rule) Check

func (r Rule) Check(name string) bool

Check if name matches rule

type Rules

type Rules []Rule

Rules is a list of rules

func (Rules) CheckNamespace

func (r Rules) CheckNamespace(search NamespaceSearch) bool

CheckNamespace verifies user has access

func (Rules) GetNamespaceSearch

func (r Rules) GetNamespaceSearch() (lis NamespaceSearch)

GetNamespaceSearch returns a default search for users rules.

func (Rules) GetRoles

func (r Rules) GetRoles(typ, name string) (lis Roles)

GetRoles returns a list of Roles

func (Rules) ReduceSearch

func (r Rules) ReduceSearch(search NamespaceSearch) (out NamespaceSearch)

ReduceSearch verifies user has access

type Space

type Space struct {
	Space string   `json:"space"`
	Tags  []string `json:"tags"`
	Notes []string `json:"notes"`
	List  []Value  `json:"list"`
}

Space stores a registry of spaces

func NewSpace

func NewSpace(space string) *Space

func (*Space) AddKeys

func (s *Space) AddKeys(keys ...*Value) *Space

func (*Space) AddNotes

func (s *Space) AddNotes(notes ...string) *Space

func (*Space) AddTags

func (s *Space) AddTags(tags ...string) *Space

func (Space) FirstTagMeta

func (s Space) FirstTagMeta(needle string) string

FirstTagMeta returns the first meta tag value.

func (Space) FirstValue

func (s Space) FirstValue(name string) Value

FirstValue that matches name

func (Space) GetTagMeta

func (s Space) GetTagMeta(needle string, offset int) string

GetTagMeta retuns the value after a '/' in a tag. Tags are in the format 'name' or 'name/value' This function returns the value.

func (Space) GetValues

func (s Space) GetValues(name string) (lis []Value)

GetValues that match name

func (Space) HasTag

func (s Space) HasTag(needle string) bool

HasTag returns true if needle is found If the needle ends with a / it will be treated as a prefix for tag meta data.

func (*Space) ID

func (s *Space) ID() string

func (*Space) IsNode added in v0.12.4

func (s *Space) IsNode()

func (*Space) SetKeys

func (s *Space) SetKeys(keys ...*Value) *Space

func (*Space) SetNotes

func (s *Space) SetNotes(notes ...string) *Space

func (*Space) SetTags

func (s *Space) SetTags(tags ...string) *Space

type SpaceMap

type SpaceMap map[string]*Space

SpaceMap generic map of space values

func (SpaceMap) ToArray

func (m SpaceMap) ToArray() Config

ToArray converts SpaceMap to ArraySpace

type Value

type Value struct {
	Space  string   `json:"-"`
	Seq    uint64   `json:"-"`
	Name   string   `json:"name"`
	Values []string `json:"values"`
	Notes  []string `json:"notes"`
	Tags   []string `json:"tags"`
}

Value stores the attributes for space values

func NewValue

func NewValue(name string) *Value

func (*Value) AddNotes

func (v *Value) AddNotes(notes ...string) *Value

func (*Value) AddTags

func (v *Value) AddTags(tags ...string) *Value

func (*Value) AddValues

func (v *Value) AddValues(values ...string) *Value

func (Value) First

func (v Value) First() string

First value in array.

func (Value) FirstTagMeta

func (v Value) FirstTagMeta(needle string) string

FirstTagMeta returns the first meta tag value.

func (Value) GetTagMeta

func (v Value) GetTagMeta(needle string, offset int) string

GetTagMeta retuns the value after a '/' in a tag. Tags are in the format 'name' or 'name/value' This function returns the value.

func (Value) HasTag

func (v Value) HasTag(needle string) bool

HasTag returns true if needle is found If the needle ends with a / it will be treated as a prefix for tag meta data.

func (*Value) ID added in v0.12.3

func (v *Value) ID() string

func (Value) Join

func (v Value) Join() string

Join values with newlines.

func (*Value) SetNotes

func (v *Value) SetNotes(notes ...string) *Value

func (*Value) SetTags

func (v *Value) SetTags(tags ...string) *Value

func (*Value) SetValues

func (v *Value) SetValues(values ...string) *Value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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