envoyx

package
v0.0.0-...-df391e2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OnConflictDefault mergeAlg = iota
	OnConflictReplace
	OnConflictSkip
	OnConflictPanic

	DecodeTypeURI   decodeType = "uri"
	DecodeTypeIO    decodeType = "io"
	DecodeTypeStore decodeType = "store"

	EncodeTypeURI   encodeType = "uri"
	EncodeTypeStore encodeType = "store"
	EncodeTypeIo    encodeType = "io"
)

Variables

This section is empty.

Functions

func AutomationWorkflowRbacReferences

func AutomationWorkflowRbacReferences(workflow string) (res *Ref, pp []*Ref, err error)

AutomationWorkflowRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func CastMergeAlg

func CastMergeAlg(v string) (mergeAlg mergeAlg)

func ComposeChartRbacReferences

func ComposeChartRbacReferences(namespaceID string, chart string) (res *Ref, pp []*Ref, err error)

ComposeChartRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func ComposeModuleFieldRbacReferences

func ComposeModuleFieldRbacReferences(namespaceID string, moduleID string, moduleField string) (res *Ref, pp []*Ref, err error)

ComposeModuleFieldRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func ComposeModuleRbacReferences

func ComposeModuleRbacReferences(namespaceID string, module string) (res *Ref, pp []*Ref, err error)

ComposeModuleRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func ComposeNamespaceRbacReferences

func ComposeNamespaceRbacReferences(namespace string) (res *Ref, pp []*Ref, err error)

ComposeNamespaceRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func ComposePageLayoutRbacReferences

func ComposePageLayoutRbacReferences(namespaceID string, pageID string, pageLayout string) (res *Ref, pp []*Ref, err error)

ComposePageLayoutRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func ComposePageRbacReferences

func ComposePageRbacReferences(namespaceID string, page string) (res *Ref, pp []*Ref, err error)

ComposePageRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func ComposeRecordRbacReferences

func ComposeRecordRbacReferences(namespaceID string, moduleID string, record string) (res *Ref, pp []*Ref, err error)

ComposeRecordRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func FederationExposedModuleRbacReferences

func FederationExposedModuleRbacReferences(nodeID string, exposedModule string) (res *Ref, pp []*Ref, err error)

FederationExposedModuleRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func FederationNodeRbacReferences

func FederationNodeRbacReferences(node string) (res *Ref, pp []*Ref, err error)

FederationNodeRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func FederationSharedModuleRbacReferences

func FederationSharedModuleRbacReferences(nodeID string, sharedModule string) (res *Ref, pp []*Ref, err error)

FederationSharedModuleRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func Initialized

func Initialized() bool

func MergeRefs

func MergeRefs(a map[string]Ref, bb ...map[string]Ref) (c map[string]Ref)

func NodesByResourceType

func NodesByResourceType(nn ...*Node) (out map[string]NodeSet)

NodesByResourceType returns Nodes grouped by their resource type

func ParseRule

func ParseRule(res string) (string, *Ref, []*Ref, error)

Parse generates resource setting logic for each resource

Resources with "envoy: false" are skipped

This function is auto-generated

func SetDecoderSources

func SetDecoderSources(nn NodeSet, dd ...Provider)

func SetGlobal

func SetGlobal(n *Service)

SetGlobal sets the global envoy service

func SplitResourceIdentifier

func SplitResourceIdentifier(ref string) (out map[string]Ref)

SplitResourceIdentifier takes an identifier string and splices it into path identifiers as defined by the resource

func SystemApigwRouteRbacReferences

func SystemApigwRouteRbacReferences(apigwRoute string) (res *Ref, pp []*Ref, err error)

SystemApigwRouteRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func SystemApplicationRbacReferences

func SystemApplicationRbacReferences(application string) (res *Ref, pp []*Ref, err error)

SystemApplicationRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func SystemAuthClientRbacReferences

func SystemAuthClientRbacReferences(authClient string) (res *Ref, pp []*Ref, err error)

SystemAuthClientRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func SystemDalConnectionRbacReferences

