config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func GetPluginForFormat added in v0.2.0

func GetPluginForFormat(format *Format) (string, bool)

GetPluginForFormat determines the plugin which provides the given format, using the plugin versions file, Call either GetPluginForFormatPreset or GetPluginForFormatType

func GetPluginForFormatByName added in v0.2.0

func GetPluginForFormatByName(formatName string) (string, bool)

GetPluginForFormatByName returns the plugin name that provides the given format name. Call either GetPluginForFormatPreset or GetPluginForFormatType

func GetPluginForFormatPreset added in v0.2.0

func GetPluginForFormatPreset(fullName string, versionMap map[string]*versionfile.InstalledVersion) (string, bool)

GetPluginForFormatPreset returns the plugin name that provides the given format preset. Format name should be in the format "type.name"

func GetPluginForFormatType added in v0.2.0

func GetPluginForFormatType(typeName string, versionMap map[string]*versionfile.InstalledVersion) (string, bool)

GetPluginForFormatType returns the plugin name that provides the given format type.

func GetPluginForSourceType added in v0.2.0

func GetPluginForSourceType(sourceType string, versionMap map[string]*versionfile.InstalledVersion) string

GetPluginForSourceType returns the plugin name that provides the given source.

func GetPluginForTable added in v0.2.0

func GetPluginForTable(tableName string, versionMap map[string]*versionfile.InstalledVersion) string

GetPluginForTable returns the plugin name that provides the given table. NOTE: this does not check custom tables - if the same table name is a custom table we should use the core plugin we cannot check that here as this function may be called before the config is fully populated

func NewFilter

func NewFilter(block *hcl.Block, fullName string) (modconfig.HclResource, hcl.Diagnostics)

func NewFormat

func NewFormat(block *hcl.Block, fullName string) (modconfig.HclResource, hcl.Diagnostics)

func NewPartition

func NewPartition(block *hcl.Block, fullName string) (modconfig.HclResource, hcl.Diagnostics)

func NewTable

func NewTable(block *hcl.Block, fullName string) (modconfig.HclResource, hcl.Diagnostics)

func NewTailpipeConnection

func NewTailpipeConnection(block *hcl.Block, fullName string) (modconfig.HclResource, hcl.Diagnostics)

func ResourceHasSubtype

func ResourceHasSubtype(blockType string) bool

Types

type Column added in v0.2.0

type Column struct {
	Name        string  `hcl:"name,label" cty:"name"`
	Type        *string `hcl:"type" cty:"type"`
	Source      *string `hcl:"source" cty:"source"`
	Description *string `hcl:"description" cty:"description"`
	Required    *bool   `hcl:"required" cty:"required"`
	NullValue   *string `hcl:"null_value" cty:"null_value"`
}

type Filter

type Filter struct {
	modconfig.HclResourceImpl
	Where *string `hcl:"where"`
}

func (*Filter) CtyValue added in v0.2.0

func (f *Filter) CtyValue() (cty.Value, error)

CtyValue implements CtyValueProvider (note this must be implemented by each resource, we cannot rely on the HclResourceImpl implementation as it will only serialise its own properties) )

type Format

type Format struct {
	modconfig.HclResourceImpl
	// the format type
	Type string `cty:"type"`
	// the raw HCL of the format (this will be decoded by the plugin which implements the format)
	Config *HclBytes `cty:"config"`
	// alternatively, the preset name opf the format
	PresetName string `cty:"preset"`
}

func NewPresetFormat added in v0.2.0

func NewPresetFormat(block *hcl.Block, presetName string) (*Format, hcl.Diagnostics)

func (*Format) CtyValue added in v0.2.0

func (f *Format) CtyValue() (cty.Value, error)

CtyValue implements CtyValueProvider (note this must be implemented by each resource, we cannot rely on the HclResourceImpl implementation as it will only serialise its own properties) )

func (*Format) GetSubType

func (f *Format) GetSubType() string

GetSubType returns the subtype for the format block (the type). The presence of this function indicates this resource supports 3 part names, which affects how it is stored in the eval context

func (*Format) SetConfigHcl

func (f *Format) SetConfigHcl(u *HclBytes)

func (*Format) ToProto

func (f *Format) ToProto() *proto.FormatData

type HclBytes

type HclBytes struct {
	Hcl   []byte           `cty:"hcl"`
	Range hclhelpers.Range `cty:"range"`
}

func HclBytesForLines added in v0.2.0

func HclBytesForLines(sourceHcl []byte, r hcl.Range) *HclBytes

HclBytesForLines extracts the HCL bytes for a given range from a source HCL byte buffer, ensuring that it includes full lines rather than using byte-based slicing.

func HclBytesForRange

func HclBytesForRange(sourceHcl []byte, r hcl.Range) *HclBytes

HclBytesForRange extracts the HCL bytes for a given range from a source HCL byte buffer This is used to extract the HCL for a unknown attributes so we can pass it to a plugin to parse

func (*HclBytes) Merge

func (h *HclBytes) Merge(other *HclBytes)

func (*HclBytes) String added in v0.2.0

func (h *HclBytes) String() string

string

type Partition

