-
Notifications
You must be signed in to change notification settings - Fork 3
/
interfaces.go
128 lines (114 loc) · 3.43 KB
/
interfaces.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package modconfig
import (
"github.com/hashicorp/hcl/v2"
"github.com/turbot/pipe-fittings/printers"
"github.com/zclconf/go-cty/cty"
)
// HclResource must be implemented by resources defined in HCL
type HclResource interface {
printers.Showable
printers.Listable
Name() string
GetTitle() string
GetUnqualifiedName() string
GetShortName() string
OnDecoded(*hcl.Block, ResourceMapsProvider) hcl.Diagnostics
GetDeclRange() *hcl.Range
BlockType() string
GetDescription() string
GetDocumentation() string
GetTags() map[string]string
SetTopLevel(bool)
IsTopLevel() bool
GetBase() HclResource
GetHclResourceImpl() *HclResourceImpl
}
// ModTreeItem must be implemented by elements of the mod resource hierarchy
// i.e. Control, Benchmark, Dashboard
type ModTreeItem interface {
HclResource
ModItem
DatabaseItem
AddParent(ModTreeItem) error
GetParents() []ModTreeItem
GetChildren() []ModTreeItem
// GetPaths returns an array resource paths
GetPaths() []NodePath
SetPaths()
GetModTreeItemImpl() *ModTreeItemImpl
IsDependencyResource() bool
}
type DatabaseItem interface {
GetDatabase() *string
GetSearchPath() []string
GetSearchPathPrefix() []string
}
type ModItem interface {
GetMod() *Mod
}
// RuntimeDependencyProvider is implemented by all QueryProviders and Dashboard
type RuntimeDependencyProvider interface {
ModTreeItem
AddRuntimeDependencies([]*RuntimeDependency)
GetRuntimeDependencies() map[string]*RuntimeDependency
}
type WithProvider interface {
AddWith(with *DashboardWith) hcl.Diagnostics
GetWiths() []*DashboardWith
GetWith(string) (*DashboardWith, bool)
}
// QueryProvider must be implemented by resources which have query/sql
type QueryProvider interface {
RuntimeDependencyProvider
GetArgs() *QueryArgs
GetParams() []*ParamDef
GetSQL() *string
GetQuery() *Query
SetArgs(*QueryArgs)
SetParams([]*ParamDef)
GetResolvedQuery(*QueryArgs) (*ResolvedQuery, error)
RequiresExecution(QueryProvider) bool
ValidateQuery() hcl.Diagnostics
MergeParentArgs(QueryProvider, QueryProvider) hcl.Diagnostics
GetQueryProviderImpl() *QueryProviderImpl
ParamsInheritedFromBase() bool
ArgsInheritedFromBase() bool
}
type CtyValueProvider interface {
CtyValue() (cty.Value, error)
}
// ResourceWithMetadata must be implemented by resources which supports reflection metadata
type ResourceWithMetadata interface {
Name() string
GetMetadata() *ResourceMetadata
SetMetadata(metadata *ResourceMetadata)
SetAnonymous(block *hcl.Block)
IsAnonymous() bool
AddReference(ref *ResourceReference)
GetReferences() []*ResourceReference
}
// DashboardLeafNode must be implemented by resources may be a leaf node in the dashboard execution tree
type DashboardLeafNode interface {
ModTreeItem
ResourceWithMetadata
GetDisplay() string
GetType() string
GetWidth() int
}
type ResourceMapsProvider interface {
GetResourceMaps() *ResourceMaps
GetResource(parsedName *ParsedResourceName) (resource HclResource, found bool)
}
// NodeAndEdgeProvider must be implemented by any dashboard leaf node which supports edges and nodes
// (DashboardGraph, DashboardFlow, DashboardHierarchy)
// TODO [node_reuse] add NodeAndEdgeProviderImpl https://github.com/turbot/steampipe/issues/2918
type NodeAndEdgeProvider interface {
QueryProvider
WithProvider
GetEdges() DashboardEdgeList
SetEdges(DashboardEdgeList)
GetNodes() DashboardNodeList
SetNodes(DashboardNodeList)
AddCategory(category *DashboardCategory) hcl.Diagnostics
AddChild(child HclResource) hcl.Diagnostics
}