Documentation
¶
Index ¶
- func DefaultCopyFileCallback(sourcePath, sourceFilename string, destinationPath, destinationFilename string) error
- func DefaultGetPathsCallback(ctx debefix.ValueResolveContext, fieldname string, fileData FileData) (source string, destination string, err error)
- func DefaultGetValueCallback(ctx debefix.ValueCallbackResolveContext, fileData FileData) (value any, addField bool, err error)
- func ReplaceFields(str string, values map[string]any) (string, error)
- func ReplaceFieldsWithFilter(str string, ctx debefix.ValueResolveContext) (string, error)
- type CopyFile
- type CopyFileCallback
- type FileData
- type GetPathsCallback
- type GetValueCallback
- type Option
- type ParsedFields
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultCopyFileCallback ¶ added in v1.3.1
func DefaultCopyFileCallback(sourcePath, sourceFilename string, destinationPath, destinationFilename string) error
DefaultCopyFileCallback is the default implementation of CopyFileCallback.
func DefaultGetPathsCallback ¶ added in v1.3.1
func DefaultGetPathsCallback(ctx debefix.ValueResolveContext, fieldname string, fileData FileData) (source string, destination string, err error)
DefaultGetPathsCallback is the default implementation of GetPathsCallback.
func DefaultGetValueCallback ¶ added in v1.3.1
func DefaultGetValueCallback(ctx debefix.ValueCallbackResolveContext, fileData FileData) (value any, addField bool, err error)
DefaultGetValueCallback is the default implementation of GetValueCallback.
func ReplaceFields ¶ added in v1.3.1
ReplaceFields parses curly-brace-delimited fields in strings and replaces them with values. To escape a curly-brace, add two consecutive ones.
func ReplaceFieldsWithFilter ¶ added in v1.3.1
func ReplaceFieldsWithFilter(str string, ctx debefix.ValueResolveContext) (string, error)
ReplaceFieldsWithFilter replaces curly-braces separated fields in str as debefix filter expressions.
Types ¶
type CopyFile ¶
CopyFile is a debefix plugin to configure files to be copied during the data generation process.
func NewOptions ¶
func NewOptions(options ...Option) (*CopyFile, []debefix.LoadOption, []debefix.ResolveOption)
NewOptions returns debefix debefix.LoadOption and debefix.ResolveOption to use the plugin.
func (*CopyFile) RowResolved ¶
func (c *CopyFile) RowResolved(ctx debefix.ValueResolveContext) error
type CopyFileCallback ¶ added in v1.3.1
type CopyFileCallback func(sourcePath, sourceFilename string, destinationPath, destinationFilename string) error
CopyFileCallback copy a file from a source to a destination.
type FileData ¶
type FileData struct {
ID string `yaml:"id"`
Value *string `yaml:"value"`
Source string `yaml:"source"`
Destination string `yaml:"destination"`
}
FileData is the information of the !copyfile tag.
type GetPathsCallback ¶ added in v1.3.1
type GetPathsCallback func(ctx debefix.ValueResolveContext, fieldname string, fileData FileData) (source string, destination string, err error)
GetPathsCallback gets the source and destination file names from FileData.
type GetValueCallback ¶ added in v1.3.1
type GetValueCallback func(ctx debefix.ValueCallbackResolveContext, fileData FileData) (value any, addField bool, err error)
GetValueCallback allows getting a value for the file field. If addField is false, no field will be added to the data, only the file will be copied.
type Option ¶
type Option func(*CopyFile)
func WithCopyFileCallback ¶ added in v1.3.1
func WithCopyFileCallback(callback CopyFileCallback) Option
WithCopyFileCallback sets the callback that copy files from a source to a destination.
func WithDestinationPath ¶ added in v1.3.1
WithDestinationPath sets the destination path, the root of all destination filenames.
func WithGetPathsCallback ¶ added in v1.3.1
func WithGetPathsCallback(callback GetPathsCallback) Option
WithGetPathsCallback sets the callback to get the source and destination filenames from the FileData parameters. The default implementation DefaultGetPathsCallback replaces field filters in both source and destination using ReplaceFieldsWithFilter.
func WithGetValueCallback ¶ added in v1.3.1
func WithGetValueCallback(setValueCallback GetValueCallback) Option
WithGetValueCallback sets the callback to have the option to set the file field value. The default implementation DefaultGetValueCallback don't add the field if [FileData.Value] was not set, otherwise it replaces field filters in it using ReplaceFieldsWithFilter.
func WithSourcePath ¶ added in v1.3.1
WithSourcePath sets the source path, the root of all source filenames.
type ParsedFields ¶ added in v1.3.1
type ParsedFields struct {
// contains filtered or unexported fields
}
ParsedFields stores the parsed fields from ParseFields.
func ParseFields ¶ added in v1.3.1
func ParseFields(str string) *ParsedFields
ParseFields parses curly-brace-delimited fields in strings and allows listing and replacing them. To escape a curly-brace, add two consecutive ones.
func (*ParsedFields) Fields ¶ added in v1.3.1
func (s *ParsedFields) Fields() []string
Fields returns the list of fields found.