dashboardexecute

package
v0.18.0-alpha.19 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Executor = newDashboardExecutor()

Functions

func ExecutionCompleteToSnapshot added in v0.17.0

func ExecutionCompleteToSnapshot(event *dashboardevents.ExecutionComplete) *dashboardtypes.SteampipeSnapshot

ExecutionCompleteToSnapshot transforms the ExecutionComplete event into a SteampipeSnapshot

func GenerateSnapshot added in v0.17.0

func GenerateSnapshot(ctx context.Context, target string, initData *initialisation.InitData, inputs map[string]any) (snapshot *dashboardtypes.SteampipeSnapshot, err error)

func GetReferencedVariables added in v0.17.0

func GetReferencedVariables(root dashboardtypes.DashboardTreeRun, w *workspace.Workspace) map[string]string

GetReferencedVariables builds map of variables values containing only those mod variables which are referenced

Types

type CheckRun

type CheckRun struct {
	DashboardTreeRunBase
	DashboardParentBase

	Width            int                          `json:"width,omitempty"`
	Description      string                       `json:"description,omitempty"`
	Documentation    string                       `json:"documentation,omitempty"`
	Display          string                       `json:"display,omitempty"`
	Type             string                       `json:"display_type,omitempty"`
	Tags             map[string]string            `json:"tags,omitempty"`
	ErrorString      string                       `json:"error,omitempty"`
	NodeType         string                       `json:"panel_type"`
	DashboardName    string                       `json:"dashboard"`
	SourceDefinition string                       `json:"source_definition"`
	Summary          *controlexecute.GroupSummary `json:"summary"`
	SessionId        string                       `json:"-"`
	// if the dashboard node is a control, serialise to json as 'properties'
	Control *modconfig.Control `json:"properties,omitempty"`

	DashboardNode modconfig.DashboardLeafNode      `json:"-"`
	Root          controlexecute.ExecutionTreeNode `json:"-"`
	// contains filtered or unexported fields
}

CheckRun is a struct representing the execution of a control or benchmark

func NewCheckRun

func NewCheckRun(resource modconfig.DashboardLeafNode, parent dashboardtypes.DashboardParent, executionTree *DashboardExecutionTree) (*CheckRun, error)

func (*CheckRun) AsTreeNode

func (r *CheckRun) AsTreeNode() *dashboardtypes.SnapshotTreeNode

func (*CheckRun) BuildSnapshotPanels added in v0.17.0

func (r *CheckRun) BuildSnapshotPanels(leafNodeMap map[string]dashboardtypes.SnapshotPanel) map[string]dashboardtypes.SnapshotPanel

BuildSnapshotPanels is a custom implementation of BuildSnapshotPanels - be nice to just use the DashboardExecutionTree but work is needed on common interface types/generics

func (*CheckRun) ChildrenComplete

func (r *CheckRun) ChildrenComplete() bool

ChildrenComplete implements DashboardTreeRun (override base)

func (*CheckRun) Execute

func (r *CheckRun) Execute(ctx context.Context)

Execute implements DashboardRunNode

func (*CheckRun) GetRunStatus

func (r *CheckRun) GetRunStatus() dashboardtypes.DashboardRunStatus

GetRunStatus implements DashboardTreeRun

func (*CheckRun) GetTitle added in v0.17.0

func (r *CheckRun) GetTitle() string

GetTitle implements DashboardTreeRun

func (*CheckRun) Initialise

func (r *CheckRun) Initialise(ctx context.Context)

Initialise implements DashboardRunNode

func (*CheckRun) IsSnapshotPanel

func (*CheckRun) IsSnapshotPanel()

IsSnapshotPanel implements SnapshotPanel

func (*CheckRun) SetComplete

func (r *CheckRun) SetComplete(ctx context.Context)

SetComplete implements DashboardTreeRun

func (*CheckRun) SetError

func (r *CheckRun) SetError(ctx context.Context, err error)

SetError implements DashboardTreeRun

type DashboardContainerRun

type DashboardContainerRun struct {
	DashboardParentBase

	Width            int    `json:"width,omitempty"`
	Display          string `json:"display,omitempty"`
	ErrorString      string `json:"error,omitempty"`
	NodeType         string `json:"panel_type"`
	DashboardName    string `json:"dashboard"`
	SourceDefinition string `json:"source_definition"`
	// contains filtered or unexported fields
}

DashboardContainerRun is a struct representing a container run

func (*DashboardContainerRun) AsTreeNode

func (*DashboardContainerRun) Execute

func (r *DashboardContainerRun) Execute(ctx context.Context)

Execute implements DashboardRunNode execute all children and wait for them to complete

func (*DashboardContainerRun) Initialise

