{"modulePath":"github.com/cloudquery/plugin-sdk","version":"v1.4.0","isLatest":false,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package codegen\n\nPackage codegen helps autogenerate tables for CloudQuery source plugins from Go structs (of relevant SDKs).\n\n## Variables\n\n```go\nvar TemplatesFS embed.FS\n```\n\n## Functions\n\n```go\nfunc DefaultNameTransformer(field reflect.StructField) (string, error)\n```\n\n```go\nfunc DefaultResolverTransformer(_ reflect.StructField, path string) (string, error)\n```\n\n```go\nfunc DefaultTypeTransformer(v reflect.StructField) (schema.ValueType, error)\n```\n\n## Types\n\n```go\ntype ColumnDefinition struct {\n\tName          string\n\tType          schema.ValueType\n\tResolver      string\n\tDescription   string\n\tIgnoreInTests bool\n\tOptions       schema.ColumnCreationOptions\n}\n```\n\n```go\ntype ColumnDefinitions []ColumnDefinition\n```\n\n```go\nfunc (c ColumnDefinitions) GetByName(name string) *ColumnDefinition\n```\n\n```go\ntype NameTransformer func(reflect.StructField) (string, error)\n```\n\n```go\ntype ResolverTransformer func(field reflect.StructField, path string) (string, error)\n```\n\n```go\ntype ResourceDefinition struct {\n\tName  string\n\tTable *TableDefinition\n}\n```\n\n```go\ntype TableDefinition struct {\n\tName        string\n\tColumns     ColumnDefinitions\n\tDescription string\n\tRelations   []string\n\n\tResolver             string\n\tIgnoreError          string\n\tMultiplex            string\n\tPostResourceResolver string\n\tPreResourceResolver  string\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewTableFromStruct(name string, obj interface{}, opts ...TableOption) (*TableDefinition, error)\n```\nNewTableFromStruct creates a new TableDefinition from a struct by inspecting its fields\n\n```go\nfunc (t *TableDefinition) Check() error\n```\nCheck that the resulting TableDefinition is correct (e.g., no overlapping column names).\n\n```go\nfunc (t *TableDefinition) GenerateTemplate(wr io.Writer) error\n```\n\n```go\ntype TableOption func(*TableDefinition)\n```\n\n```go\nfunc WithExtraColumns(columns ColumnDefinitions) TableOption\n```\nWithExtraColumns allows passing additional ColumnDefinitions\n\n```go\nfunc WithLogger(logger zerolog.Logger) TableOption\n```\nWithLogger allows passing custom logger\n\n```go\nfunc WithNameTransformer(transformer NameTransformer) TableOption\n```\nWithNameTransformer overrides how column name will be determined. DefaultNameTransformer is used as the default.\n\n```go\nfunc WithPKColumns(columnNames ...string) TableOption\n```\nWithPKColumns allows to specify what columns should be considered PKs without need for WithExtraColumns + WithSkipFields\n\n```go\nfunc WithResolverTransformer(transformer ResolverTransformer) TableOption\n```\nWithResolverTransformer sets a function that can override the resolver for a field. DefaultResolverTransformer is used as the default. If the transformer provided returns error, gen will fail. To fallback onto the default resolver return \"\", nil.\n\n```go\nfunc WithSkipFields(fields []string) TableOption\n```\nWithSkipFields allows to specify what struct fields should be skipped.\n\n```go\nfunc WithTypeTransformer(transformer TypeTransformer) TableOption\n```\nWithTypeTransformer sets a function that can override the schema type for specific fields. Return \\`schema.TypeInvalid\\` to fall back to default behavior. DefaultTypeTransformer is used as the default.\n\n```go\nfunc WithUnwrapAllEmbeddedStructs() TableOption\n```\nWithUnwrapAllEmbeddedStructs instructs codegen to unwrap all embedded fields (1 level deep only)\n\n```go\nfunc WithUnwrapStructFields(fields []string) TableOption\n```\nWithUnwrapStructFields allows to unwrap specific struct fields (1 level deep only)\n\n```go\ntype TypeTransformer func(reflect.StructField) (schema.ValueType, error)\n```\n\n","path":"github.com/cloudquery/plugin-sdk/codegen","name":"codegen","synopsis":"Package codegen helps autogenerate tables for CloudQuery source plugins from Go structs (of relevant SDKs).","isRedistributable":true}
