Documentation ¶
Index ¶
- Constants
- Variables
- func BuildModResourceName(blockType ModBlockType, name string) string
- func GetCtyTypes(item interface{}) map[string]cty.Type
- func PropertyPathToResourceName(propertyPath string) (string, error)
- func PseudoResourceNameFromPath(modPath, filePath string) (string, error)
- func RegisteredFileExtensions() []string
- type Connection
- type Control
- func (c *Control) AddChild(child ControlTreeItem) error
- func (c *Control) CtyValue() (cty.Value, error)
- func (c *Control) GetMetadata() *ResourceMetadata
- func (c *Control) GetParentName() string
- func (c *Control) Name() string
- func (c *Control) Path() []string
- func (c *Control) QualifiedName() string
- func (c *Control) SetMetadata(metadata *ResourceMetadata)
- func (c *Control) SetParent(parent ControlTreeItem) error
- func (c *Control) String() string
- type ControlGroup
- func (c *ControlGroup) AddChild(child ControlTreeItem) error
- func (c *ControlGroup) CtyValue() (cty.Value, error)
- func (c *ControlGroup) GetChildControls() []*Control
- func (c *ControlGroup) GetMetadata() *ResourceMetadata
- func (c *ControlGroup) GetParentName() string
- func (c *ControlGroup) Name() string
- func (c *ControlGroup) Path() []string
- func (c *ControlGroup) QualifiedName() string
- func (c *ControlGroup) SetMetadata(metadata *ResourceMetadata)
- func (c *ControlGroup) SetParent(parent ControlTreeItem) error
- func (c *ControlGroup) String() string
- type ControlGroupName
- type ControlTreeItem
- type HclResource
- type Local
- type MappableResource
- type Mod
- func (m *Mod) AddChild(child ControlTreeItem) error
- func (m *Mod) AddPseudoResource(resource MappableResource)
- func (m *Mod) AddResource(item HclResource) bool
- func (m *Mod) BuildControlTree() error
- func (m *Mod) ControlTreeItemFromName(fullName string) (ControlTreeItem, error)
- func (m *Mod) CtyValue() (cty.Value, error)
- func (m *Mod) GetMetadata() *ResourceMetadata
- func (m *Mod) GetParentName() string
- func (m *Mod) IsControlTreeItem()
- func (m *Mod) IsDefaultMod() bool
- func (m *Mod) Name() string
- func (m *Mod) Path() []string
- func (m *Mod) Schema() *hcl.BodySchema
- func (m *Mod) SetMetadata(metadata *ResourceMetadata)
- func (m *Mod) SetParent(ControlTreeItem) error
- func (m *Mod) String() string
- type ModBlockType
- type ModMap
- type ModVersion
- type OpenGraph
- type ParsedPropertyPath
- type ParsedResourceName
- type PluginVersion
- type Query
- func (q *Query) CtyValue() (cty.Value, error)
- func (q *Query) GetMetadata() *ResourceMetadata
- func (q *Query) InitialiseFromFile(modPath, filePath string) (MappableResource, []byte, error)
- func (q *Query) Name() string
- func (q *Query) QualifiedName() string
- func (q *Query) SetMetadata(metadata *ResourceMetadata)
- func (q *Query) String() string
- type Requires
- type ResourceMetadata
- type ResourceWithMetadata
- type WorkspaceResourceMaps
Constants ¶
const ( BlockTypeMod ModBlockType = "mod" BlockTypeQuery = "query" BlockTypeControl = "control" BlockTypeControlGroup = "control_group" BlockTypeLocals = "locals" BlockTypeOpengraph = "opengraph" BlockTypeRequires = "requires" BlockTypePluginVersion = "plugin" BlockTypeModVersion = "mod" BlockTypeSteampipeVersion = "steampipe" )
Variables ¶
var ResourceTypeMap = map[string]factoryFunc{ constants.SqlExtension: func(modPath, filePath string) (MappableResource, []byte, error) { return QueryFromFile(modPath, filePath) }, }
Functions ¶
func BuildModResourceName ¶ added in v0.5.0
func BuildModResourceName(blockType ModBlockType, name string) string
func GetCtyTypes ¶ added in v0.5.0
GetCtyTypes build map of cty types for all teagged properties - used to convert the struct to a cty value
func PropertyPathToResourceName ¶ added in v0.5.0
func PseudoResourceNameFromPath ¶
PseudoResourceNameFromPath :: convert a filepath into a resource name: 1) get filename 2) remove extension 3) sluggify, with '_' as the divider
func RegisteredFileExtensions ¶
func RegisteredFileExtensions() []string
Types ¶
type Connection ¶ added in v0.5.0
type Connection struct { // connection name Name string // Name of plugin Plugin string // unparsed HCL of plugin specific connection config Config string // options Options *options.Connection }
Connection :: structure representing the partially parsed connection.
func (*Connection) SetOptions ¶ added in v0.5.0
func (c *Connection) SetOptions(opts options.Options, block *hcl.Block) hcl.Diagnostics
SetOptions : set the options on the connection verify the options is a valid options type (only options.Connection currently supported)
func (*Connection) String ¶ added in v0.5.0
func (c *Connection) String() string
type Control ¶ added in v0.5.0
type Control struct { ShortName string FullName string `cty:"name"` Description *string `cty:"description" hcl:"description" column_type:"text"` Documentation *string `cty:"documentation" hcl:"documentation" column_type:"text"` Labels *[]string `cty:"labels" hcl:"labels" column_type:"jsonb"` Links *[]string `cty:"links" hcl:"links" column_type:"jsonb"` Tags *map[string]string `cty:"tags" hcl:"tags" column_type:"jsonb"` ParentName *ControlGroupName `cty:"parent" hcl:"parent" column_type:"text"` SQL *string `cty:"sql" hcl:"sql" column_type:"text"` Severity *string `cty:"severity" hcl:"severity" column_type:"text"` Title *string `cty:"title" hcl:"title" column_type:"text"` DeclRange hcl.Range // contains filtered or unexported fields }
Control :: struct representing the control mod resource
func NewControl ¶ added in v0.5.0
func NewControl(block *hcl.Block) *Control
func (*Control) AddChild ¶ added in v0.5.0
func (c *Control) AddChild(child ControlTreeItem) error
AddChild :: implementation of ControlTreeItem - controls cannot have children so just return error
func (*Control) GetMetadata ¶ added in v0.5.0
func (c *Control) GetMetadata() *ResourceMetadata
GetMetadata :: implementation of HclResource
func (*Control) GetParentName ¶
GetParentName :: implementation of ControlTreeItem
func (*Control) Name ¶ added in v0.5.0
Name :: implementation of ControlTreeItem, HclResource return name in format: 'control.<shortName>'
func (*Control) QualifiedName ¶ added in v0.5.0
QualifiedName :: name in format: '<modName>.control.<shortName>'
func (*Control) SetMetadata ¶ added in v0.5.0
func (c *Control) SetMetadata(metadata *ResourceMetadata)
SetMetadata :: implementation of HclResource
func (*Control) SetParent ¶
func (c *Control) SetParent(parent ControlTreeItem) error
SetParent :: implementation of ControlTreeItem
type ControlGroup ¶
type ControlGroup struct { ShortName string FullName string `cty:"name"` Description *string `cty:"description" hcl:"description" column_type:"text"` Documentation *string `cty:"documentation" hcl:"documentation" column_type:"text"` Labels *[]string `cty:"labels" hcl:"labels" column_type:"jsonb"` Tags *map[string]string `cty:"tags" hcl:"tags" column_type:"jsonb"` ParentName *ControlGroupName `cty:"parent" hcl:"parent" column_type:"text"` Title *string `cty:"title" hcl:"title" column_type:"text"` DeclRange hcl.Range // contains filtered or unexported fields }
ControlGroup :: struct representing the control group mod resource
func NewControlGroup ¶
func NewControlGroup(block *hcl.Block) *ControlGroup
func (*ControlGroup) AddChild ¶
func (c *ControlGroup) AddChild(child ControlTreeItem) error
AddChild :: implementation of ControlTreeItem
func (*ControlGroup) GetChildControls ¶
func (c *ControlGroup) GetChildControls() []*Control
GetChildControls :: return a flat list of controls underneath us in the tree
func (*ControlGroup) GetMetadata ¶
func (c *ControlGroup) GetMetadata() *ResourceMetadata
GetMetadata :: implementation of HclResource
func (*ControlGroup) GetParentName ¶
func (c *ControlGroup) GetParentName() string
GetParentName :: implementation of ControlTreeItem
func (*ControlGroup) Name ¶
func (c *ControlGroup) Name() string
Name :: implementation of ControlTreeItem, HclResource return name in format: 'control.<shortName>'
func (*ControlGroup) Path ¶
func (c *ControlGroup) Path() []string
Path :: implementation of ControlTreeItem
func (*ControlGroup) QualifiedName ¶
func (c *ControlGroup) QualifiedName() string
QualifiedName :: name in format: '<modName>.control.<shortName>'
func (*ControlGroup) SetMetadata ¶
func (c *ControlGroup) SetMetadata(metadata *ResourceMetadata)
SetMetadata :: implementation of HclResource
func (*ControlGroup) SetParent ¶
func (c *ControlGroup) SetParent(parent ControlTreeItem) error
SetParent :: implementation of ControlTreeItem
func (*ControlGroup) String ¶
func (c *ControlGroup) String() string
type ControlGroupName ¶
type ControlGroupName struct {
Name string `cty:"name"`
}
func (ControlGroupName) String ¶
func (c ControlGroupName) String() string
type ControlTreeItem ¶ added in v0.5.0
type ControlTreeItem interface { // GetParentName :: get the name of the parent of this item GetParentName() string // SetParent :: set the parent of this item SetParent(ControlTreeItem) error // AddChild :: add a child to the item AddChild(child ControlTreeItem) error // Name :: name in the format <type>.<name> Name() string // Path ::array of parents in the control hiearchy Path() []string }
type HclResource ¶ added in v0.5.0
HclResource :: a resource which is defined in HCL - must be implemented by resource with attributes to parse
type Local ¶ added in v0.5.0
type Local struct { ShortName string FullName string `cty:"name"` Value cty.Value DeclRange hcl.Range // contains filtered or unexported fields }
func (*Local) GetMetadata ¶ added in v0.5.0
func (l *Local) GetMetadata() *ResourceMetadata
GetMetadata :: implementation of HclResource
func (*Local) Schema ¶
func (l *Local) Schema() *hcl.BodySchema
Schema :: implementation of HclResource
func (*Local) SetMetadata ¶ added in v0.5.0
func (l *Local) SetMetadata(metadata *ResourceMetadata)
SetMetadata :: implementation of HclResource
type MappableResource ¶
type MappableResource interface { InitialiseFromFile(modPath, filePath string) (MappableResource, []byte, error) Name() string GetMetadata() *ResourceMetadata SetMetadata(*ResourceMetadata) }
MappableResource :: a mod resource which can be created directly from a content file (e.g. sql, markdown) InitialiseFromFile :: initialise the mod resource from the file of the given path return the created resource, and the file data
func QueryFromFile ¶
func QueryFromFile(modPath, filePath string) (MappableResource, []byte, error)
QueryFromFile :: factory function
type Mod ¶
type Mod struct { ShortName string `hcl:"name,label"` FullName string `cty:"name"` // attributes Color *string `cty:"color" hcl:"color" column_type:"text"` Description *string `cty:"description" hcl:"description" column_type:"text"` Documentation *string `cty:"documentation" hcl:"documentation" column_type:"text"` Icon *string `cty:"icon" hcl:"icon" column_type:"text"` Labels *[]string `cty:"labels" hcl:"labels" column_type:"jsonb"` Tags *map[string]string `cty:"tags" hcl:"tags" column_type:"jsonb"` Title *string `cty:"title" hcl:"title" column_type:"text"` // blocks Requires *Requires `hcl:"requires,block"` OpenGraph *OpenGraph `hcl:"opengraph,block"` // TODO do we need this? Version *string Queries map[string]*Query Controls map[string]*Control ControlGroups map[string]*ControlGroup ModPath string DeclRange hcl.Range // contains filtered or unexported fields }
func CreateDefaultMod ¶ added in v0.5.0
CreateDefaultMod :: create a default mod created for a workspace with no mod definition
func (*Mod) AddChild ¶ added in v0.5.0
func (m *Mod) AddChild(child ControlTreeItem) error
AddChild :: implementation of ControlTreeItem
func (*Mod) AddPseudoResource ¶ added in v0.5.0
func (m *Mod) AddPseudoResource(resource MappableResource)
AddPseudoResource :: add resource to parse results, if there is no resource of same name
func (*Mod) AddResource ¶ added in v0.5.0
func (m *Mod) AddResource(item HclResource) bool
func (*Mod) BuildControlTree ¶ added in v0.5.0
func (*Mod) ControlTreeItemFromName ¶
func (m *Mod) ControlTreeItemFromName(fullName string) (ControlTreeItem, error)
func (*Mod) GetMetadata ¶ added in v0.5.0
func (m *Mod) GetMetadata() *ResourceMetadata
GetMetadata :: implementation of HclResource
func (*Mod) GetParentName ¶
GetParentName :: implementation of ControlTreeItem
func (*Mod) IsControlTreeItem ¶ added in v0.5.0
func (m *Mod) IsControlTreeItem()
IsControlTreeItem :: implementation of ControlTreeItem (mod is always top of the tree)
func (*Mod) IsDefaultMod ¶ added in v0.5.0
IsDefaultMod :: is this mod a default mod created for a workspace with no mod definition
func (*Mod) SetMetadata ¶ added in v0.5.0
func (m *Mod) SetMetadata(metadata *ResourceMetadata)
SetMetadata :: implementation of HclResource
func (*Mod) SetParent ¶
func (m *Mod) SetParent(ControlTreeItem) error
SetParent :: implementation of ControlTreeItem
type ModBlockType ¶ added in v0.5.0
type ModBlockType string
type ModVersion ¶
type ModVersion struct { // the fully qualified mod name, e.g. github.com/turbot/mod1 // TODO THINK ABOUT NAMES ShortName string `hcl:"name,label"` FullName string `cty:"name"` Version string `cty:"version" hcl:"version"` Alias *string `cty:"alias" hcl:"alias,optional"` DeclRange hcl.Range }
func (*ModVersion) HasVersion ¶
func (m *ModVersion) HasVersion() bool
HasVersion :: if no version is specified, or the version is "latest", this is the latest version
func (*ModVersion) String ¶
func (m *ModVersion) String() string
type OpenGraph ¶ added in v0.5.0
type OpenGraph struct { // The opengraph description (og:description) of the mod, for use in social media applications Description string `cty:"description" hcl:"description"` // The opengraph display title (og:title) of the mod, for use in social media applications. Title string `cty:"title" hcl:"title"` DeclRange hcl.Range }
type ParsedPropertyPath ¶ added in v0.5.0
type ParsedPropertyPath struct { Mod string ItemType ModBlockType Name string PropertyPath []string }
func ParseResourcePropertyPath ¶ added in v0.5.0
func ParseResourcePropertyPath(propertyPath string) (res *ParsedPropertyPath, err error)
type ParsedResourceName ¶ added in v0.5.0
type ParsedResourceName struct { Mod string ItemType ModBlockType Name string }
func ParseResourceName ¶ added in v0.5.0
func ParseResourceName(fullName string) (res *ParsedResourceName, err error)
func (*ParsedResourceName) TypeString ¶ added in v0.5.0
func (m *ParsedResourceName) TypeString() string
type PluginVersion ¶ added in v0.5.0
type PluginVersion struct { // the fully qualified plugin name, e.g. github.com/turbot/mod1 Name string `cty:"name" hcl:"name,label"` // the version STREAM, can be either a major or minor version stream i.e. 1 or 1.1 Version string `cty:"version" hcl:"version,optional"` DeclRange hcl.Range }
func (*PluginVersion) FullName ¶ added in v0.5.0
func (p *PluginVersion) FullName() string
func (*PluginVersion) String ¶ added in v0.5.0
func (p *PluginVersion) String() string
type Query ¶
type Query struct { ShortName string FullName string `cty:"name"` Description *string `cty:"description" hcl:"description" column_type:"text"` Documentation *string `cty:"documentation" hcl:"documentation" column_type:"text"` Labels *[]string `cty:"labels" hcl:"labels" column_type:"jsonb"` Tags *map[string]string `cty:"tags" hcl:"tags" column_type:"jsonb"` SQL *string `cty:"sql" hcl:"sql" column_type:"text"` SearchPath *string `cty:"search_path" hcl:"search_path" column_type:"text"` SearchPathPrefix *string `cty:"search_path_prefix" hcl:"search_path_prefix" column_type:"text"` Title *string `cty:"title" hcl:"title" column_type:"text"` DeclRange hcl.Range // contains filtered or unexported fields }
func (*Query) GetMetadata ¶ added in v0.5.0
func (q *Query) GetMetadata() *ResourceMetadata
GetMetadata :: implementation of HclResource and MappableResource
func (*Query) InitialiseFromFile ¶
func (q *Query) InitialiseFromFile(modPath, filePath string) (MappableResource, []byte, error)
InitialiseFromFile :: implementation of MappableResource
func (*Query) QualifiedName ¶ added in v0.5.0
QualifiedName :: name in format: '<modName>.control.<shortName>'
func (*Query) SetMetadata ¶ added in v0.5.0
func (q *Query) SetMetadata(metadata *ResourceMetadata)
SetMetadata :: implementation of MappableResource, HclResource
type Requires ¶ added in v0.5.0
type Requires struct { Steampipe string `hcl:"steampipe,optional"` Plugins []*PluginVersion `hcl:"plugin,block"` Mods []*ModVersion `hcl:"mod,block"` DeclRange hcl.Range }
Requires :: struct mod dependencies
type ResourceMetadata ¶ added in v0.5.0
type ResourceMetadata struct { ResourceName string `hcl:"resource_name" column_type:"text"` // mod name in the format mod.<modName>@<version? ModName string `hcl:"mod_name" column_type:"text"` FileName string `hcl:"file_name" column_type:"text"` StartLineNumber int `hcl:"start_line_number" column_type:"integer"` EndLineNumber int `hcl:"end_line_number" column_type:"integer"` IsAutoGenerated bool `hcl:"auto_generated" column_type:"bool"` SourceDefinition string `hcl:"source_definition" column_type:"text"` // mod short name ModShortName string }
ResourceMetadata :: additional data we collect about each resource to populate the reflection tables
func (*ResourceMetadata) SetMod ¶ added in v0.5.0
func (m *ResourceMetadata) SetMod(mod *Mod)
SetMod set the mod name and mod short name
type ResourceWithMetadata ¶ added in v0.5.0
type ResourceWithMetadata interface { Name() string GetMetadata() *ResourceMetadata SetMetadata(metadata *ResourceMetadata) }
ResourceWithMetadata :: a resource which supports reflection metadata
type WorkspaceResourceMaps ¶ added in v0.5.0
type WorkspaceResourceMaps struct { ModMap map[string]*Mod QueryMap map[string]*Query ControlMap map[string]*Control ControlGroupMap map[string]*ControlGroup }
WorkspaceResourceMaps :: maps of all mod resource types provided to avoid db needing to reference workspace package