func (r *DashboardContainerRun) Initialise(ctx context.Context)

Initialise implements DashboardRunNode

func (*DashboardContainerRun) IsSnapshotPanel

func (*DashboardContainerRun) IsSnapshotPanel()

IsSnapshotPanel implements SnapshotPanel

func (*DashboardContainerRun) SetComplete

func (r *DashboardContainerRun) SetComplete(context.Context)

SetComplete implements DashboardTreeRun

func (*DashboardContainerRun) SetError

func (r *DashboardContainerRun) SetError(_ context.Context, err error)

SetError implements DashboardTreeRun tell parent we are done

type DashboardEventControlHooks added in v0.17.0

type DashboardEventControlHooks struct {
	CheckRun *CheckRun
}

DashboardEventControlHooks is a struct which implements ControlHooks, and raises ControlComplete and ControlError dashboard events

func NewDashboardEventControlHooks added in v0.17.0

func NewDashboardEventControlHooks(r *CheckRun) *DashboardEventControlHooks

func (*DashboardEventControlHooks) OnComplete added in v0.17.0

func (*DashboardEventControlHooks) OnControlComplete added in v0.17.0

func (*DashboardEventControlHooks) OnControlError added in v0.17.0

func (*DashboardEventControlHooks) OnControlStart added in v0.17.0

func (*DashboardEventControlHooks) OnStart added in v0.17.0

type DashboardExecutionTree

type DashboardExecutionTree struct {
	Root dashboardtypes.DashboardTreeRun
	// contains filtered or unexported fields
}

DashboardExecutionTree is a structure representing the control result hierarchy

func NewDashboardExecutionTree

func NewDashboardExecutionTree(rootName string, sessionId string, client db_common.Client, workspace *workspace.Workspace) (*DashboardExecutionTree, error)

func (*DashboardExecutionTree) AsTreeNode added in v0.19.0

func (*DashboardExecutionTree) BuildSnapshotPanels added in v0.17.0

func (e *DashboardExecutionTree) BuildSnapshotPanels() map[string]dashboardtypes.SnapshotPanel

func (*DashboardExecutionTree) Cancel

func (e *DashboardExecutionTree) Cancel()

func (*DashboardExecutionTree) ChildCompleteChan

func (e *DashboardExecutionTree) ChildCompleteChan() chan dashboardtypes.DashboardTreeRun

ChildCompleteChan implements DashboardParent

func (*DashboardExecutionTree) ChildrenComplete added in v0.19.0

func (e *DashboardExecutionTree) ChildrenComplete() bool

ChildrenComplete implements DashboardParent

func (*DashboardExecutionTree) Execute

func (e *DashboardExecutionTree) Execute(ctx context.Context)

func (*DashboardExecutionTree) GetChildren added in v0.19.0

GetChildren implements DashboardParent

func (*DashboardExecutionTree) GetError added in v0.19.0

func (e *DashboardExecutionTree) GetError() error

func (*DashboardExecutionTree) GetInputsDependingOn added in v0.19.0

func (e *DashboardExecutionTree) GetInputsDependingOn(s string) []string

func (*DashboardExecutionTree) GetName

func (e *DashboardExecutionTree) GetName() string

GetName implements DashboardParent use mod short name - this will be the root name for all child runs

func (*DashboardExecutionTree) GetParent added in v0.19.0

GetParent implements DashboardTreeRun

func (*DashboardExecutionTree) GetRunStatus

GetRunStatus returns the stats of the Root run

func (*DashboardExecutionTree) GetTitle added in v0.19.0

func (e *DashboardExecutionTree) GetTitle() string

func (*DashboardExecutionTree) Initialise added in v0.19.0

func (e *DashboardExecutionTree) Initialise(ctx context.Context)

func (*DashboardExecutionTree) InputRuntimeDependencies added in v0.19.0

func (e *DashboardExecutionTree) InputRuntimeDependencies() []string

InputRuntimeDependencies returns the names of all inputs which are runtime dependencies

func (*DashboardExecutionTree) RunComplete added in v0.19.0

func (e *DashboardExecutionTree) RunComplete() bool

func (*DashboardExecutionTree) SetComplete added in v0.19.0

func (e *DashboardExecutionTree) SetComplete(ctx context.Context)

func (*DashboardExecutionTree) SetError

func (e *DashboardExecutionTree) SetError(ctx context.Context, err error)

SetError sets the error on the Root run

func (*DashboardExecutionTree) SetInputValues added in v0.19.0

func (e *DashboardExecutionTree) SetInputValues(inputValues map[string]any)

type DashboardExecutor

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

func (*DashboardExecutor) CancelExecutionForSession

func (e *DashboardExecutor) CancelExecutionForSession(_ context.Context, sessionId string)

