generators

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadYaml added in v0.8.0

func ReadYaml(path string, object interface{}) error

ReadYaml reads a yaml file into a structure

Types

type AppGenerator added in v0.8.0

type AppGenerator struct {
	*Generator
	Config *config.Config
	Name   string
	Repo   string
}

AppGenerator manages generating an application

func NewAppGenerator added in v0.8.0

func NewAppGenerator(cfg *config.Config, name, repo string) *AppGenerator

NewAppGenerator returns a new instance of Generator

func (*AppGenerator) Execute added in v0.8.0

func (g *AppGenerator) Execute() error

Execute processes all of the configurations and generates an application

type Connection added in v0.8.0

type Connection struct {
	URI        string
	Database   string `json:"database,omitempty" yaml:"database,omitempty"`
	Collection string `json:"collection,omitempty" yaml:"collection,omitempty"`
}

type ConnectorGenerator added in v0.8.0

type ConnectorGenerator struct {
	*Generator
	Config *config.Config
	Models []map[string]string
	Data   *ConnectorGeneratorData
}

ConnectorGenerator manages generation of the database connector

func NewConnectorGenerator added in v0.8.0

func NewConnectorGenerator(cfg *config.Config, models []map[string]string) *ConnectorGenerator

NewConnectorGenerator creates and returns a ConnectorGenerator

func (*ConnectorGenerator) Execute added in v0.8.0

func (g *ConnectorGenerator) Execute(buf *bytes.Buffer) error

Execute configures and generates the database connector

type ConnectorGeneratorData added in v0.8.0

type ConnectorGeneratorData struct {
	Models []*ConnectorGeneratorDataModel
}

ConnectorGeneratorData stores the data for the database connector template

type ConnectorGeneratorDataModel added in v0.8.0

type ConnectorGeneratorDataModel struct {
	Name   string
	Type   string
	Camel  string
	Struct bool
	Model  bool
}

type DatabaseGenerator added in v0.8.0

type DatabaseGenerator struct {
	*Generator
	Config *config.Config
	Models []map[string]string
}

DatabaseGenerator manages the generation of all database related files

func (*DatabaseGenerator) Execute added in v0.8.0

func (g *DatabaseGenerator) Execute() error

Execute configures and generates all of the database related files

type Definition added in v0.8.0

type Definition struct {
	Repo   string            `json:"repo,omitempty" yaml:"repo,omitempty"`
	Name   string            `json:"name,omitempty" yaml:"name,omitempty"`
	Groups map[string]*Group `json:"groups,omitempty" yaml:"groups,omitempty"`
	Routes map[string]*Route `json:"routes,omitempty" yaml:"routes,omitempty"`
}

Definition stores the configuration from the routes file

func (*Definition) FindGroup added in v0.8.0

func (d *Definition) FindGroup(name string, rest bool) *Group

func (*Definition) FindRoute added in v0.8.0

func (d *Definition) FindRoute(path string) *Route

FindRoute finds a route corresponding to the path name passed as argument

type Field added in v0.8.0

type Field struct {
	Name   string   `yaml:"name,omitempty"`
	Camel  string   `yaml:"camel,omitempty"`
	Type   string   `yaml:"type,omitempty"`
	Json   string   `yaml:"json,omitempty"`
	Bson   string   `yaml:"bson,omitempty"`
	Tags   string   `yaml:"tags,omitempty"`
	Fields []*Field `yaml:"fields,omitempty"`
}

Field holds the data from the YAML field

type FieldGenerator added in v0.8.0

type FieldGenerator struct {
	Definition *Field
	// contains filtered or unexported fields
}

FieldGenerator is the generator of model fields

func (*FieldGenerator) Execute added in v0.8.0

func (f *FieldGenerator) Execute(s *bytes.Buffer) error

Execute generates the field using the template

func (*FieldGenerator) Prepare added in v0.8.0

func (f *FieldGenerator) Prepare() error

Prepare configures the data for the template

type FileGenerator added in v0.8.0

type FileGenerator struct {
	*Generator
	Config *config.Config
	Name   string
	Data   map[string]string
}

FileGenerator manages generic or simple file generation

func NewFileGenerator added in v0.8.0

func NewFileGenerator(cfg *config.Config, name string, path string, data map[string]string) *FileGenerator

NewFileGenerator creates and returns a FileGenerator

func (*FileGenerator) Execute added in v0.8.0

func (f *FileGenerator) Execute() error

Execute configures and generates a file

type Generator

type Generator struct {
	Filename string
	Buffer   *bytes.Buffer
}

Generator is the base generate for all other generators

func (*Generator) Format added in v0.8.0

func (g *Generator) Format() error

Format the file using goimports

func (*Generator) Write added in v0.8.0

func (g *Generator) Write() error

Write the output of the generator to a file

type Group added in v0.8.0

type Group struct {
	Name   string            `json:"name,omitempty" yaml:"name,omitempty"`
	Path   string            `json:"path,omitempty" yaml:"path,omitempty"`
	Method string            `json:"method,omitempty" yaml:"method,omitempty"`
	Routes map[string]*Route `json:"routes,omitempty" yaml:"routes,omitempty"`
	Rest   bool              `json:"rest,omitempty" yaml:"rest,omitempty"`
}

Group stores the configuration of the group

func (*Group) Camel added in v0.8.0

func (g *Group) Camel() string

type GroupGenerator added in v0.8.0

