Documentation
¶
Index ¶
- Constants
- func DB(p cfg.Process, fn cfg.FileHandler, logger zerolog.Logger, schemas db.DB, ...) error
- func Embed(p cfg.Process, fn cfg.FileHandler, l zerolog.Logger, groups []input.FileGroup, ...) error
- func HasDBOutput(o cfg.Output) bool
- func HasEmbedOutput(o cfg.Output) bool
- func HasOpenAPIOutput(o cfg.Output) bool
- func HasProtoOutput(o cfg.Output) bool
- func HasSQLOutput(o cfg.Output) bool
- func OpenAPI(p cfg.Process, fn cfg.FileHandler, l zerolog.Logger, groups openapi.FileGroups, ...) error
- func Proto(p cfg.Process, fn cfg.FileHandler, l zerolog.Logger, groups proto.PBFileGroups, ...) error
- func SQL(p cfg.Process, fn cfg.FileHandler, l zerolog.Logger, fileGroups sql.FileGroups, ...) error
- type Context
- func (c *Context) Aborted() error
- func (c *Context) ErrorIf(t bool, reason string) (string, error)
- func (c *Context) Funcs() plates.FuncMap
- func (c *Context) NotNeededIf(t bool, reason string) (string, error)
- func (c *Context) PackageName() string
- func (c *Context) ToCase(name string) string
- func (c *Context) WithParams(values ...interface{}) (*Context, error)
- type EmbedContext
- type EmbedFileContext
- type EmbedFileGroupContext
- type EnumContext
- type EnumsContext
- type Error
- type FuncMapper
- type Imports
- type Initializer
- type OpResponse
- type OpenAPIFileContext
- func (o *OpenAPIFileContext) CheckAllTypes()
- func (o *OpenAPIFileContext) GetOpHappyResponse(pkg string, op *openapi3.Operation) OpResponse
- func (o *OpenAPIFileContext) GetOpHappyResponseKey(op *openapi3.Operation) string
- func (o *OpenAPIFileContext) GetOpHappyResponseMimeType(op *openapi3.Operation) string
- func (o *OpenAPIFileContext) GetOpHappyResponseType(pkg string, op *openapi3.Operation) string
- func (o *OpenAPIFileContext) GetType(pkg, name string, s *openapi3.SchemaRef) string
- func (o *OpenAPIFileContext) GetTypeName(pkg string, s *openapi3.SchemaRef) string
- func (o *OpenAPIFileContext) HasAnyAuth(op *openapi3.Operation) bool
- func (o *OpenAPIFileContext) HasAuthorization() bool
- func (o *OpenAPIFileContext) HasBasicAuth() bool
- func (o *OpenAPIFileContext) HasBearerAuth() bool
- func (o *OpenAPIFileContext) HasComplexAuth() bool
- func (o *OpenAPIFileContext) HasValidation(s *openapi3.SchemaRef) bool
- func (o *OpenAPIFileContext) Init() error
- func (o *OpenAPIFileContext) IsDefaultEnum(name string, s *openapi3.SchemaRef) bool
- func (o *OpenAPIFileContext) IsSimpleAuth(op *openapi3.Operation) bool
- func (o *OpenAPIFileContext) OpSecurity(op *openapi3.Operation) openapi3.SecurityRequirements
- func (o *OpenAPIFileContext) RefToName(ref string) string
- func (o *OpenAPIFileContext) RequiresAuthUser(op *openapi3.Operation) bool
- func (o *OpenAPIFileContext) WithParams(values ...interface{}) (*OpenAPIFileContext, error)
- type ProcessRunner
- type Properties
- type Property
- type ProtoContext
- type ProtoFileContext
- type ProtoFileGroupContext
- type Resource
- type ResourceMap
- type RuntimeParams
- type SQLContext
- type SQLFileContext
- type SQLFileGroupContext
- type SQLQueryContext
- type SchemaContext
- type SchemasContext
- func (s SchemasContext) GetType(c *db.Column, pkg string) string
- func (s *SchemasContext) Parameterize(cc db.Columns, format, pkg string) string
- func (s SchemasContext) PropertiesFromDB(cc db.Columns) Properties
- func (s SchemasContext) PropertyFromDB(c *db.Column) *Property
- func (s SchemasContext) Resources() ResourceMap
- type TableContext
Constants ¶
const ( ErrInvalidDictParams = Error("invalid dict params in call to WithParams, must be key and value pairs") ErrInvalidDictKey = Error("invalid dict params in call to WithParams, must be key and value pairs") )
const ( DBAll = "DbAll" DBSchema = "DbSchema" DBTable = "DbTable" DBEnums = "DbEnums" DBEnum = "DbEnum" )
const ( EmbedAll = "EmbedAll" EmbedFileGroup = "EmbedFileGroup" EmbedFile = "EmbedFile" )
const ( ErrMissingRequirement = Error("requires") ErrNotNeeded = Error("not needed") ErrPermExists = Error("file exists") )
const ( OpenAPIFile = "OpenAPIFile" OpenAPITag = "OpenAPITag" )
const ( ProtoAll = "ProtoAll" ProtoFileGroup = "ProtoFileGroup" ProtoFile = "ProtoFile" )
const ( SQLAll = "SQLAll" SQLFiles = "SQLFiles" SQLFile = "SQLFile" SQLQuery = "SQLQuery" )
const PermPrefix = "!"
const ValidTypeElems = 2
Variables ¶
This section is empty.
Functions ¶
func HasDBOutput ¶
func HasEmbedOutput ¶
func HasOpenAPIOutput ¶
func HasProtoOutput ¶
func HasSQLOutput ¶
func OpenAPI ¶
func OpenAPI(p cfg.Process, fn cfg.FileHandler, l zerolog.Logger, groups openapi.FileGroups, simulate bool) error
Types ¶
type Context ¶
type Context struct { // RuntimeParams are used for parameterized sub-templates RuntimeParams // Process provides the details of the currently executing Process cfg.Process // Logger provides logging features to the context helpers and templates Logger zerolog.Logger // AbortError allows cancelling saving of a file. See NotNeededIf. AbortError error }
func (*Context) Aborted ¶
Aborted is used to control file generation based on template execution. See NotNeededIf.
func (*Context) ErrorIf ¶
ErrorIf if given bool is true the execution is fatally aborted, and stops processing.
func (*Context) NotNeededIf ¶
NotNeededIf given bool is true the execution is aborted, and can be used to prevent generation of a file.
func (*Context) PackageName ¶
PackageName is a helper to extract the package name from a fully qualified package. It uses the Process.Params.Package as the source. Params.Package "github.com/domain/repo/package/subpackage" => "subpackage".
func (*Context) WithParams ¶
WithParams Clones the current context and adds runtime params for each pair of key, value provided. Used for executing sub templates that still need access to the context.
type EmbedContext ¶
type EmbedFileContext ¶
type EmbedFileContext struct { EmbedFileGroupContext input.File }
type EmbedFileGroupContext ¶
type EmbedFileGroupContext struct { EmbedContext FileGroup input.FileGroup }
type EnumContext ¶
type EnumContext struct { db.Enum SchemasContext }
type EnumsContext ¶
type EnumsContext struct { db.Enums SchemasContext }
type FuncMapper ¶
type Imports ¶
type Imports stringlist.Strings
Imports tracks dynamic usage of objects. Because templates are executed in order, using this to populate a list at the top of a generated file requires precalculating all of the imports. See SQLContext.Init as an example. Another option would be to create a buffer of generated code at the beginning, then generate the final output.
func (*Imports) Add ¶
Add filters duplicates and appends to the import list. Add works on uninitialized Imports objects.
func (*Imports) CheckPackage ¶
CheckPackage is used for type mapping. Currently it is designed for go fully qualified package names. Examples: "github.com/domain/repo/package/subpackage.Type", "" => "subpackage.Type" "time.Time", "" => "time.Time" "int", "" => "int" "github.com/domain/repo/package/subpackage.Type", "github.com/domain/repo/package/subpackage" => "Type" If the type is defined in a separate package the package is added to the import list.
type Initializer ¶
type Initializer interface {
Init() error
}
type OpResponse ¶
func (OpResponse) IsLongPollingOperation ¶
func (op OpResponse) IsLongPollingOperation() bool
type OpenAPIFileContext ¶
func (*OpenAPIFileContext) CheckAllTypes ¶
func (o *OpenAPIFileContext) CheckAllTypes()
func (*OpenAPIFileContext) GetOpHappyResponse ¶
func (o *OpenAPIFileContext) GetOpHappyResponse(pkg string, op *openapi3.Operation) OpResponse
func (*OpenAPIFileContext) GetOpHappyResponseKey ¶
func (o *OpenAPIFileContext) GetOpHappyResponseKey(op *openapi3.Operation) string
func (*OpenAPIFileContext) GetOpHappyResponseMimeType ¶
func (o *OpenAPIFileContext) GetOpHappyResponseMimeType(op *openapi3.Operation) string
func (*OpenAPIFileContext) GetOpHappyResponseType ¶
func (o *OpenAPIFileContext) GetOpHappyResponseType(pkg string, op *openapi3.Operation) string
func (*OpenAPIFileContext) GetType ¶
func (o *OpenAPIFileContext) GetType(pkg, name string, s *openapi3.SchemaRef) string
func (*OpenAPIFileContext) GetTypeName ¶
func (o *OpenAPIFileContext) GetTypeName(pkg string, s *openapi3.SchemaRef) string
func (*OpenAPIFileContext) HasAnyAuth ¶
func (o *OpenAPIFileContext) HasAnyAuth(op *openapi3.Operation) bool
func (*OpenAPIFileContext) HasAuthorization ¶
func (o *OpenAPIFileContext) HasAuthorization() bool
func (*OpenAPIFileContext) HasBasicAuth ¶
func (o *OpenAPIFileContext) HasBasicAuth() bool
func (*OpenAPIFileContext) HasBearerAuth ¶
func (o *OpenAPIFileContext) HasBearerAuth() bool
func (*OpenAPIFileContext) HasComplexAuth ¶
func (o *OpenAPIFileContext) HasComplexAuth() bool
func (*OpenAPIFileContext) HasValidation ¶
func (o *OpenAPIFileContext) HasValidation(s *openapi3.SchemaRef) bool
func (*OpenAPIFileContext) Init ¶
func (o *OpenAPIFileContext) Init() error
func (*OpenAPIFileContext) IsDefaultEnum ¶
func (o *OpenAPIFileContext) IsDefaultEnum(name string, s *openapi3.SchemaRef) bool
IsDefaultEnum helper that checks if an enumerated type is overridden (specified externally).
func (*OpenAPIFileContext) IsSimpleAuth ¶
func (o *OpenAPIFileContext) IsSimpleAuth(op *openapi3.Operation) bool
func (*OpenAPIFileContext) OpSecurity ¶
func (o *OpenAPIFileContext) OpSecurity(op *openapi3.Operation) openapi3.SecurityRequirements
func (*OpenAPIFileContext) RefToName ¶
func (o *OpenAPIFileContext) RefToName(ref string) string
func (*OpenAPIFileContext) RequiresAuthUser ¶
func (o *OpenAPIFileContext) RequiresAuthUser(op *openapi3.Operation) bool
func (*OpenAPIFileContext) WithParams ¶
func (o *OpenAPIFileContext) WithParams(values ...interface{}) (*OpenAPIFileContext, error)
type ProcessRunner ¶
func NewProcessRunner ¶
func NewProcessRunner(dir string, fn cfg.FileHandler, l zerolog.Logger, simulate bool) ProcessRunner
type Properties ¶
type Properties []*Property
type ProtoContext ¶
type ProtoContext struct { Context Imports FileGroups proto.PBFileGroups }
func (ProtoContext) HasMessage ¶
func (q ProtoContext) HasMessage(msg *proto.Message) bool
func (ProtoContext) IsEnum ¶
func (q ProtoContext) IsEnum(name string) bool
func (ProtoContext) IsMessage ¶
func (q ProtoContext) IsMessage(name string) bool
type ProtoFileContext ¶
type ProtoFileContext struct { ProtoFileGroupContext proto.PBFile }
type ProtoFileGroupContext ¶
type ProtoFileGroupContext struct { ProtoContext FileGroup proto.PBFileGroup }
type Resource ¶
type Resource struct { Name string Properties Properties Table *db.Table PK *Property }
type ResourceMap ¶
type RuntimeParams ¶
type RuntimeParams map[string]interface{}
type SQLContext ¶
type SQLContext struct { Context sql.FileGroups Imports }
func (*SQLContext) Init ¶
func (q *SQLContext) Init() error
func (SQLContext) Parameterize ¶
func (q SQLContext) Parameterize(cc sql.Params, format, pkg string) string
type SQLFileContext ¶
type SQLFileContext struct { SQLContext sql.File }
func (*SQLFileContext) Init ¶
func (q *SQLFileContext) Init() error
type SQLFileGroupContext ¶
type SQLFileGroupContext struct { SQLContext Files []sql.File }
func (*SQLFileGroupContext) Init ¶
func (q *SQLFileGroupContext) Init() error
type SQLQueryContext ¶
type SQLQueryContext struct { SQLContext sql.Query }
func (*SQLQueryContext) Init ¶
func (q *SQLQueryContext) Init() error
type SchemaContext ¶
type SchemaContext struct { db.Schema SchemasContext }
type SchemasContext ¶
func (*SchemasContext) Parameterize ¶
func (s *SchemasContext) Parameterize(cc db.Columns, format, pkg string) string
func (SchemasContext) PropertiesFromDB ¶
func (s SchemasContext) PropertiesFromDB(cc db.Columns) Properties
func (SchemasContext) PropertyFromDB ¶
func (s SchemasContext) PropertyFromDB(c *db.Column) *Property
func (SchemasContext) Resources ¶
func (s SchemasContext) Resources() ResourceMap
type TableContext ¶
type TableContext struct { db.Table SchemasContext }