graph

package
v0.0.0-...-ed79881 Latest Latest
Warning

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

Go to latest
Published: May 6, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EgressOnlyInternetGatewayTarget routeTargetType = iota
	GatewayTarget
	InstanceTarget
	NatTarget
	NetworkInterfaceTarget
	VpcPeeringConnectionTarget
)

Variables

View Source
var (
	DefaultDiffer = &hierarchicDiffer{rdf.ParentOf}
	MetaPredicate = "meta"
)

Functions

func NewGraphFromFiles

func NewGraphFromFiles(files ...string) (cloud.GraphAPI, error)

func Subtract

func Subtract(one, other map[string]interface{}) map[string]interface{}

func VisitorCollectFunc

func VisitorCollectFunc(collect *[]*Resource) visitEachFunc

Types

type And

type And struct {
	Resolvers []Resolver
}

func (*And) Resolve

func (r *And) Resolve(snap tstore.RDFGraph) (result []*Resource, err error)

type ById

type ById struct {
	Id string
}

func (*ById) Resolve

func (r *ById) Resolve(snap tstore.RDFGraph) ([]*Resource, error)

type ByProperty

type ByProperty struct {
	Key   string
	Value interface{}
}

func (*ByProperty) Resolve

func (r *ByProperty) Resolve(snap tstore.RDFGraph) ([]*Resource, error)

type ByType

type ByType struct {
	Typ string
}

func (*ByType) Resolve

func (r *ByType) Resolve(snap tstore.RDFGraph) ([]*Resource, error)

type ByTypeAndProperty

type ByTypeAndProperty struct {
	Type  string
	Key   string
	Value interface{}
}

func (*ByTypeAndProperty) Resolve

func (r *ByTypeAndProperty) Resolve(snap tstore.RDFGraph) ([]*Resource, error)

type ByTypes

type ByTypes struct {
	Typs []string
}

func (*ByTypes) Resolve

func (r *ByTypes) Resolve(snap tstore.RDFGraph) ([]*Resource, error)

type ChildrenVisitor

type ChildrenVisitor struct {
	From        *Resource
	Each        visitEachFunc
	IncludeFrom bool
	Relation    string
}

func (*ChildrenVisitor) Visit

func (v *ChildrenVisitor) Visit(g *Graph) error

type Diff

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

func NewDiff

func NewDiff(fromG, toG *Graph) *Diff

func (*Diff) FromGraph

func (d *Diff) FromGraph() *Graph

func (*Diff) HasDiff

func (d *Diff) HasDiff() bool

func (*Diff) MergedGraph

func (d *Diff) MergedGraph() *Graph

func (*Diff) ToGraph

func (d *Diff) ToGraph() *Graph

type Differ

type Differ interface {
	Run(string, *Graph, *Graph) (*Diff, error)
}

type DistributionOrigin

type DistributionOrigin struct {
	ID         string `predicate:"cloud:id"`
	PublicDNS  string `predicate:"cloud:publicDNS"`
	PathPrefix string `predicate:"cloud:pathPrefix"`
	OriginType string `predicate:"cloud:type"`
	Config     string `predicate:"cloud:config"`
}

func (*DistributionOrigin) String

func (o *DistributionOrigin) String() string

type FilterFn

type FilterFn func(*Resource) bool

func BuildPropertyFilterFunc

func BuildPropertyFilterFunc(key, val string) FilterFn

func BuildTagFilterFunc

func BuildTagFilterFunc(key, val string) FilterFn

func BuildTagKeyFilterFunc

func BuildTagKeyFilterFunc(key string) FilterFn

func BuildTagValueFilterFunc

func BuildTagValueFilterFunc(value string) FilterFn

type FirewallRule

type FirewallRule struct {
	PortRange PortRange    `predicate:"net:portRange"`
	Protocol  string       `predicate:"net:protocol"`
	IPRanges  []*net.IPNet `predicate:"net:cidr"` // IPv4 or IPv6 range
	Sources   []string     `predicate:"cloud:source"`
}

FirewallRule describes a single firewall rule.

func (*FirewallRule) Contains

func (r *FirewallRule) Contains(ip string) bool

Contains checks if firewall rule contains `ip`.

func (*FirewallRule) String

func (r *FirewallRule) String() string

String prints a firewall rule to string.

type FirewallRules

type FirewallRules []*FirewallRule

FirewallRules is a slice of firewall rules.

