Documentation ¶
Index ¶
Constants ¶
const GoProxyEnvKey = "GOPROXY"
GoProxyEnvKey with the environment variable name that defines the GOPROXY preferences.
const (
// PackagePlaceHolder is the package name placeholder
PackagePlaceHolder = "github.com/kubevela/vela-go-sdk"
)
Variables ¶
var ( //go:embed openapi-generator/templates // Templates contains different template files for different languages Templates embed.FS // SupportedLangs is supported languages SupportedLangs = map[string]bool{"go": true} //go:embed _scaffold // Scaffold is scaffold files for different languages Scaffold embed.FS // ScaffoldDir is scaffold dir name ScaffoldDir = "_scaffold" )
var ( // DefinitionKindToPascal is the map of definition kind to pascal case DefinitionKindToPascal = map[string]string{ v1beta1.ComponentDefinitionKind: "Component", v1beta1.TraitDefinitionKind: "Trait", v1beta1.WorkflowStepDefinitionKind: "WorkflowStep", v1beta1.PolicyDefinitionKind: "Policy", } // DefinitionKindToBaseType is the map of definition kind to base type DefinitionKindToBaseType = map[string]string{ v1beta1.ComponentDefinitionKind: "ComponentBase", v1beta1.TraitDefinitionKind: "TraitBase", v1beta1.WorkflowStepDefinitionKind: "WorkflowStepBase", v1beta1.PolicyDefinitionKind: "PolicyBase", } // DefinitionKindToStatement is the map of definition kind to statement DefinitionKindToStatement = map[string]*j.Statement{ v1beta1.ComponentDefinitionKind: j.Qual("common", "ApplicationComponent"), v1beta1.TraitDefinitionKind: j.Qual("common", "ApplicationTrait"), v1beta1.WorkflowStepDefinitionKind: j.Qual("v1beta1", "WorkflowStep"), v1beta1.PolicyDefinitionKind: j.Qual("v1beta1", "AppPolicy"), } )
var ( // LangArgsRegistry is used to store the argument info LangArgsRegistry = map[string]map[langArgKey]LangArg{} )
Functions ¶
This section is empty.
Types ¶
type GenMeta ¶
type GenMeta struct { Output string APIDirectory string IsSubModule bool Lang string Package string Template string File []string InitSDK bool Verbose bool LangArgs LanguageArgs // contains filtered or unexported fields }
GenMeta stores the metadata for generator.
func (*GenMeta) CreateScaffold ¶
CreateScaffold will create a scaffold for the given language. It will copy all files from embedded scaffold/{meta.Lang} to meta.Output.
func (*GenMeta) Init ¶
Init initializes the generator. It will validate the param, analyze the CUE files, read them to memory, mkdir for output.
func (*GenMeta) PrepareGeneratorAndTemplate ¶
PrepareGeneratorAndTemplate will make a copy of the embedded openapi-generator-cli and templates/{meta.Lang} to local
func (*GenMeta) Run ¶
Run will generally do two thing: 1. Generate OpenAPI schema from cue files 2. Generate code from OpenAPI schema
func (*GenMeta) SetDefinition ¶
SetDefinition sets definition name and kind
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator is used to generate SDK code from CUE template for one language.
func NewModifiableGenerator ¶
NewModifiableGenerator returns a new Generator with modifiers
func (*Generator) GenOpenAPISchema ¶
GenOpenAPISchema generates OpenAPI json schema from cue.Instance
func (*Generator) GenerateCode ¶
GenerateCode will call openapi-generator to generate code and modify it
type GoDefModifier ¶
type GoDefModifier struct { *GenMeta // contains filtered or unexported fields }
GoDefModifier is the Modifier for golang, modify code for each definition
func (*GoDefModifier) Modify ¶
func (m *GoDefModifier) Modify() error
Modify the modification of generated code
type GoModuleModifier ¶
type GoModuleModifier struct { *GenMeta // contains filtered or unexported fields }
GoModuleModifier is the Modifier for golang, modify code for each module which contains multiple definitions
func (*GoModuleModifier) Modify ¶
func (m *GoModuleModifier) Modify() error
Modify implements Modifier
type LanguageArgs ¶
LanguageArgs is used to store the arguments for the language.
func NewLanguageArgs ¶
func NewLanguageArgs(lang string, langArgs []string) (LanguageArgs, error)
NewLanguageArgs parses the language arguments and returns a LanguageArgs.