type GroupGenerator struct {
	*Generator
	Config     *config.Config
	Output     string
	Name       string
	Definition *Group
}

GroupGenerator manages the creation of group routes

func NewGroupGenerator added in v0.8.0

func NewGroupGenerator(cfg *config.Config, name string, d *Group) *GroupGenerator

NewGroupGenerator configures and returns an instance of GroupGenerator

func (*GroupGenerator) Execute added in v0.8.0

func (g *GroupGenerator) Execute() error

Execute manages creation of group routes files with the template

type MainGenerator added in v0.8.0

type MainGenerator struct {
	Config *config.Config
}

Generator is the top-level generator and calls other generators

func (*MainGenerator) Execute added in v0.8.0

func (g *MainGenerator) Execute() error

Execute calls all dependent generators based on configuration

type Model added in v0.8.0

type Model struct {
	Package string   `yaml:"package,omitempty"`
	Camel   string   `yaml:"camel,omitempty"`
	Name    string   `yaml:"name,omitempty"`
	Type    string   `yaml:"type,omitempty"`
	Imports []string `yaml:"imports,omitempty"`
	Fields  []*Field `yaml:"fields,omitempty"`
}

Model holds the data from the YAML model

type ModelDefinitionGenerator added in v0.8.0

type ModelDefinitionGenerator struct {
	*Generator
	Config     *config.Config
	Name       string
	Type       string
	Fields     []string
	Definition *Model
}

ModelDefinitionGenerator manages the generation of model definitions

func NewModelDefinitionGenerator added in v0.8.0

func NewModelDefinitionGenerator(cfg *config.Config, name string, fields ...string) *ModelDefinitionGenerator

NewModelDefinitionGenerator creates and returns an instance of ModelDefinitionGenerator

func (*ModelDefinitionGenerator) Execute added in v0.8.0

func (g *ModelDefinitionGenerator) Execute() error

Execute generates the model definition

type Param added in v0.8.0

type Param struct {
	Name    string `json:"name" yaml:"name"`
	Type    string `json:"type" yaml:"type"`
	Default string `json:"default,omitempty" yaml:"default,omitempty"`
	Query   bool   `json:"query,omitempty" yaml:"query,omitempty"`
}

Param stores the configuration of the parameter

func (*Param) GetType added in v0.8.0

func (d *Param) GetType() string

GetType returns the capitalized type of the parameter or the default string

type Route added in v0.8.0

type Route struct {
	Name   string   `json:"name,omitempty" yaml:"name,omitempty"`
	Path   string   `json:"path,omitempty" yaml:"path,omitempty"`
	Method string   `json:"method,omitempty" yaml:"method,omitempty"`
	Params []*Param `json:"params,omitempty" yaml:"params,omitempty"`
}

Route stores the configuration of the route

func (*Route) Camel added in v0.8.0

func (r *Route) Camel() string

func (*Route) GetMethod added in v0.8.0

func (r *Route) GetMethod() string

GetMethod returns the capitalized method of the route or the default get

type RouteDefinitionGenerator added in v0.8.0

type RouteDefinitionGenerator struct {
	*Generator
	Config     *config.Config
	Name       string
	Path       string
	Params     []string
	Rest       bool
	Definition *Definition
}

RouteDefinitionGenerator manages the generation of and updates to routes definition

func NewRouteDefinitionGenerator added in v0.8.0

func NewRouteDefinitionGenerator(cfg *config.Config, path string, rest bool, params ...string) *RouteDefinitionGenerator

NewRouteDefinitionGenerator creates and returns an instance of RouteDefinitionGenerator

func (*RouteDefinitionGenerator) Execute added in v0.8.0

func (g *RouteDefinitionGenerator) Execute() error

Execute generates or updates the routes definition

type RoutesGenerator added in v0.8.0

type RoutesGenerator struct {
	Config     *config.Config
	Definition *Definition
	Groups     []*GroupGenerator
}

RoutesGenerator manages the generation of all routes related files

func NewRoutesGenerator added in v0.8.0

func NewRoutesGenerator(cfg *config.Config) *RoutesGenerator

NewRoutesGenerator creates and returns an instance of Generator

func (*RoutesGenerator) Execute added in v0.8.0

func (g *RoutesGenerator) Execute() error

Execute generates the files from the templates

type ServerGenerator added in v0.8.0

type ServerGenerator struct {
	*Generator
	Config     *config.Config
	Output     string
	Definition *Definition
}

ServerGenerator manages the creation of the server file

func NewServerGenerator added in v0.8.0

func NewServerGenerator(cfg *config.Config, d *Definition) *ServerGenerator

NewServerGenerator creates and returns an instance of ServerGenerator

func (*ServerGenerator) Execute added in v0.8.0

func (g *ServerGenerator) Execute() error

Execute creates the server file from the template

type ServerRoutesGenerator added in v0.8.0

type ServerRoutesGenerator struct {
	*Generator
	Config     *config.Config
	Output     string
	Definition *Definition
}

ServerRoutesGenerator manages the creation of the server routes file

func NewServerRoutesGenerator added in v0.8.0

func NewServerRoutesGenerator(cfg *config.Config, d *Definition) *ServerRoutesGenerator

NewServerRoutesGenerator creates and returns an instance of ServerRoutesGenerator

func (*ServerRoutesGenerator) Execute added in v0.8.0

func (g *ServerRoutesGenerator) Execute() error

Execute creates the server routes file from the template

Jump to

Keyboard shortcuts

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