Remove redundant code. Add issues to TODOs.

This commit is contained in:
kai
2022-12-23 13:15:14 +00:00
parent ad35401aa6
commit cd80fa28e4
17 changed files with 30 additions and 42 deletions

View File

@@ -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

View File

@@ -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 {

View File

@@ -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...)
}()
}

View File

@@ -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 {

View File

@@ -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() {

View File

@@ -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

View File

@@ -22,8 +22,3 @@ type DashboardTreeRun interface {
AsTreeNode() *SnapshotTreeNode
GetResource() modconfig.DashboardLeafNode
}
type TreeRunExecuteConfig struct {
RuntimeDependenciesOnly bool
BaseExecution bool
}

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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

View File

@@ -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
}

View File

@@ -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)

View File

@@ -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)

View File

@@ -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{
{

View File

@@ -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