mirror of
https://github.com/turbot/steampipe.git
synced 2026-02-18 22:00:12 -05:00
Remove redundant code. Add issues to TODOs.
This commit is contained in:
@@ -33,7 +33,7 @@ func NewCheckRun(resource modconfig.DashboardLeafNode, parent dashboardtypes.Das
|
||||
c := &CheckRun{SessionId: executionTree.sessionId}
|
||||
// create NewDashboardTreeRunImpl
|
||||
// (we must create after creating the run as it requires a ref to the run)
|
||||
// TODO [node_reuse] do this a different way
|
||||
// TODO [node_reuse] do this a different way https://github.com/turbot/steampipe/issues/2919
|
||||
c.DashboardTreeRunImpl = NewDashboardTreeRunImpl(resource, parent, c, executionTree)
|
||||
|
||||
// verify node type
|
||||
|
||||
@@ -34,7 +34,7 @@ func NewDashboardContainerRun(container *modconfig.DashboardContainer, parent da
|
||||
r := &DashboardContainerRun{dashboardNode: container}
|
||||
// create NewDashboardTreeRunImpl
|
||||
// (we must create after creating the run as it requires a ref to the run)
|
||||
// TODO [node_reuse] do this a different way
|
||||
// TODO [node_reuse] do this a different way https://github.com/turbot/steampipe/issues/2919
|
||||
r.DashboardTreeRunImpl = NewDashboardTreeRunImpl(container, parent, r, executionTree)
|
||||
|
||||
if container.Title != nil {
|
||||
|
||||
@@ -94,7 +94,7 @@ func (r *DashboardParentImpl) waitForChildrenAsync() chan error {
|
||||
|
||||
log.Printf("[TRACE] %s ALL children and withs complete, errors: %v", r.Name, errors)
|
||||
// so all children have completed - check for errors
|
||||
// TODO [node_reuse] format better error
|
||||
// TODO [node_reuse] format better error https://github.com/turbot/steampipe/issues/2920
|
||||
doneChan <- error_helpers.CombineErrors(errors...)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ func NewDashboardRun(dashboard *modconfig.Dashboard, parent dashboardtypes.Dashb
|
||||
}
|
||||
// create RuntimeDependencyPublisherImpl- this handles 'with' run creation and resolving runtime dependency resolution
|
||||
// (we must create after creating the run as it requires a ref to the run)
|
||||
// TODO [node_reuse] do this a different way
|
||||
// TODO [node_reuse] do this a different way https://github.com/turbot/steampipe/issues/2919
|
||||
r.RuntimeDependencyPublisherImpl = NewRuntimeDependencyPublisherImpl(dashboard, parent, r, executionTree)
|
||||
// add r into execution tree BEFORE creating child runs or initialising runtime depdencies
|
||||
// - this is so child runs can find this dashboard run
|
||||
@@ -160,7 +160,7 @@ func (r *DashboardRun) createChildRuns(executionTree *DashboardExecutionTree) er
|
||||
|
||||
// TACTICAL: as this is a runtime dependency, set the run name to the 'scoped name'
|
||||
// this is to match the name in the panel dependendencies
|
||||
// TODO [node_reuse] tidy this
|
||||
// TODO [node_reuse] consider naming https://github.com/turbot/steampipe/issues/2921
|
||||
inputRunName := fmt.Sprintf("%s.%s", r.DashboardName, i.UnqualifiedName)
|
||||
childRun, err = NewLeafRun(i.Clone(), r, executionTree, setName(inputRunName))
|
||||
if err != nil {
|
||||
|
||||
@@ -30,8 +30,7 @@ type DashboardTreeRunImpl struct {
|
||||
resource modconfig.DashboardLeafNode
|
||||
// store the top level run which embeds this struct
|
||||
// we need this for setStatus which serialises the run for the message payload
|
||||
run dashboardtypes.DashboardTreeRun
|
||||
executeConfig dashboardtypes.TreeRunExecuteConfig
|
||||
run dashboardtypes.DashboardTreeRun
|
||||
}
|
||||
|
||||
func NewDashboardTreeRunImpl(resource modconfig.DashboardLeafNode, parent dashboardtypes.DashboardParent, run dashboardtypes.DashboardTreeRun, executionTree *DashboardExecutionTree) DashboardTreeRunImpl {
|
||||
@@ -129,9 +128,6 @@ func (r *DashboardTreeRunImpl) GetResource() modconfig.DashboardLeafNode {
|
||||
return r.resource
|
||||
}
|
||||
|
||||
// TODO [node_reuse] do this a different way
|
||||
// maybe move to a different embedded struct - ExecutableRun, to differentiate between Base runs
|
||||
|
||||
// SetError implements DashboardTreeRun
|
||||
func (r *DashboardTreeRunImpl) SetError(ctx context.Context, err error) {
|
||||
log.Printf("[TRACE] %s SetError err %v", r.Name, err)
|
||||
@@ -156,15 +152,12 @@ func (r *DashboardTreeRunImpl) SetComplete(context.Context) {
|
||||
|
||||
func (r *DashboardTreeRunImpl) setStatus(status dashboardtypes.DashboardRunStatus) {
|
||||
r.Status = status
|
||||
// do not send events for runtime dependency execution (i.e. when we are executing base resources
|
||||
// for their runtime dependencies)
|
||||
if !r.executeConfig.RuntimeDependenciesOnly {
|
||||
// raise LeafNodeUpdated event
|
||||
// TODO [node_reuse] tidy this up
|
||||
// TACTICAL: pass the full run struct - 'r.run', rather than ourselves - so we serialize all properties
|
||||
e, _ := dashboardevents.NewLeafNodeUpdate(r.run, r.executionTree.sessionId, r.executionTree.id)
|
||||
r.executionTree.workspace.PublishDashboardEvent(e)
|
||||
}
|
||||
// raise LeafNodeUpdated event
|
||||
// TODO [node_reuse] do this a different way https://github.com/turbot/steampipe/issues/2919
|
||||
// TACTICAL: pass the full run struct - 'r.run', rather than ourselves - so we serialize all properties
|
||||
e, _ := dashboardevents.NewLeafNodeUpdate(r.run, r.executionTree.sessionId, r.executionTree.id)
|
||||
r.executionTree.workspace.PublishDashboardEvent(e)
|
||||
|
||||
}
|
||||
|
||||
func (r *DashboardTreeRunImpl) notifyParentOfCompletion() {
|
||||
|
||||
@@ -133,7 +133,7 @@ func (r *LeafRun) Execute(ctx context.Context) {
|
||||
|
||||
// if we have sql to execute, do it now
|
||||
// (if we are only performing a base execution, do not run the query)
|
||||
if r.executeSQL != "" && !r.executeConfig.BaseExecution {
|
||||
if r.executeSQL != "" {
|
||||
if err := r.executeQuery(ctx); err != nil {
|
||||
r.SetError(ctx, err)
|
||||
return
|
||||
|
||||
@@ -22,8 +22,3 @@ type DashboardTreeRun interface {
|
||||
AsTreeNode() *SnapshotTreeNode
|
||||
GetResource() modconfig.DashboardLeafNode
|
||||
}
|
||||
|
||||
type TreeRunExecuteConfig struct {
|
||||
RuntimeDependenciesOnly bool
|
||||
BaseExecution bool
|
||||
}
|
||||
|
||||
@@ -263,9 +263,9 @@ func (d *Dashboard) ValidateRuntimeDependencies(workspace ResourceMapsProvider)
|
||||
}
|
||||
|
||||
func (d *Dashboard) validateRuntimeDependenciesForResource(resource HclResource, workspace ResourceMapsProvider) error {
|
||||
// TODO [node_reuse] re-add parse time validation https://github.com/turbot/steampipe/issues/2925
|
||||
return nil
|
||||
//rdp := resource.(RuntimeDependencyProvider)
|
||||
// TODO [node_reuse] validate param and args runtime deps
|
||||
//// WHAT ABOUT CHILDREN
|
||||
//if len(runtimeDependencies) == 0 {
|
||||
// return nil
|
||||
|
||||
@@ -82,7 +82,7 @@ func (f *DashboardFlow) GetReferences() []*ResourceReference {
|
||||
return f.References
|
||||
}
|
||||
|
||||
// TODO [node_reuse] PUT IN 1 PLACE FOR ALL EDGE PROVIDERS
|
||||
// TODO [node_reuse] Add DashboardLeafNodeImpl and move this there https://github.com/turbot/steampipe/issues/2926
|
||||
// GetChildren implements ModTreeItem
|
||||
func (f *DashboardFlow) GetChildren() []ModTreeItem {
|
||||
// return nodes and edges (if any)
|
||||
|
||||
@@ -84,7 +84,8 @@ func (g *DashboardGraph) GetReferences() []*ResourceReference {
|
||||
return g.References
|
||||
}
|
||||
|
||||
// TODO [node_reuse] PUT IN 1 PLACE FOR ALL EDGE PROVIDERS
|
||||
// TODO [node_reuse] Add DashboardLeafNodeImpl and move this there https://github.com/turbot/steampipe/issues/2926
|
||||
|
||||
// GetChildren implements ModTreeItem
|
||||
func (g *DashboardGraph) GetChildren() []ModTreeItem {
|
||||
// return nodes and edges (if any)
|
||||
|
||||
@@ -84,7 +84,8 @@ func (h *DashboardHierarchy) GetReferences() []*ResourceReference {
|
||||
return h.References
|
||||
}
|
||||
|
||||
// TODO [node_reuse] PUT IN 1 PLACE FOR ALL EDGE PROVIDERS
|
||||
// TODO [node_reuse] Add DashboardLeafNodeImpl and move this there https://github.com/turbot/steampipe/issues/2926
|
||||
|
||||
// GetChildren implements ModTreeItem
|
||||
func (h *DashboardHierarchy) GetChildren() []ModTreeItem {
|
||||
// return nodes and edges (if any)
|
||||
|
||||
@@ -107,7 +107,7 @@ type ResourceMapsProvider interface {
|
||||
|
||||
// NodeAndEdgeProvider must be implemented by any dashboard leaf node which supports edges and nodes
|
||||
// (DashboardGraph, DashboardFlow, DashboardHierarchy)
|
||||
// TODO [node_reuse] add NodeAndEdgeProviderImpl
|
||||
// TODO [node_reuse] add NodeAndEdgeProviderImpl https://github.com/turbot/steampipe/issues/2918
|
||||
type NodeAndEdgeProvider interface {
|
||||
QueryProvider
|
||||
GetEdges() DashboardEdgeList
|
||||
|
||||
@@ -33,9 +33,9 @@ func (d *RuntimeDependency) String() string {
|
||||
}
|
||||
|
||||
func (d *RuntimeDependency) ValidateSource(dashboard *Dashboard, workspace ResourceMapsProvider) error {
|
||||
// TODO [node_reuse] re-add parse time validation https://github.com/turbot/steampipe/issues/2925
|
||||
//resourceName := d.PropertyPath.ToResourceName()
|
||||
var found bool
|
||||
// TODO [node_reuse] validate source resource in resource tree
|
||||
//var found bool
|
||||
////var sourceResource HclResource
|
||||
//switch d.PropertyPath.ItemType {
|
||||
//// if this is a 'with' resolve from the parent resource
|
||||
@@ -51,9 +51,9 @@ func (d *RuntimeDependency) ValidateSource(dashboard *Dashboard, workspace Resou
|
||||
// // // otherwise, resolve from the global inputs
|
||||
// // _, found = workspace.GetResourceMaps().GlobalDashboardInputs[resourceName]
|
||||
//}
|
||||
if !found {
|
||||
return fmt.Errorf("could not resolve runtime dependency resource %s", d.PropertyPath)
|
||||
}
|
||||
//if !found {
|
||||
// return fmt.Errorf("could not resolve runtime dependency resource %s", d.PropertyPath)
|
||||
//}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ func decodeVariable(block *hcl.Block, parseCtx *ModParseContext) (*modconfig.Var
|
||||
func decodeQueryProvider(block *hcl.Block, parseCtx *ModParseContext) (modconfig.QueryProvider, *decodeResult) {
|
||||
res := newDecodeResult()
|
||||
|
||||
// TODO [node_reuse] need raise errors for invalid properties
|
||||
// TODO [node_reuse] need raise errors for invalid properties https://github.com/turbot/steampipe/issues/2923
|
||||
|
||||
// get shell resource
|
||||
resource, diags := resourceForBlock(block, parseCtx)
|
||||
@@ -367,7 +367,7 @@ func decodeQueryProviderBlocks(block *hcl.Block, content *hclsyntax.Body, resour
|
||||
func decodeNodeAndEdgeProvider(block *hcl.Block, parseCtx *ModParseContext) (modconfig.HclResource, *decodeResult) {
|
||||
res := newDecodeResult()
|
||||
|
||||
// TODO [node_reuse] need raise errors for invalid properties - update validateHcl to include attributes
|
||||
// TODO [node_reuse] need raise errors for invalid properties https://github.com/turbot/steampipe/issues/2923
|
||||
|
||||
// get shell resource
|
||||
resource, diags := resourceForBlock(block, parseCtx)
|
||||
|
||||
@@ -329,7 +329,7 @@ func (r *ModParseContext) getResourceCtyValue(resource modconfig.HclResource) (c
|
||||
if ctyValue.Type().FriendlyName() != "object" {
|
||||
return ctyValue, nil
|
||||
}
|
||||
// TODO [node_reuse] fetch nested structs and serialise automatically
|
||||
// TODO [node_reuse] fetch nested structs and serialise automatically https://github.com/turbot/steampipe/issues/2924
|
||||
valueMap := ctyValue.AsValueMap()
|
||||
if valueMap == nil {
|
||||
valueMap = make(map[string]cty.Value)
|
||||
|
||||
@@ -5,8 +5,7 @@ import (
|
||||
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
|
||||
)
|
||||
|
||||
// TODO [node_reuse] Replace everything with consts
|
||||
// TODO [node_reuse] add all attributes into validation-only-schemas
|
||||
// TODO [node_reuse] Replace all block type with consts https://github.com/turbot/steampipe/issues/2922
|
||||
|
||||
var ConfigBlockSchema = &hcl.BodySchema{
|
||||
Attributes: []hcl.AttributeSchema{},
|
||||
@@ -165,7 +164,6 @@ var RequireModBlockSchema = &hcl.BodySchema{
|
||||
}
|
||||
|
||||
// DashboardBlockSchema is only used to validate the blocks of a Dashboard
|
||||
// TODO [node_reuse] add all atttributes and validate these as well
|
||||
var DashboardBlockSchema = &hcl.BodySchema{
|
||||
Blocks: []hcl.BlockHeaderSchema{
|
||||
{
|
||||
@@ -216,7 +214,6 @@ var DashboardBlockSchema = &hcl.BodySchema{
|
||||
}
|
||||
|
||||
// DashboardContainerBlockSchema is only used to validate the blocks of a DashboardContainer
|
||||
// TODO [node_reuse] add all atttributes and validate these as well
|
||||
var DashboardContainerBlockSchema = &hcl.BodySchema{
|
||||
Blocks: []hcl.BlockHeaderSchema{
|
||||
{
|
||||
|
||||
@@ -41,6 +41,7 @@ func validateRuntimeDependencyProvider(resource modconfig.RuntimeDependencyProvi
|
||||
// enrich the loaded nodes and edges with the fully parsed resources from the resourceMapProvider
|
||||
func validateNodeAndEdgeProvider(resource modconfig.NodeAndEdgeProvider) hcl.Diagnostics {
|
||||
// TODO [node_reuse] add NodeAndEdgeProviderImpl and move validate there
|
||||
// https://github.com/turbot/steampipe/issues/2918
|
||||
|
||||
var diags hcl.Diagnostics
|
||||
containsEdgesOrNodes := len(resource.GetEdges())+len(resource.GetNodes()) > 0
|
||||
|
||||
Reference in New Issue
Block a user