func (*DashboardExecutor) ExecuteDashboard

func (e *DashboardExecutor) ExecuteDashboard(ctx context.Context, sessionId, dashboardName string, inputs map[string]any, workspace *workspace.Workspace, client db_common.Client) (err error)

func (*DashboardExecutor) LoadSnapshot added in v0.17.0

func (e *DashboardExecutor) LoadSnapshot(ctx context.Context, sessionId, snapshotName string, w *workspace.Workspace) (map[string]any, error)

func (*DashboardExecutor) OnInputChanged

func (e *DashboardExecutor) OnInputChanged(ctx context.Context, sessionId string, inputs map[string]any, changedInput string) error

type DashboardParentBase

type DashboardParentBase struct {
	DashboardTreeRunBase
	// contains filtered or unexported fields
}

func (*DashboardParentBase) ChildCompleteChan

func (r *DashboardParentBase) ChildCompleteChan() chan dashboardtypes.DashboardTreeRun

func (*DashboardParentBase) ChildrenComplete

func (r *DashboardParentBase) ChildrenComplete() bool

ChildrenComplete implements DashboardTreeRun

func (*DashboardParentBase) GetChildren

GetChildren implements DashboardTreeRun

type DashboardRun

type DashboardRun struct {
	RuntimeDependencyPublisherBase

	Width            int               `json:"width,omitempty"`
	Description      string            `json:"description,omitempty"`
	Display          string            `json:"display,omitempty"`
	Documentation    string            `json:"documentation,omitempty"`
	Tags             map[string]string `json:"tags,omitempty"`
	ErrorString      string            `json:"error,omitempty"`
	NodeType         string            `json:"panel_type"`
	DashboardName    string            `json:"dashboard"`
	SourceDefinition string            `json:"source_definition"`
	// contains filtered or unexported fields
}

DashboardRun is a struct representing a container run

func NewDashboardRun

func NewDashboardRun(dashboard *modconfig.Dashboard, parent dashboardtypes.DashboardParent, executionTree *DashboardExecutionTree) (*DashboardRun, error)

TODO can dashboards have params????

func (*DashboardRun) AsTreeNode

func (r *DashboardRun) AsTreeNode() *dashboardtypes.SnapshotTreeNode

func (*DashboardRun) Execute

func (r *DashboardRun) Execute(ctx context.Context)

Execute implements DashboardRunNode execute all children and wait for them to complete

func (*DashboardRun) GetInput

func (r *DashboardRun) GetInput(name string) (*modconfig.DashboardInput, bool)

GetInput searches for an input with the given name

func (*DashboardRun) GetInputsDependingOn

func (r *DashboardRun) GetInputsDependingOn(changedInputName string) []string

GetInputsDependingOn returns a list o DashboardInputs which have a runtime dependency on the given input

func (*DashboardRun) Initialise

func (r *DashboardRun) Initialise(ctx context.Context)

Initialise implements DashboardRunNode

func (*DashboardRun) IsSnapshotPanel

func (*DashboardRun) IsSnapshotPanel()

IsSnapshotPanel implements SnapshotPanel

func (*DashboardRun) SetComplete

func (r *DashboardRun) SetComplete(context.Context)

SetComplete implements DashboardTreeRun

func (*DashboardRun) SetError

func (r *DashboardRun) SetError(_ context.Context, err error)

SetError implements DashboardTreeRun tell parent we are done

type DashboardTreeRunBase

type DashboardTreeRunBase struct {
	Name   string                            `json:"name"`
	Title  string                            `json:"title,omitempty"`
	Status dashboardtypes.DashboardRunStatus `json:"status"`
	// contains filtered or unexported fields
}

func (*DashboardTreeRunBase) GetError

func (r *DashboardTreeRunBase) GetError() error

GetError implements DashboardTreeRun

func (*DashboardTreeRunBase) GetInputsDependingOn

func (r *DashboardTreeRunBase) GetInputsDependingOn(_ string) []string

GetInputsDependingOn implements DashboardTreeRun defaults to nothing

func (*DashboardTreeRunBase) GetName

func (r *DashboardTreeRunBase) GetName() string

GetName implements DashboardTreeRun

func (*DashboardTreeRunBase) GetParent

GetParent implements DashboardTreeRun

func (*DashboardTreeRunBase) GetRunStatus

GetRunStatus implements DashboardTreeRun

func (*DashboardTreeRunBase) GetTitle

func (r *DashboardTreeRunBase) GetTitle() string

GetTitle implements DashboardTreeRun

func (*DashboardTreeRunBase) RunComplete

func (r *DashboardTreeRunBase) RunComplete() bool

RunComplete implements DashboardTreeRun

