generator

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Image     = files.EnvVar(internal.DockerRegistry) + "/${PROJECT_GROUP}/${PROJECT_NAME}:${PROJECT_VERSION}"
	FromImage = files.EnvVar(internal.DockerRegistry) + "/" + files.EnvVar(internal.RunnerGolang)
)

Functions

func ConvertEnvVars

func ConvertEnvVars(src []envconfig.EnvVar) []apiv1.EnvVar

func EachFieldValue

func EachFieldValue(val reflect.Value, walker func(value reflect.Value) bool)

func Generate

func Generate(generator Generator, inputPath, outputPath string)

func GeneratedSuffix

func GeneratedSuffix(filename string) string

func GetServiceName

func GetServiceName(projectName string) string

func IsGoFile

func IsGoFile(filename string) bool

func IsGoTextFile

func IsGoTextFile(filename string) bool

func ParseStatusErrorDesc

func ParseStatusErrorDesc(str string) (msg string, desc string, canBeErrTalk bool)

func PathExist

func PathExist(p string) bool

func WriteFile

func WriteFile(filename string, content string)

Types

type ClientGenerator

type ClientGenerator struct {
	Api *oas.OpenAPI
	// contains filtered or unexported fields
}

func NewClientGenerator

func NewClientGenerator(pkgName string) *ClientGenerator

func (*ClientGenerator) Finally

func (c *ClientGenerator) Finally()

func (*ClientGenerator) Load

func (c *ClientGenerator) Load(path string)

func (*ClientGenerator) Output

func (c *ClientGenerator) Output(outputPath string) Outputs

func (*ClientGenerator) Pick

func (c *ClientGenerator) Pick()

type Config

type Config struct {
	StructName string
	TableName  string
	Database   string

	WithComments        bool
	WithTableName       bool
	WithTableInterfaces bool
	WithMethods         bool

	FieldPrimaryKey   string
	FieldKeyDeletedAt string
	FieldKeyCreatedAt string
	FieldKeyUpdatedAt string
}

func (*Config) SetDefaults

func (g *Config) SetDefaults()

type ConfigGenerator

type ConfigGenerator struct {
	// contains filtered or unexported fields
}

func NewConfigGenerator

func NewConfigGenerator(envVars []envconfig.EnvVar, fileName string) *ConfigGenerator

func (ConfigGenerator) Finally

func (c ConfigGenerator) Finally()

func (ConfigGenerator) Load

func (c ConfigGenerator) Load(path string)

func (ConfigGenerator) Output

func (c ConfigGenerator) Output(outputPath string) Outputs

func (ConfigGenerator) Pick

func (c ConfigGenerator) Pick()

type DockerGenerator

type DockerGenerator struct {
	ServiceName string
	EnvVars     []envconfig.EnvVar
}

func NewDockerGenerator

func NewDockerGenerator(serviceName string, envVars []envconfig.EnvVar) *DockerGenerator

func (*DockerGenerator) Finally

func (d *DockerGenerator) Finally()

func (*DockerGenerator) Load

func (d *DockerGenerator) Load(path string)

func (*DockerGenerator) Output

func (d *DockerGenerator) Output(outputPath string) Outputs

func (*DockerGenerator) Pick

func (d *DockerGenerator) Pick()

type EnumGenerator

type EnumGenerator struct {
	TypeName string
	// contains filtered or unexported fields
}

func NewEnumGenerator

func NewEnumGenerator(typeName string) *EnumGenerator

func (*EnumGenerator) Finally

func (e *EnumGenerator) Finally()

func (*EnumGenerator) Load

func (e *EnumGenerator) Load(cwd string)

func (*EnumGenerator) Output

func (e *EnumGenerator) Output(outputPath string) Outputs

func (*EnumGenerator) Pick

func (e *EnumGenerator) Pick()

type Generator

type Generator interface {
	Load(path string)
	Pick()
	Output(outputPath string) Outputs
	Finally()
}

type K8sGenerator

type K8sGenerator struct {
	EnvVars []envconfig.EnvVar
	// contains filtered or unexported fields
}

func NewK8sGenerator

func NewK8sGenerator(config []interface{}, envVars []envconfig.EnvVar) *K8sGenerator

func (*K8sGenerator) Finally

func (d *K8sGenerator) Finally()

func (*K8sGenerator) Load

func (d *K8sGenerator) Load(cwd string)

func (*K8sGenerator) Output

func (d *K8sGenerator) Output(outputPath string) Outputs

func (*K8sGenerator) Pick

func (d *K8sGenerator) Pick()

type ModelGenerator

type ModelGenerator struct {
	generator.Config
	// contains filtered or unexported fields
}

func NewModelGenerator

func NewModelGenerator() *ModelGenerator

func (*ModelGenerator) Finally

func (g *ModelGenerator) Finally()

func (*ModelGenerator) Load

func (g *ModelGenerator) Load(cwd string)

func (*ModelGenerator) Output

