gen

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(manifestPath string, mcfg *packages.Config) error

Generate generates the mapping files.

Types

type CommonStruct added in v0.3.3

type CommonStruct struct {
	PackageName string       `yaml:"package_name"`
	StructName  string       `yaml:"struct_name"`
	Path        string       `yaml:"path"`
	Struct      csgen.Struct `yaml:"struct"`
}

CommonStruct a container for structs that have global application when creating maps

type ConvertFunctionParams

type ConvertFunctionParams struct {
	ConverterPackage     string
	FunctionName         string
	FunctionNameForSlice string
	SourcePackage        string
	SourceObjectName     string
	FQSourceObjectName   string
	TargetPackage        string
	TargetObjectName     string
	FQTargetObjectName   string
	Assignments          []string
	Imports              []string
}

ConvertFunctionParams is a struct that contains the parameters that feed into the template.

type Manifest

type Manifest struct {
	ProjectRoot      string         `yaml:"project_root"`
	GeneratorPath    string         `yaml:"generator_path"`
	GeneratorPackage string         `yaml:"generator_package"`
	ObjectMaps       []ObjectMap    `yaml:"maps"`
	CommonStructs    []CommonStruct `yaml:"common_structs"`
}

Manifest strongly typed respresentation of the manifest file.

func LoadManifest

func LoadManifest(path string, mcfg *packages.Config) Manifest

LoadManifest loads the manifest file and returns a slice of ObjectMap structs.

func (*Manifest) GetCommonStruct added in v0.3.3

func (m *Manifest) GetCommonStruct(name string) *CommonStruct

GetCommonStruct return a common struct by name if it exists and nil otherwise

type MapOverride

type MapOverride struct {
	SourceName string `yaml:"source_name"`
	TargetName string `yaml:"target_name"`
}

MapOverride struct that represents an explicitly specified object mapping, overriding the defailt name matching

type ObjectMap

type ObjectMap struct {
	Name          string `yaml:"name"`
	SourcePath    string `yaml:"source_path"`
	SourceObjects []csgen.Struct
	TargetPath    string `yaml:"target_path"`
	TargetObjects []csgen.Struct
	Imports       []string      `yaml:"imports"`
	MapOverrides  []MapOverride `yaml:"map_overrides"`
}

ObjectMap is a struct that contains the source and destination paths for a single mapping.

Jump to

Keyboard shortcuts

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