codegen

package
v0.7.8 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package codgen helps autogenerate tables for CloudQuery source plugins from Go structs (of relevant SDKs)

Index

Constants

This section is empty.

Variables

View Source
var TemplatesFS embed.FS

Functions

This section is empty.

Types

type ColumnDefinition

type ColumnDefinition struct {
	// Name name of the column
	Name          string
	Type          schema.ValueType
	Resolver      string
	Description   string
	IgnoreInTests bool
	Options       schema.ColumnCreationOptions
}

type ColumnDefinitions

type ColumnDefinitions []ColumnDefinition

func (ColumnDefinitions) GetByName

func (c ColumnDefinitions) GetByName(name string) *ColumnDefinition

type ResourceDefinition

type ResourceDefinition struct {
	Name  string
	Table *TableDefinition
}

type TableDefinition

type TableDefinition struct {
	Name        string
	Columns     ColumnDefinitions
	Description string
	Relations   []string

	Resolver             string
	IgnoreError          string
	Multiplex            string
	PostResourceResolver string
	PreResourceResolver  string
	// contains filtered or unexported fields
}

func NewTableFromStruct

func NewTableFromStruct(name string, obj interface{}, opts ...TableOptions) (*TableDefinition, error)

NewTableFromStruct creates a new TableDefinition from a struct by inspecting its fields

func (*TableDefinition) GenerateTemplate

func (t *TableDefinition) GenerateTemplate(wr io.Writer) error

type TableOptions

type TableOptions func(*TableDefinition)

func WithExtraColumns

func WithExtraColumns(columns []ColumnDefinition) TableOptions

func WithNameTransformer

func WithNameTransformer(transformer func(field reflect.StructField) string) TableOptions

func WithSkipFields

func WithSkipFields(fields []string) TableOptions

func WithUnwrapAllEmbeddedStructs added in v0.6.1

func WithUnwrapAllEmbeddedStructs() TableOptions

Unwrap all fields that are embedded structs (1 level deep only)

func WithUnwrapFieldsStructs added in v0.6.1

func WithUnwrapFieldsStructs(fields []string) TableOptions

Unwrap specific struct fields (1 level deep only)

Jump to

Keyboard shortcuts

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