func (g *ModelGenerator) Output(outputPath string) Outputs

func (*ModelGenerator) Pick

func (g *ModelGenerator) Pick()

type OpenApiGenerator

type OpenApiGenerator struct {
	// contains filtered or unexported fields
}

func NewOpenApiGenerator

func NewOpenApiGenerator() *OpenApiGenerator

func (*OpenApiGenerator) Finally

func (a *OpenApiGenerator) Finally()

func (*OpenApiGenerator) Load

func (a *OpenApiGenerator) Load(cwd string)

func (*OpenApiGenerator) OperationByOperatorTypes

func (a *OpenApiGenerator) OperationByOperatorTypes(
	method string,
	operatorTypes ...*scanner.OperatorWithTypeName,
) *oas.Operation

func (*OpenApiGenerator) Output

func (a *OpenApiGenerator) Output(outputPath string) Outputs

func (*OpenApiGenerator) Pick

func (a *OpenApiGenerator) Pick()

type Outputs

type Outputs map[string]string

func (Outputs) Add

func (outputs Outputs) Add(filename string, content string)

func (Outputs) WriteFile

func (outputs Outputs) WriteFile(filename string, content string)

func (Outputs) WriteFiles

func (outputs Outputs) WriteFiles()

type ProjectGenerator

type ProjectGenerator struct {
	// contains filtered or unexported fields
}

func NewProjectGenerator

func NewProjectGenerator(opt ProjectOption) *ProjectGenerator

func (*ProjectGenerator) Finally

func (p *ProjectGenerator) Finally()

func (*ProjectGenerator) Load

func (p *ProjectGenerator) Load(path string)

func (*ProjectGenerator) Output

func (p *ProjectGenerator) Output(outputPath string) Outputs

func (*ProjectGenerator) Pick

func (p *ProjectGenerator) Pick()

type ProjectOption

type ProjectOption struct {
	Name            string
	Group           string
	Owner           string
	Namespace       string
	Desc            string
	Version         string
	ProgramLanguage string `survey:"project_language"`
	Workflow        string
	ConfigCenter    enum.ConfigCenterType `survey:"config_center"`
}

type RepositoryGenerator

type RepositoryGenerator struct {
	scanner.ModelScannerConfig
	// contains filtered or unexported fields
}

func NewRepositoryGenerator

func NewRepositoryGenerator() *RepositoryGenerator

func (*RepositoryGenerator) Finally

func (g *RepositoryGenerator) Finally()

func (*RepositoryGenerator) Load

func (g *RepositoryGenerator) Load(cwd string)

func (*RepositoryGenerator) Output

func (g *RepositoryGenerator) Output(outputPath string) Outputs

func (*RepositoryGenerator) Pick

func (g *RepositoryGenerator) Pick()

type RouterGenerator

type RouterGenerator struct {
	scanner.ModelScannerConfig
	// contains filtered or unexported fields
}

func NewRouterGenerator

func NewRouterGenerator() *RouterGenerator

func (*RouterGenerator) Finally

func (g *RouterGenerator) Finally()

func (*RouterGenerator) Load

func (g *RouterGenerator) Load(cwd string)

func (*RouterGenerator) Output

func (g *RouterGenerator) Output(outputPath string) Outputs

func (*RouterGenerator) Pick

func (g *RouterGenerator) Pick()

type ServiceGenerator

type ServiceGenerator struct {
	// contains filtered or unexported fields
}

func NewServiceGenerator

func NewServiceGenerator(opt ServiceOption) *ServiceGenerator

func (*ServiceGenerator) Finally

func (s *ServiceGenerator) Finally()

func (*ServiceGenerator) Load

func (s *ServiceGenerator) Load(path string)

func (*ServiceGenerator) Output

func (s *ServiceGenerator) Output(outputPath string) Outputs

func (*ServiceGenerator) Pick

func (s *ServiceGenerator) Pick()

type ServiceOption

type ServiceOption struct {
	FrameworkVersion string `survey:"framework_version"`
	Name             string
	PackageName      string                `survey:"package_name"`
	DatabaseSupport  expressBool           `survey:"database_support"`
	ConfigCenter     enum.ConfigCenterType `survey:"config_center"`

	Group           string
	Owner           string
	Namespace       string
	Desc            string
	Version         string
	ProgramLanguage string `survey:"project_language"`
	Workflow        string `survey:"workflow"`
}

type StatusErrGenerator

type StatusErrGenerator struct {
	// contains filtered or unexported fields
}

func NewStatusErrGenerator

func NewStatusErrGenerator() *StatusErrGenerator

func (*StatusErrGenerator) Finally

func (s *StatusErrGenerator) Finally()

func (*StatusErrGenerator) Load

func (s *StatusErrGenerator) Load(path string)

func (*StatusErrGenerator) Output

func (s *StatusErrGenerator) Output(outputPath string) Outputs

func (*StatusErrGenerator) Pick

func (s *StatusErrGenerator) Pick()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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