func (FirewallRules) Sort

func (rules FirewallRules) Sort()

Sort firewall rules.

type Grant

type Grant struct {
	Permission string  `predicate:"cloud:permission"`
	Grantee    Grantee `predicate:"cloud:grantee" bnode:""`
}

func (*Grant) String

func (g *Grant) String() string

type Grantee

type Grantee struct {
	GranteeID          string `predicate:"cloud:id"`
	GranteeDisplayName string `predicate:"cloud:name"`
	GranteeType        string `predicate:"cloud:granteeType"`
}

type Grants

type Grants []*Grant

func (Grants) Sort

func (grants Grants) Sort()

type Graph

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

func NewGraph

func NewGraph() *Graph

func (*Graph) Accept

func (g *Graph) Accept(v Visitor) error

func (*Graph) AddAppliesOnRelation

func (g *Graph) AddAppliesOnRelation(parent, child *Resource) error

func (*Graph) AddGraph

func (g *Graph) AddGraph(other *Graph)

func (*Graph) AddParentRelation

func (g *Graph) AddParentRelation(parent, child *Resource) error

func (*Graph) AddResource

func (g *Graph) AddResource(resources ...*Resource) error

func (*Graph) AsRDFGraphSnaphot

func (g *Graph) AsRDFGraphSnaphot() tstore.RDFGraph

func (*Graph) Filter

func (g *Graph) Filter(entity string, filters ...FilterFn) (*Graph, error)

func (*Graph) FilterGraph

func (g *Graph) FilterGraph(q cloud.Query) (cloud.GraphAPI, error)

func (*Graph) Find

func (g *Graph) Find(q cloud.Query) ([]cloud.Resource, error)

func (*Graph) FindAncestor

func (g *Graph) FindAncestor(res *Resource, resourceType string) *Resource

func (*Graph) FindOne

func (g *Graph) FindOne(q cloud.Query) (cloud.Resource, error)

func (*Graph) FindResource

func (g *Graph) FindResource(id string) (*Resource, error)

func (*Graph) FindResourcesByProperty

func (g *Graph) FindResourcesByProperty(key string, value interface{}) ([]*Resource, error)

func (*Graph) FindWithProperties

func (g *Graph) FindWithProperties(props map[string]interface{}) ([]cloud.Resource, error)

func (*Graph) GetAllResources

func (g *Graph) GetAllResources(typs ...string) ([]*Resource, error)

func (*Graph) GetResource

func (g *Graph) GetResource(t string, id string) (*Resource, error)

func (*Graph) ListResourcesAppliedOn

func (g *Graph) ListResourcesAppliedOn(start *Resource) ([]*Resource, error)

func (*Graph) ListResourcesDependingOn

func (g *Graph) ListResourcesDependingOn(start *Resource) ([]*Resource, error)

func (*Graph) MarshalTo

func (g *Graph) MarshalTo(w io.Writer) error

func (*Graph) Merge

func (g *Graph) Merge(mg cloud.GraphAPI) error

func (*Graph) MustMarshal

func (g *Graph) MustMarshal() string

func (*Graph) OrFilter

func (g *Graph) OrFilter(entity string, filters ...FilterFn) (*Graph, error)

func (*Graph) ResolveResources

func (g *Graph) ResolveResources(resolvers ...Resolver) ([]*Resource, error)

func (*Graph) ResourceRelations

func (g *Graph) ResourceRelations(from cloud.Resource, relation string, recursive bool) (collect []cloud.Resource, err error)

func (*Graph) ResourceSiblings

func (g *Graph) ResourceSiblings(res cloud.Resource) (collect []cloud.Resource, err error)

func (*Graph) Unmarshal

func (g *Graph) Unmarshal(data []byte) error

func (*Graph) UnmarshalFromReaders

func (g *Graph) UnmarshalFromReaders(readers ...io.Reader) error

func (*Graph) VisitRelations

func (g *Graph) VisitRelations(from cloud.Resource, relation string, includeFrom bool, each func(cloud.Resource, int) error) (err error)

type KeyValue

type KeyValue struct {
	Key   string `predicate:"cloud:keyName"`
	Value string `predicate:"cloud:value"`
}

KeyValue is a (Key, Value) string pair.

func (*KeyValue) String

func (kv *KeyValue) String() string

type Or

type Or struct {
	Resolvers []Resolver
}

func (*Or) Resolve