type Partition struct {
	modconfig.HclResourceImpl

	// the name of the table this partition is for - this is the first label in the partition block
	TableName string

	// if the partition of for a custom table, this will be set to the custom table config
	CustomTable *Table `cty:"table"`

	// Plugin used for this partition
	Plugin *plugin.Plugin `cty:"-"`

	// Source of the data for this partition
	Source Source `cty:"source"`

	// any partition-type specific config data for the partition
	Config []byte `cty:"config"`
	// the config location
	ConfigRange hclhelpers.Range `cty:"config_range"`
	// an option filter in the format of a SQL where clause
	Filter string
}

func (*Partition) AddFilter

func (c *Partition) AddFilter(filter string)

func (*Partition) CollectionStatePath

func (c *Partition) CollectionStatePath(collectionDir string) string

func (*Partition) CtyValue added in v0.2.0

func (c *Partition) CtyValue() (cty.Value, error)

CtyValue implements CtyValueProvider (note this must be implemented by each resource, we cannot rely on the HclResourceImpl implementation as it will only serialise its own properties) )

func (*Partition) GetFormat added in v0.2.0

func (c *Partition) GetFormat() *Format

GetFormat returns the format for this partition, if either the source or the custom table has one

func (*Partition) InferPluginName

func (c *Partition) InferPluginName(v *versionfile.PluginVersionFile) string

func (*Partition) SetConfigHcl

func (c *Partition) SetConfigHcl(u *HclBytes)

func (*Partition) Validate added in v0.2.0

func (c *Partition) Validate() hcl.Diagnostics

type Source

type Source struct {
	Type       string              `hcl:" type,label" cty:"type"`
	Connection *TailpipeConnection `hcl:"connection" cty:"connection"`
	// optional: the format (for custom tables)
	Format *Format `hcl:"format" cty:"format"`
	// the config hcl
	Config *HclBytes `cty:"config"`
}

func (*Source) SetConfigHcl

func (s *Source) SetConfigHcl(u *HclBytes)

func (*Source) ToProto

func (s *Source) ToProto() *proto.ConfigData

type Table

type Table struct {
	modconfig.HclResourceImpl

	// the default format for this table (todo make a map keyed by source name?)
	DefaultSourceFormat *Format `hcl:"format" cty:"format"`

	Columns []Column `hcl:"column,block" cty:"columns"`

	// should we include ALL source fields in addition to any defined columns, or ONLY include the columns defined
	AutoMapSourceFields bool `hcl:"automap_source_fields,optional" cty:"automap_source_fields"`
	// should we exclude any source fields from the output (only applicable if automap_source_fields is true)
	ExcludeSourceFields []string `hcl:"exclude_source_fields,optional" cty:"exclude_source_fields"`
	// the default null value for the table (may be overridden for specific columns)
	NullValue string `hcl:"null_value,optional" cty:"null_value"`
}

Table is a struct representing a custom table definition

func (*Table) CtyValue added in v0.2.0

func (t *Table) CtyValue() (cty.Value, error)

CtyValue implements CtyValueProvider (note this must be implemented by each resource, we cannot rely on the HclResourceImpl implementation as it will only serialise its own properties) )

func (*Table) ToProto

func (t *Table) ToProto() *proto.Schema

func (*Table) Validate added in v0.2.0

func (t *Table) Validate() hcl.Diagnostics

type TailpipeConfig

type TailpipeConfig struct {
	// map of partitions, keyed by unqualified name (<partition_type>.<partition_name>)
	Partitions map[string]*Partition

	Connections map[string]*TailpipeConnection

	PluginVersions map[string]*versionfile.InstalledVersion
	CustomTables   map[string]*Table
	Formats        map[string]*Format
}
var GlobalConfig *TailpipeConfig

func NewTailpipeConfig

func NewTailpipeConfig() *TailpipeConfig

func (*TailpipeConfig) Add

func (c *TailpipeConfig) Add(resource modconfig.HclResource) error

func (*TailpipeConfig) InitPartitions

func (c *TailpipeConfig) InitPartitions(versionMap *versionfile.PluginVersionFile)

func (*TailpipeConfig) Validate

func (c *TailpipeConfig) Validate() hcl.Diagnostics

type TailpipeConnection

type TailpipeConnection struct {
	modconfig.HclResourceImpl
	Plugin string `cty:"plugin"`
	Hcl    []byte `cty:"hcl"`
	// the hcl range for the connection - use our version so we can sty serialise it
	HclRange hclhelpers.Range `cty:"hcl_range"`
}

func (*TailpipeConnection) CtyValue added in v0.2.0

func (c *TailpipeConnection) CtyValue() (cty.Value, error)

CtyValue implements CtyValueProvider (note this must be implemented by each resource, we cannot rely on the HclResourceImpl implementation as it will only serialise its own properties) )

func (*TailpipeConnection) GetSubType

func (c *TailpipeConnection) GetSubType() string

GetSubType returns the subtype for the connection (the plugin). The presence of this function indicates this resource supports 3 part names, which affects how it is stored in the eval context

func (*TailpipeConnection) ToProto

func (c *TailpipeConnection) ToProto() *proto.ConfigData

Jump to

Keyboard shortcuts

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