func SystemDalConnectionRbacReferences(dalConnection string) (res *Ref, pp []*Ref, err error)

SystemDalConnectionRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func SystemDataPrivacyRequestRbacReferences

func SystemDataPrivacyRequestRbacReferences(dataPrivacyRequest string) (res *Ref, pp []*Ref, err error)

SystemDataPrivacyRequestRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func SystemQueueRbacReferences

func SystemQueueRbacReferences(queue string) (res *Ref, pp []*Ref, err error)

SystemQueueRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func SystemReportRbacReferences

func SystemReportRbacReferences(report string) (res *Ref, pp []*Ref, err error)

SystemReportRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func SystemRoleRbacReferences

func SystemRoleRbacReferences(role string) (res *Ref, pp []*Ref, err error)

SystemRoleRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func SystemTemplateRbacReferences

func SystemTemplateRbacReferences(template string) (res *Ref, pp []*Ref, err error)

SystemTemplateRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

func SystemUserRbacReferences

func SystemUserRbacReferences(user string) (res *Ref, pp []*Ref, err error)

SystemUserRbacReferences generates RBAC references

Resources with "envoy: false" are skipped

This function is auto-generated

Types

type Datasource

type Datasource interface {
	Next(ctx context.Context, out map[string]string) (ident []string, more bool, err error)
	Reset(ctx context.Context) error
	SetProvider(Provider) bool
}

type DatasourceMapping

type DatasourceMapping struct {
	SourceIdent string   `yaml:"source"`
	KeyField    []string `yaml:"key"`
	References  map[string]string
	Scope       map[string]string

	// Defaultable indicates wether the mapping should keep the values where
	// the ident is not explicitly mapped.
	//
	// When true, the value is assigned to the given identifier.
	Defaultable bool `yaml:"defaultable"`
	Mapping     FieldMapping
}

type DecodeParams

type DecodeParams struct {
	Type   decodeType
	Params map[string]any
	Config DecoderConfig
	Filter map[string]ResourceFilter
}

type Decoder

type Decoder interface {
	// Decode returns a set of Nodes extracted based on the provided definition
	Decode(ctx context.Context, p DecodeParams) (out NodeSet, err error)
}

type DecoderConfig

type DecoderConfig struct{}

type DepGraph

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

DepGraph provides a collection of optionally connected subgraphs

Each subgraph is dedicated for a specific node scope. A subgraph with scoped nodes may be connected to the subgraph with no defined scope.

func BuildDepGraph

func BuildDepGraph(nn ...*Node) (out *DepGraph)

BuildDepGraph constructs a dependency graph from the provided nodes

We firstly group the nodes by scope, then build a subgraph for each scope, and lastly merge the subgraphs into a single graph.

func (DepGraph) Children

func (g DepGraph) Children(n *Node) (out NodeSet)

Children returns all child nodes of n

func (DepGraph) ChildrenForResourceType

func (g DepGraph) ChildrenForResourceType(n *Node, rt string) (out NodeSet)

ChildrenForResourceType returns child nodes of n which match the resource type

func (DepGraph) MissingRefs

func (g DepGraph) MissingRefs() (out []map[string]Ref)

MissingRegs returns a slice of all refs that are requested but not found in the graph

func (DepGraph) NodeForRef

func (g DepGraph) NodeForRef(ref Ref) (out *Node)

func (DepGraph) ParentForRT

func (g DepGraph) ParentForRT(n *Node, rt string) (out NodeSet)

ParentForRT returns a set of parent nodes matching the resource type

func (DepGraph) ParentForRef

func (g DepGraph) ParentForRef(n *Node, ref Ref) (out *Node)

ParentForRef returns a parent node of n which matches ref (nil if none)

func (DepGraph) Roots

func (g DepGraph) Roots() (out NodeSet)

Roots returns all nodes which are considered as root resources based on the current state

For the most part, these are all resources with no parent resources. If all resources define parents, then some home brew logic is ran

type EncodeParams