func (r *Or) Resolve(snap tstore.RDFGraph) (result []*Resource, err error)

type ParentsVisitor

type ParentsVisitor struct {
	From        *Resource
	Each        visitEachFunc
	IncludeFrom bool
	Relation    string
}

func (*ParentsVisitor) Visit

func (v *ParentsVisitor) Visit(g *Graph) error

type Policy

type Policy struct {
	Version    string             `json:",omitempty"`
	ID         string             `json:"Id,omitempty"`
	Statements compositeStatement `json:"Statement,omitempty"`
}

type PolicyStatement

type PolicyStatement struct {
	ID           string              `json:"Sid,omitempty"`
	Principal    *StatementPrincipal `json:",omitempty"`
	NotPrincipal *StatementPrincipal `json:",omitempty"`
	Effect       string              `json:",omitempty"`
	Actions      compositeString     `json:"Action,omitempty"`
	NotActions   compositeString     `json:"NotAction,omitempty"`
	Resources    compositeString     `json:"Resource,omitempty"`
	NotResources compositeString     `json:"NotResource,omitempty"`
	Condition    interface{}         `json:",omitempty"`
}

type PortRange

type PortRange struct {
	FromPort, ToPort int64
	Any              bool
}

PortRange describes a port range.

func ParsePortRange

func ParsePortRange(s string) (PortRange, error)

func (PortRange) Contains

func (p PortRange) Contains(port int64) bool

Contains checks if port range contains given port.

func (PortRange) String

func (p PortRange) String() string

type Resolver

type Resolver interface {
	Resolve(snap tstore.RDFGraph) ([]*Resource, error)
}

type Resource

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

func InitResource

func InitResource(kind, id string) *Resource

func NotFoundResource

func NotFoundResource(id string) *Resource

func ResolveResourcesWithProp

func ResolveResourcesWithProp(snap tstore.RDFGraph, resType, propName, propVal string) ([]*Resource, error)

func (*Resource) AddRelation

func (res *Resource) AddRelation(typ string, rel *Resource)

func (*Resource) Format

func (res *Resource) Format(layout string) (out string)

func (*Resource) Id

func (res *Resource) Id() string

func (*Resource) Meta

func (res *Resource) Meta(k string) (interface{}, bool)

func (*Resource) Properties

func (res *Resource) Properties() map[string]interface{}

func (*Resource) Property

func (res *Resource) Property(k string) (interface{}, bool)

func (*Resource) Same

func (res *Resource) Same(other cloud.Resource) bool

Compare only the id and type of the resources (no properties nor meta)

func (*Resource) SetProperty

func (res *Resource) SetProperty(k string, v interface{})

func (*Resource) String

func (res *Resource) String() string

func (*Resource) Type

func (res *Resource) Type() string

type Resources

type Resources []*Resource

func (Resources) Map

func (res Resources) Map(f func(*Resource) string) (out []string)

type Route

type Route struct {
	Destination             *net.IPNet     `predicate:"net:cidr"`
	DestinationIPv6         *net.IPNet     `predicate:"net:cidrv6"`
	DestinationPrefixListId string         `predicate:"net:routeDestinationPrefixList"`
	Targets                 []*RouteTarget `predicate:"net:routeTargets"`
}

func (*Route) String

func (r *Route) String() string

type RouteTarget

type RouteTarget struct {
	Type  routeTargetType
	Ref   string
	Owner string
}

func ParseRouteTarget

func ParseRouteTarget(s string) (*RouteTarget, error)

func (*RouteTarget) String

func (t *RouteTarget) String() string

type Routes

type Routes []*Route

func (Routes) Sort

func (routes Routes) Sort()

type SiblingsVisitor

type SiblingsVisitor struct {
	From        *Resource
	Each        visitEachFunc
	IncludeFrom bool
}

func (*SiblingsVisitor) Visit

func (v *SiblingsVisitor) Visit(g *Graph) error

type StatementPrincipal

type StatementPrincipal struct {
	AWS       compositeString `json:",omitempty"`
	Service   compositeString `json:",omitempty"`
	Federated compositeString `json:",omitempty"`
}

func (*StatementPrincipal) UnmarshalJSON

func (c *StatementPrincipal) UnmarshalJSON(data []byte) (err error)

To support AWS JSON for Policy in which a principal can be either a JSON object, either "*"

type Visitor

type Visitor interface {
	Visit(*Graph) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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