type LeafRun

type LeafRun struct {
	RuntimeDependencyPublisherBase

	Width            int                         `json:"width,omitempty"`
	Type             string                      `cty:"type" hcl:"type" column:"type,text" json:"display_type,omitempty"`
	Display          string                      `cty:"display" hcl:"display" json:"display,omitempty"`
	RawSQL           string                      `json:"sql,omitempty"`
	Data             *dashboardtypes.LeafData    `json:"data,omitempty"`
	ErrorString      string                      `json:"error,omitempty"`
	Resource         modconfig.DashboardLeafNode `json:"properties,omitempty"`
	NodeType         string                      `json:"panel_type"`
	DashboardName    string                      `json:"dashboard"`
	SourceDefinition string                      `json:"source_definition"`
	// a list of the (scoped) names of any `withs` that we rely on
	DependencyWiths []string                  `json:"withs,omitempty"`
	TimingResult    *queryresult.TimingResult `json:"-"`
	// contains filtered or unexported fields
}

LeafRun is a struct representing the execution of a leaf dashboard node

func NewLeafRun

func NewLeafRun(resource modconfig.DashboardLeafNode, parent dashboardtypes.DashboardParent, executionTree *DashboardExecutionTree) (*LeafRun, error)

func (*LeafRun) AsTreeNode

func (r *LeafRun) AsTreeNode() *dashboardtypes.SnapshotTreeNode

func (*LeafRun) Execute

func (r *LeafRun) Execute(ctx context.Context)

Execute implements DashboardRunNode

func (*LeafRun) IsSnapshotPanel

func (*LeafRun) IsSnapshotPanel()

IsSnapshotPanel implements SnapshotPanel

func (*LeafRun) SetComplete

func (r *LeafRun) SetComplete(ctx context.Context)

SetComplete implements DashboardTreeRun

func (*LeafRun) SetError

func (r *LeafRun) SetError(ctx context.Context, err error)

SetError implements DashboardTreeRun

type RuntimeDependencyPublishOption added in v0.19.0

type RuntimeDependencyPublishOption = func(target *RuntimeDependencyPublishTarget)

type RuntimeDependencyPublishTarget added in v0.19.0

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

type RuntimeDependencyPublisher added in v0.19.0

type RuntimeDependencyPublisher interface {
	dashboardtypes.DashboardTreeRun
	ProvidesRuntimeDependency(dependency *modconfig.RuntimeDependency) bool
	SubscribeToRuntimeDependency(name string, opts ...RuntimeDependencyPublishOption) chan *dashboardtypes.ResolvedRuntimeDependencyValue
	PublishRuntimeDependencyValue(name string, result *dashboardtypes.ResolvedRuntimeDependencyValue)
	GetWithRuns() map[string]*LeafRun
}

type RuntimeDependencyPublisherBase

type RuntimeDependencyPublisherBase struct {
	DashboardParentBase
	Args   []any                 `json:"args,omitempty"`
	Params []*modconfig.ParamDef `json:"params,omitempty"`
	// contains filtered or unexported fields
}

func (*RuntimeDependencyPublisherBase) AsTreeNode

func (*RuntimeDependencyPublisherBase) Execute

func (*RuntimeDependencyPublisherBase) FindRuntimeDependenciesForParent

func (b *RuntimeDependencyPublisherBase) FindRuntimeDependenciesForParent(parentProperty string) []*dashboardtypes.ResolvedRuntimeDependency

func (*RuntimeDependencyPublisherBase) FindRuntimeDependencyForParent

func (b *RuntimeDependencyPublisherBase) FindRuntimeDependencyForParent(parentProperty string) *dashboardtypes.ResolvedRuntimeDependency

func (*RuntimeDependencyPublisherBase) GetName

func (*RuntimeDependencyPublisherBase) GetWithRuns

func (b *RuntimeDependencyPublisherBase) GetWithRuns() map[string]*LeafRun

func (*RuntimeDependencyPublisherBase) Initialise

func (*RuntimeDependencyPublisherBase) ProvidesRuntimeDependency

func (b *RuntimeDependencyPublisherBase) ProvidesRuntimeDependency(dependency *modconfig.RuntimeDependency) bool

func (*RuntimeDependencyPublisherBase) PublishRuntimeDependencyValue

func (b *RuntimeDependencyPublisherBase) PublishRuntimeDependencyValue(name string, result *dashboardtypes.ResolvedRuntimeDependencyValue)

func (*RuntimeDependencyPublisherBase) SetComplete

func (*RuntimeDependencyPublisherBase) SetError

func (*RuntimeDependencyPublisherBase) SubscribeToRuntimeDependency

Jump to

Keyboard shortcuts

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