type EncodeParams struct {
	Type    encodeType
	Params  map[string]any
	Envoy   EnvoyConfig
	Encoder EncoderConfig

	// @note these are only used by records since v1 did just that
	// @todo make these more expanded
	DeferOk  func()
	DeferNok func(error) error
	Defer    func()
}

type Encoder

type Encoder interface {
	// Encode encodes the data
	//
	// The function receives a set of root-level nodes (with no parent dependencies)
	// and a Traverser it can use to handle all of the child nodes.
	Encode(context.Context, EncodeParams, string, NodeSet, Traverser) (err error)
}

type EncoderConfig

type EncoderConfig struct {
	DefaultUserID       uint64
	PreferredTimeLayout string
	PreferredTimezone   string
}

type EnvoyConfig

type EnvoyConfig struct {
	MergeAlg   mergeAlg
	SkipIf     string
	SkipIfEval expr.Evaluable
}

type Evaluated

type Evaluated struct {
	Skip bool
}

type FieldMapping

type FieldMapping struct {
	// @note This had to be like so to simplify decoding
	Map map[string]MapEntry
}

func (*FieldMapping) UnmarshalYAML

func (d *FieldMapping) UnmarshalYAML(n *yaml.Node) (err error)

UnmarshalYAML is used to get the yaml parsed into a series of nodes so we can easily pass it down

type Identifiers

type Identifiers struct {
	Slice []string
	Index map[string]bool
}

func MakeIdentifiers

func MakeIdentifiers(ii ...any) (out Identifiers)

MakeIdentifiers initializes an Identifiers instance from the given slice

func MergeIdents

func MergeIdents(a, b Identifiers) (cc Identifiers)

MergeIdents merges the two identifiers and returns a new one

func (Identifiers) Add

func (ii Identifiers) Add(vv ...any) (out Identifiers)

Add adds the given values to the identifier

func (Identifiers) FriendlyIdentifier

func (ii Identifiers) FriendlyIdentifier() (out string)

FriendlyIdentifier returns the best available identifier

If any non-ID identifiers are available, it uses the first one. If no non-ID identifiers are available, it returns the first ID.

func (Identifiers) HasIntersection

func (aa Identifiers) HasIntersection(bb Identifiers) bool

HasIntersection returns true if the two identifiers define an intersection

func (Identifiers) Idents

func (ii Identifiers) Idents() (ints []uint64, rest []string)

Idents returns a slice of numeric and text identifiers

func (Identifiers) IdentsAsStrings

func (ii Identifiers) IdentsAsStrings() (ids, rest []string)

func (Identifiers) Intersection

func (aa Identifiers) Intersection(bb Identifiers) (out []string)

Intersection returns a slice of identifiers which are in an intersection

func (Identifiers) Merge

func (aa Identifiers) Merge(bb Identifiers) (cc Identifiers)

Merge merges the two identifiers and returns a new one @todo deprecate this; use MergeIdents instead

type MapEntry

type MapEntry struct {
	Column string
	Field  string
	Skip   bool
}

type Node

type Node struct {
	Resource   resource
	Datasource Datasource

	ResourceType string
	Identifiers  Identifiers
	References   map[string]Ref
	Scope        Scope

	// Placeholders are resources which were added to help resolve missing deps
	Placeholder bool
	Config      EnvoyConfig
	Evaluated   Evaluated
}

Node is a wrapper around a Corteza resource for use within Envoy

func NodeForRef

func NodeForRef(ref Ref, nn ...*Node) (out *Node)

NodeForRef returns the Node that matches the given ref

func (*Node) Prune

func (n *Node) Prune(ref Ref)

func (Node) ToRef

func (n Node) ToRef() Ref

type NodeSet

type NodeSet []*Node

func NodesForResourceType

func NodesForResourceType(rt string, nn ...*Node) (out NodeSet)

NodesForResourceType returns which belong to the given resource type

func OmitPlaceholderNodes

func OmitPlaceholderNodes(nn ...*Node) (out NodeSet)

func RBACRulesForNodes

func RBACRulesForNodes(rr rbac.RuleSet, nn ...*Node) (rules NodeSet, err error)

func ResourceTranslationsForNodes

func ResourceTranslationsForNodes(tt types.ResourceTranslationSet, nn ...*Node) (translations NodeSet, err error)

type PrepareEncoder

type PrepareEncoder interface {
	Preparer
	Encoder
}

type Preparer

type Preparer interface {
	// Prepare performs generic preprocessing on the provided nodes
	//
	// The function is called for every resource type where all of the nodes of
	// that resource type are passed as the argument.
	Prepare(context.Context, EncodeParams, string, NodeSet) error
}

type Provider

type Provider interface {
	Next(ctx context.Context, out map[string]string) (more bool, err error)
	Reset(ctx context.Context) error
	SetIdent(string)
	Ident() string
}

type Ref

type Ref struct {
	ResourceType string
	Identifiers  Identifiers
	Scope        Scope
	// @todo consider replacing with something that indicates
	//       it can't be fetched from the DB
	Optional bool
}

Ref defines a reference to a different resource

The reference only holds if all three parts match -- the resource type, there is an intersection between the identifiers, and the scope matches.

func (Ref) Equals

func (a Ref) Equals(b Ref) bool

func (Ref) Idents

func (r Ref) Idents() (ints []uint64, rest []string)

func (Ref) ResourceFilter

func (r Ref) ResourceFilter() (out map[string]ResourceFilter)

ResourceFilter returns a filter which would match the referenced resource

type ResourceFilter

type ResourceFilter struct {
	Identifiers Identifiers
	Refs        map[string]Ref

	Limit uint
	Scope Scope
}

type Scope

type Scope struct {
	ResourceType string
	Identifiers  Identifiers
}

Scope lets us group nodes based on some common context

Scope is primarily used to scope low-code applications to denote to what namespace a specific module reference belongs to. In the previous version this was referred to as reference constraints; This is the same but different.

When constructing dependency graphs, nodes with the same scope are grouped together. Nodes from the same scope can reference each other. Nodes from a defined scope can reference nodes from an undefined scope, but not the other way around.

func (Scope) Equals

func (a Scope) Equals(b Scope) bool

func (Scope) IsEmpty

func (s Scope) IsEmpty() bool

type Service

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

func Global

func Global() *Service

Global gets the global envoy service

func New

func New() *Service

New initializes a new Envoy service

func (*Service) AddDecoder

func (svc *Service) AddDecoder(t decodeType, dd ...Decoder)

func (*Service) AddEncoder

func (svc *Service) AddEncoder(t encodeType, ee ...Encoder)

func (*Service) AddPreparer

func (svc *Service) AddPreparer(t encodeType, pp ...Preparer)

func (*Service) Bake

func (svc *Service) Bake(ctx context.Context, p EncodeParams, providers []Provider, nodes ...*Node) (gg *DepGraph, err error)

func (*Service) Decode

func (svc *Service) Decode(ctx context.Context, p DecodeParams) (nodes NodeSet, providers []Provider, err error)

Decode returns a set of envoy Nodes based on the given decode params

func (*Service) Encode

func (svc *Service) Encode(ctx context.Context, p EncodeParams, dg *DepGraph) (err error)

Encode encodes Corteza resources bases on the provided encode params

use the BuildDepGraph function to build the default dependency graph.

type Traverser

type Traverser interface {
	// ParentForRef returns the parent of the provided node which matches the ref
	//
	// If no parent is found, nil is returned.
	ParentForRef(*Node, Ref) *Node

	// ParentForRT returns a set of parent nodes matching the resource type
	ParentForRT(*Node, string) NodeSet

	// ChildrenForResourceType returns the children of the provided node which
	// match the provided resource type
	ChildrenForResourceType(*Node, string) NodeSet

	// Children returns all of the children of the provided node
	Children(*Node) NodeSet

	// NodeForRef returns the node which matches the provided ref
	NodeForRef(Ref) *Node
}

Traverser provides a structure which can be used to traverse the node's deps

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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