transformers

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JsonDeleteOpName = "delete"
	JsonSetOpName    = "set"
)
View Source
const (
	MPassword   string = "password"
	MName       string = "name"
	MAddress    string = "addr"
	MEmail      string = "email"
	MMobile     string = "mobile"
	MTelephone  string = "tel"
	MID         string = "id"
	MCreditCard string = "credit_card"
	MURL        string = "url"
	MDefault    string = "default"
)
View Source
const (
	Int2Length = 2
	Int4Length = 4
	Int8Length = 8
)
View Source
const (
	Sha1HashFunction = "sha1"
)

Variables

View Source
var ChoiceTransformerDefinition = utils.NewTransformerDefinition(
	utils.NewTransformerProperties(
		"RandomChoice",
		"Replace values chosen randomly from list",
	),

	NewRandomChoiceTransformer,

	toolkit.MustNewParameterDefinition(
		"column",
		"column name",
	).SetIsColumn(toolkit.NewColumnProperties().
		SetAffected(true),
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"values",
		`list of values in any format. The string with value "\N" supposed to be NULL value`,
	).SetRequired(true).
		SetUnmarshaler(randomChoiceValuesUnmarshaller),

	toolkit.MustNewParameterDefinition(
		"validate",
		`perform decode procedure via PostgreSQL driver using column type, ensuring that value has correct type`,
	).SetRequired(false).
		SetDefaultValue(toolkit.ParamsValue("true")),

	keepNullParameterDefinition,

	engineParameterDefinition,
)
View Source
var CmdTransformerDefinition = utils.NewTransformerDefinition(
	utils.NewTransformerProperties(
		cmdTransformerName,
		"Transform data via external program using stdin and stdout interaction",
	),

	NewCmd,

	toolkit.MustNewParameterDefinition(
		"columns",
		"affected column names. If empty use the whole tuple."+
			"The structure:"+
			`{`+
			`"name": "type:string, required:true, description: column Name",`+
			`"not_affected": "type:bool, required:false, description: is column affected in transformation", `+
			`"skip_original_data":  "type:bool, required:false, description: is original data required for transformer",`+
			`"skip_on_null_input":  "type:bool, required:false, description: skip transformation on null input"`+
			`}`,
	).SetDefaultValue([]byte("[]")).
		SetIsColumnContainer(true),

	toolkit.MustNewParameterDefinition(
		"executable",
		"path to executable file",
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"args",
		"list of parameters for executable file",
	).SetDefaultValue([]byte("[]")),

	toolkit.MustNewParameterDefinition(
		"driver",
		"row driver with parameters that is used for interacting with cmd. The default is csv. "+
			`The structure is:`+
			`{"name": "text|csv|json", "params": { "format": "[text|bytes]"} }`,
	).SetDefaultValue([]byte(`{"name": "csv"}`)),

	toolkit.MustNewParameterDefinition(
		"validate",
		"try to encode-decode data received from cmd",
	).SetDefaultValue([]byte("false")),

	toolkit.MustNewParameterDefinition(
		"timeout",
		"timeout for sending and receiving data from cmd",
	).SetDefaultValue([]byte("2s")),

	toolkit.MustNewParameterDefinition(
		"expected_exit_code",
		"expected exit code",
	).SetDefaultValue([]byte("0")),

	toolkit.MustNewParameterDefinition(
		"skip_on_behaviour",
		"skip transformation call if one of the provided columns has null value (any) or each of the provided"+
			" column has null values (all). This option works together with skip_on_null_input parameter on columns."+
			`Possible values: "all", "any"`,
	).SetDefaultValue([]byte("all")).
		SetRawValueValidator(cmdValidateSkipBehaviour),
)
View Source
var DictTransformerDefinition = utils.NewTransformerDefinition(
	utils.NewTransformerProperties(
		"Dict",
		"Replace values matched by dictionary keys",
	),

	NewDictTransformer,

	toolkit.MustNewParameterDefinition(
		"column",
		"column name",
	).SetIsColumn(toolkit.NewColumnProperties().
		SetAffected(true),
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"values",
		`map of value to replace in format: {"string": "string"}". The string with value "\N" supposed to be NULL value`,
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"default",
		`default value if not any value has been matched with dict. The string with value "\N" supposed to be NULL value. Default is empty`,
	).SetRequired(false),

	toolkit.MustNewParameterDefinition(
		"fail_not_matched",
		`fail if value is not matched with dict otherwise keep value`,
	).SetRequired(false).
		SetDefaultValue(toolkit.ParamsValue("true")),

	toolkit.MustNewParameterDefinition(
		"validate",
		`perform encode-decode procedure using column type, ensuring that value has correct type`,
	).SetRequired(false).
		SetDefaultValue(toolkit.ParamsValue("true")),
)
View Source
var EmailTransformerDefinition = utils.NewTransformerDefinition(
	utils.NewTransformerProperties(
		"RandomEmail",
		"Generate random email",
	),

	NewEmailTransformer,

	toolkit.MustNewParameterDefinition(
		"column",
		"column name",
	).SetIsColumn(toolkit.NewColumnProperties().
		SetAffected(true).
		SetAllowedColumnTypes(
			"text", "varchar", "char", "bpchar",
		),
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"keep_original_domain",
		`Keep original domain`,
	).SetDefaultValue(toolkit.ParamsValue("false")),

	toolkit.MustNewParameterDefinition(
		"local_part_template",
		`The template for local part of email. By default it is random characters`,
	),

	toolkit.MustNewParameterDefinition(
		"domain_part_template",
		`The template for domain part of email`,
	),

	toolkit.MustNewParameterDefinition(
		"domains",
		`List of domains to use for random email generation`,
	),

	toolkit.MustNewParameterDefinition(
		"validate",
		`validate generated email if using template`,
	).SetDefaultValue(toolkit.ParamsValue("false")),

	toolkit.MustNewParameterDefinition(
		"max_random_length",
		`max length of randomly generated part of the email`,
	).SetDefaultValue(toolkit.ParamsValue("32")),

	keepNullParameterDefinition,

	engineParameterDefinition,
)
View Source
var FakerTransformersDes = map[string]*FakerTransformerDef{

	"RandomLatitude": {
		Generator: func(opts ...options.OptionFunc) string {
			return fmt.Sprintf("%f", faker.Latitude())
		},
		SupportedTypes: []string{"float4", "float8", "numeric"},
		Description:    "Generates a random latitude value.",
	},
	"RandomLongitude": {
		Generator: func(opts ...options.OptionFunc) string {
			return fmt.Sprintf("%f", faker.Longitude())
		},
		SupportedTypes: []string{"float4", "float8", "numeric"},
		Description:    "Generates a random longitude value.",
	},

	"RandomMonthName": {
		Generator:      faker.MonthName,
		SupportedTypes: []string{"text", "varchar"},
		Description:    "Generates the name of a random month.",
	},
	"RandomYearString": {
		Generator:      faker.YearString,
		SupportedTypes: []string{"text", "varchar", "int2", "int4", "int8", "numeric"},
		Description:    "Generates a random year as a string.",
	},
	"RandomDayOfWeek": {
		Generator:      faker.DayOfWeek,
		SupportedTypes: []string{"text", "varchar"},
		Description:    "Generates a random day of the week.",
	},
	"RandomDayOfMonth": {
		Generator:      faker.DayOfMonth,
		SupportedTypes: []string{"text", "varchar", "int2", "int4", "int8", "numeric"},
		Description:    "Generates a random day of the month.",
	},
	"RandomCentury": {
		Generator:      faker.Century,
		SupportedTypes: []string{"text", "varchar"},
		Description:    "Generates a random century.",
	},
	"RandomTimezone": {
		Generator:      faker.Timezone,
		SupportedTypes: []string{"text", "varchar"},
		Description:    "Generates a random timezone.",
	},

	"RandomDomainName": {
		Generator:      faker.DomainName,
		SupportedTypes: []string{"text", "varchar"},
		Description:    "Generates a random domain name.",
	},
	"RandomURL": {
		Generator:      faker.URL,
		SupportedTypes: []string{"text", "varchar"},
		Description:    "Generates a random URL.",
	},
	"RandomUsername": {
		Generator:      faker.Username,
		SupportedTypes: []string{"text", "varchar"},
		Description:    "Generates a random username.",
	},
	"RandomPassword": {
		Generator:      faker.Password,
		SupportedTypes: []string{"text", "varchar"},
		Description:    "Generates a random password.",
	},

	"RandomWord": {
		Generator:      faker.Word,
		SupportedTypes: []string{"text", "varchar"},
		Description:    "Generates a random word.",
	},
	"RandomSentence": {
		Generator:      faker.Sentence,
		SupportedTypes: []string{"text", "varchar"},
		Description:    "Generates a random sentence.",
	},
	"RandomParagraph": {
		Generator:      faker.Paragraph,
		SupportedTypes: []string{"text", "varchar"},
		Description:    "Generates a random paragraph.",
	},

	"RandomCCType": {
		Generator:      faker.CCType,
		SupportedTypes: []string{"text", "varchar"},
		Description:    "Generates a random credit card type.",
	},
	"RandomCCNumber": {
		Generator:      faker.CCNumber,
		SupportedTypes: []string{"text", "varchar", "int4", "int8", "numeric"},
		Description:    "Generates a random credit card number.",
	},
	"RandomCurrency": {
		Generator:      faker.Currency,
		SupportedTypes: []string{"text", "varchar"},
		Description:    "Generates a random currency code.",
	},
	"RandomAmountWithCurrency": {
		Generator:      faker.AmountWithCurrency,
		SupportedTypes: []string{"text", "varchar"},
		Description:    "Generates a random monetary amount with currency.",
	},

	"RandomPhoneNumber": {
		Generator:      faker.Phonenumber,
		SupportedTypes: []string{"text", "varchar"},
		Description:    "Generates a random phone number.",
	},
	"RandomTollFreePhoneNumber": {
		Generator:      faker.TollFreePhoneNumber,
		SupportedTypes: []string{"text", "varchar"},
		Description:    "Generates a random toll-free phone number.",
	},
	"RandomE164PhoneNumber": {
		Generator:      faker.E164PhoneNumber,
		SupportedTypes: []string{"text", "varchar"},
		Description:    "Generates a random phone number in E.164 format.",
	},
}
View Source
var HashTransformerDefinition = utils.NewTransformerDefinition(
	utils.NewTransformerProperties(
		"Hash",
		"Generate hash of the text value using Scrypt hash function under the hood",
	),

	NewHashTransformer,

	toolkit.MustNewParameterDefinition(
		"column",
		"column name",
	).SetIsColumn(toolkit.NewColumnProperties().
		SetAffected(true).
		SetAllowedColumnTypes("text", "varchar"),
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"salt",
		"hex encoded salt string. This value may be provided via environment variable GREENMASK_GLOBAL_SALT",
	).SetGetFromGlobalEnvVariable("GREENMASK_GLOBAL_SALT"),

	toolkit.MustNewParameterDefinition(
		"function",
		fmt.Sprintf("hash function name. Possible values: %s",
			strings.Join(
				[]string{sha1Name, sha256Name, sha512Name, sha3224Name, sha3256Name, sha384Name, sha5124Name, md5Name},
				", ",
			),
		),
	).SetDefaultValue([]byte(sha3256Name)).
		SetRawValueValidator(validateHashFunctionsParameter),

	toolkit.MustNewParameterDefinition(
		"max_length",
		"limit length of hash function result",
	).SetDefaultValue([]byte("0")).
		SetRawValueValidator(validateMaxLengthParameter),
)
View Source
var JsonTransformerDefinition = utils.NewTransformerDefinition(

	utils.NewTransformerProperties(
		"Json",
		"Update json document",
	),

	NewJsonTransformer,

	toolkit.MustNewParameterDefinition(
		"column",
		"column name",
	).SetIsColumn(toolkit.NewColumnProperties().
		SetAffected(true).
		SetAllowedColumnTypes("json", "jsonb"),
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"operations",
		`list of operations that contains editing operation [{"operation": "set|delete", "path": "path to the part of the document", "value": "value in any type - string, int, float, list, object, null", "value_template": "go template", "error_not_exist", "raise error if not exists - boolean"}]`,
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"keep_null",
		"apply changes in value is null",
	).SetDefaultValue(toolkit.ParamsValue("true")),
)
View Source
var MaskingTransformerDefinition = utils.NewTransformerDefinition(
	utils.NewTransformerProperties(
		"Masking",
		"Mask a value using one of masking type",
	),

	NewMaskingTransformer,

	toolkit.MustNewParameterDefinition(
		"column",
		"column name",
	).SetIsColumn(
		toolkit.NewColumnProperties().
			SetAffected(true).
			SetAllowedColumnTypes("text", "varchar"),
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"type",
		"logical type of attribute (default, password, name, addr, email, mobile, tel, id, credit_card, url)",
	).SetRawValueValidator(maskerTypeValidator).
		SetDefaultValue(toolkit.ParamsValue(MDefault)),
)
View Source
var NoiseDateTransformerDefinition = utils.NewTransformerDefinition(
	utils.NewTransformerProperties(
		"NoiseDate",
		"Add some random value (shift value) in the provided interval",
	),

	NewNoiseDateTransformer,

	toolkit.MustNewParameterDefinition(
		"column",
		"column name",
	).SetIsColumn(toolkit.NewColumnProperties().
		SetAffected(true).
		SetAllowedColumnTypes("date", "timestamp", "timestamptz").
		SetSkipOnNull(true),
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"min_ratio",
		"min random duration for noise. Dy default 5% of the max_ratio",
	).SetCastDbType("interval").
		SetSupportTemplate(true),

	toolkit.MustNewParameterDefinition(
		"max_ratio",
		"max random duration for noise",
	).SetRequired(true).
		SetCastDbType("interval").
		SetSupportTemplate(true),

	toolkit.MustNewParameterDefinition(
		"min",
		"min threshold date (and/or time) of value",
	).SetSupportTemplate(true).
		SetLinkParameter("column").
		SetDynamicMode(
			toolkit.NewDynamicModeProperties().
				SetCompatibleTypes("date", "timestamp", "timestamptz"),
		),

	toolkit.MustNewParameterDefinition(
		"max",
		"max threshold date (and/or time) of value",
	).SetSupportTemplate(true).
		SetLinkParameter("column").
		SetDynamicMode(
			toolkit.NewDynamicModeProperties().
				SetCompatibleTypes("date", "timestamp", "timestamptz"),
		),

	truncateDateParameterDefinition,

	engineParameterDefinition,
)
View Source
var NoiseFloatTransformerDefinition = utils.NewTransformerDefinition(
	utils.NewTransformerProperties(
		"NoiseFloat",
		"Add noise to float value in min and max thresholds",
	),
	NewNoiseFloatTransformer,

	toolkit.MustNewParameterDefinition(
		"column",
		"column name",
	).SetIsColumn(toolkit.NewColumnProperties().
		SetAffected(true).
		SetAllowedColumnTypes("float4", "float8").
		SetSkipOnNull(true),
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"decimal",
		"Numbers of decimal",
	).SetSupportTemplate(true).
		SetDefaultValue(toolkit.ParamsValue("4")),

	toolkit.MustNewParameterDefinition(
		"min",
		"min float value threshold",
	).SetLinkParameter("column").
		SetSupportTemplate(true).
		SetDynamicMode(
			toolkit.NewDynamicModeProperties().
				SetCompatibleTypes("float4", "float8", "int2", "int4", "int8"),
		),

	toolkit.MustNewParameterDefinition(
		"max",
		"max float value threshold",
	).SetLinkParameter("column").
		SetSupportTemplate(true).
		SetDynamicMode(
			toolkit.NewDynamicModeProperties().
				SetCompatibleTypes("float4", "float8", "int2", "int4", "int8"),
		),

	minRatioParameterDefinition,

	maxRatioParameterDefinition,

	engineParameterDefinition,
)
View Source
var NoiseIntTransformerDefinition = utils.NewTransformerDefinition(
	utils.NewTransformerProperties(
		"NoiseInt",
		"Make noise value for int",
	),

	NewNoiseIntTransformer,

	toolkit.MustNewParameterDefinition(
		"column",
		"column name",
	).SetIsColumn(toolkit.NewColumnProperties().
		SetAffected(true).
		SetAllowedColumnTypes("int2", "int4", "int8").
		SetSkipOnNull(true),
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"min",
		"min value threshold limiter",
	).SetSupportTemplate(true).
		SetDynamicMode(
			toolkit.NewDynamicModeProperties().
				SetCompatibleTypes("int2", "int4", "int8"),
		),

	toolkit.MustNewParameterDefinition(
		"max",
		"max value threshold limiter",
	).SetSupportTemplate(true).
		SetDynamicMode(
			toolkit.NewDynamicModeProperties().
				SetCompatibleTypes("int2", "int4", "int8"),
		),

	minRatioParameterDefinition,

	maxRatioParameterDefinition,

	engineParameterDefinition,
)
View Source
var NoiseNumericTransformerDefinition = utils.NewTransformerDefinition(
	utils.NewTransformerProperties(
		"NoiseNumeric",
		"Add noise to numeric value in min and max thresholds",
	),
	NewNumericFloatTransformer,

	toolkit.MustNewParameterDefinition(
		"column",
		"column name",
	).SetIsColumn(toolkit.NewColumnProperties().
		SetAffected(true).
		SetAllowedColumnTypes("numeric", "decimal").
		SetSkipOnNull(true),
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"decimal",
		"Numbers of decimal",
	).SetSupportTemplate(true).
		SetDefaultValue(toolkit.ParamsValue("4")),

	toolkit.MustNewParameterDefinition(
		"min",
		"min float value threshold",
	).SetSupportTemplate(true).
		SetLinkParameter("column").
		SetDynamicMode(
			toolkit.NewDynamicModeProperties().
				SetCompatibleTypes(
					"float4",
					"float8",
					"numeric",
					"decimal",
					"int2",
					"int4",
					"int8",
				).SetUnmarshaler(numericTypeUnmarshaler),
		),

	toolkit.MustNewParameterDefinition(
		"max",
		"max float value threshold",
	).SetSupportTemplate(true).
		SetLinkParameter("column").
		SetDynamicMode(
			toolkit.NewDynamicModeProperties().
				SetCompatibleTypes(
					"float4",
					"float8",
					"numeric",
					"decimal",
					"int2",
					"int4",
					"int8",
				).SetUnmarshaler(numericTypeUnmarshaler),
		),

	minRatioParameterDefinition,

	maxRatioParameterDefinition,

	engineParameterDefinition,
)
View Source
var RandomIpDefinition = utils.NewTransformerDefinition(
	utils.NewTransformerProperties("RandomIp", "Generate V4 or V6 IP in the provided subnet"),

	NewIpTransformer,

	toolkit.MustNewParameterDefinition(
		"column",
		"Column name",
	).SetIsColumn(toolkit.NewColumnProperties().
		SetAffected(true).
		SetAllowedColumnTypes("text", "varchar", "inet"),
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"subnet",
		"Subnet for generating random ip in V4 or V6 format",
	).SetRequired(true).
		SetSupportTemplate(true).
		SetCastDbType("cidr").
		SetDynamicMode(
			toolkit.NewDynamicModeProperties().
				SetCompatibleTypes("text", "varchar", "cidr"),
		),

	engineParameterDefinition,
)
View Source
var RandomMacAddressDefinition = utils.NewTransformerDefinition(
	utils.NewTransformerProperties("RandomMac", "Generate random mac address"),

	NewMacAddressTransformer,

	toolkit.MustNewParameterDefinition(
		"column",
		"Column name",
	).SetIsColumn(toolkit.NewColumnProperties().
		SetAffected(true).
		SetAllowedColumnTypes("macaddr", "varchar", "text"),
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"keep_original_vendor",
		"Keep original vendor. Default false",
	).SetRequired(false).
		SetDefaultValue(toolkit.ParamsValue("false")),

	toolkit.MustNewParameterDefinition(
		"cast_type",
		"Cast type, supported types are: individual, group, any.",
	).SetRequired(false).
		SetAllowedValues(
			toolkit.ParamsValue(castTypeNameIndividual),
			toolkit.ParamsValue(castTypeNameGroup),
			toolkit.ParamsValue(castTypeNameAny),
		).
		SetDefaultValue(toolkit.ParamsValue(castTypeNameAny)).
		SetUnmarshaler(scanCastType),

	toolkit.MustNewParameterDefinition(
		"management_type",
		"Management type, supported types are: universal, local, any.",
	).SetRequired(false).SetAllowedValues(
		toolkit.ParamsValue(managementTypeNameUniversal),
		toolkit.ParamsValue(managementTypeNameLocal),
		toolkit.ParamsValue(managementTypeNameAny),
	).SetDefaultValue(toolkit.ParamsValue(managementTypeNameAny)).
		SetUnmarshaler(scanManagementType),

	engineParameterDefinition,
)
View Source
var RealAddressTransformerDefinition = utils.NewTransformerDefinition(
	utils.NewTransformerProperties(
		"RealAddress",
		"Generate a real address",
	),

	NewRealAddressTransformer,

	toolkit.MustNewParameterDefinition(
		"columns",
		"affected column names."+
			"The structure:"+
			`{`+
			`"name": "type:string, required:true, description: column Name",`+
			`"template": "type:string, required:true, description: gotemplate with real address attributes injections",`+
			`"keep_null": "type:bool, required:false, description: keep null values",`+
			`}`,
	).SetRequired(true).
		SetIsColumnContainer(true),
)
View Source
var RegexpReplaceTransformerDefinition = utils.NewTransformerDefinition(
	utils.NewTransformerProperties(
		"RegexpReplace",
		"Replace string using regular expression",
	),

	NewRegexpReplaceTransformer,

	toolkit.MustNewParameterDefinition(
		"column",
		"column name",
	).SetIsColumn(toolkit.NewColumnProperties().
		SetAffected(true).
		SetAllowedColumnTypes("varchar", "text", "bpchar"),
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"regexp",
		"regular expression",
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"replace",
		"replacement value",
	).SetRequired(true),
)
View Source
var ReplaceTransformerDefinition = utils.NewTransformerDefinition(
	utils.NewTransformerProperties(
		"Replace",
		"Replace column value to the provided",
	),

	NewReplaceTransformer,

	toolkit.MustNewParameterDefinition(
		"column",
		"column name",
	).SetIsColumn(toolkit.NewColumnProperties().
		SetAffected(true),
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"value",
		"value to replace",
	).SetRequired(true).
		SetLinkParameter("column"),

	toolkit.MustNewParameterDefinition(
		"keep_null",
		"indicates that NULL values must not be replaced with transformed values",
	).SetDefaultValue(toolkit.ParamsValue("true")),

	toolkit.MustNewParameterDefinition(
		"validate",
		"validate the value via driver decoding procedure",
	).SetDefaultValue(toolkit.ParamsValue("true")),
)
View Source
var SetNullTransformerDefinition = utils.NewTransformerDefinition(
	utils.NewTransformerProperties(
		"SetNull",
		"Set NULL value",
	),
	NewSetNullTransformer,
	toolkit.MustNewParameterDefinition(
		"column",
		"column name",
	).SetIsColumn(toolkit.NewColumnProperties().
		SetAffected(true).
		SetNullable(true),
	).SetRequired(true),
)
View Source
var TemplateRecordTransformerDefinition = utils.NewTransformerDefinition(
	utils.NewTransformerProperties(
		"TemplateRecord",
		"Modify the record using gotemplate",
	),
	NewTemplateRecordTransformer,

	toolkit.MustNewParameterDefinition(
		"template",
		"gotemplate string",
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"validate",
		"validate template result via PostgreSQL driver decoding",
	).SetRequired(false).
		SetDefaultValue(toolkit.ParamsValue("false")),

	toolkit.MustNewParameterDefinition(
		"columns",
		"columns that supposed to be affected by the template. The list of columns will be checked for constraint violation",
	).SetRequired(false).
		SetDefaultValue(toolkit.ParamsValue("[]")),
)
View Source
var TemplateTransformerDefinition = utils.NewTransformerDefinition(
	utils.NewTransformerProperties(
		"Template",
		"Modify the value using gotemplate",
	),
	NewTemplateTransformer,
	toolkit.MustNewParameterDefinition(
		"column",
		"column name",
	).SetIsColumn(toolkit.NewColumnProperties().
		SetAffected(true),
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"template",
		"gotemplate string",
	).SetRequired(true),

	toolkit.MustNewParameterDefinition(
		"validate",
		"validate template result via PostgreSQL driver decoding",
	).SetRequired(false).
		SetDefaultValue(toolkit.ParamsValue("false")),
)

Functions

func EmailParse added in v0.2.0

func EmailParse(email []byte) (localPart, domain []byte, err error)

EmailParse parses the email into local part and domain part, and returns an error if the format is wrong

func EmailValidate added in v0.2.0

func EmailValidate(email []byte) bool

EmailValidate checks if the email is in a valid format

func MakeNewFakeTransformerFunction added in v0.1.1

func MakeNewFakeTransformerFunction(generator FakerFunc) utils.NewTransformerFunc

func NewBooleanTransformer added in v0.2.0

func NewBooleanTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewDictTransformer

func NewDictTransformer(
	ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer,
) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewEmailTransformer added in v0.2.0

func NewEmailTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewFakeTransformer added in v0.1.1

func NewFakeTransformer(
	ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer, generator FakerFunc,
) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewFloatTransformer added in v0.2.0

func NewFloatTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewHashTransformer

func NewHashTransformer(
	ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer,
) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewIntegerTransformer added in v0.2.0

func NewIntegerTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewIpTransformer added in v0.2.0

func NewIpTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewMacAddressTransformer added in v0.2.0

func NewMacAddressTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewNoiseDateTransformer

func NewNoiseDateTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewNoiseDateTransformerBase added in v0.2.0

func NewNoiseDateTransformerBase(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer, encoder noiseTimestampMinMaxEncoder) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewNoiseFloatTransformer

func NewNoiseFloatTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewNoiseIntTransformer

func NewNoiseIntTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewNumericFloatTransformer added in v0.2.0

func NewNumericFloatTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewRandomChoiceTransformer

func NewRandomChoiceTransformer(
	ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer,
) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewRandomNameTransformer added in v0.2.0

func NewRandomNameTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewRandomNumericTransformer added in v0.2.0

func NewRandomNumericTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewRandomStringTransformer

func NewRandomStringTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewRandomUuidTransformer

func NewRandomUuidTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewRealAddressTransformer added in v0.1.1

func NewRealAddressTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewRegexpReplaceTransformer

func NewRegexpReplaceTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewTemplateRecordTransformer

func NewTemplateRecordTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewTemplateTransformer

func NewTemplateTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewTimestampTransformer added in v0.2.0

func NewTimestampTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewTimestampTransformerBase added in v0.2.0

func NewTimestampTransformerBase(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer, encoder timestampMinMaxEncoder) (utils.Transformer, toolkit.ValidationWarnings, error)

func NewUnixTimestampTransformer added in v0.2.0

func NewUnixTimestampTransformer(ctx context.Context, driver *toolkit.Driver, parameters map[string]toolkit.Parameterizer) (utils.Transformer, toolkit.ValidationWarnings, error)

Types

type BooleanTransformer added in v0.2.0

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

func (*BooleanTransformer) Done added in v0.2.0

func (rbt *BooleanTransformer) Done(ctx context.Context) error

func (*BooleanTransformer) GetAffectedColumns added in v0.2.0

func (rbt *BooleanTransformer) GetAffectedColumns() map[int]string

func (*BooleanTransformer) Init added in v0.2.0

func (rbt *BooleanTransformer) Init(ctx context.Context) error

func (*BooleanTransformer) Transform added in v0.2.0

func (rbt *BooleanTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type ChoiceTransformer added in v0.2.0

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

func (*ChoiceTransformer) Done added in v0.2.0

func (rct *ChoiceTransformer) Done(ctx context.Context) error

func (*ChoiceTransformer) GetAffectedColumns added in v0.2.0

func (rct *ChoiceTransformer) GetAffectedColumns() map[int]string

func (*ChoiceTransformer) Init added in v0.2.0

func (rct *ChoiceTransformer) Init(ctx context.Context) error

func (*ChoiceTransformer) Transform added in v0.2.0

func (rct *ChoiceTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type Cmd

type Cmd struct {
	*utils.CmdTransformerBase

	Columns []*Column
	// contains filtered or unexported fields
}

func (*Cmd) Done

func (c *Cmd) Done(ctx context.Context) error

func (*Cmd) GetAffectedColumns

func (c *Cmd) GetAffectedColumns() map[int]string

func (*Cmd) Init

func (c *Cmd) Init(ctx context.Context) error

func (*Cmd) Transform

func (c *Cmd) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type Column

type Column struct {
	Name             string `json:"name"`
	NotAffected      bool   `json:"not_affected"`
	SkipOnNullInput  bool   `json:"skip_on_null_input"`
	SkipOriginalData bool   `json:"skip_original_data"`
}

type ColumnContext

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

func NewColumnContext

func NewColumnContext(columnType string, columnName string) *ColumnContext

func (*ColumnContext) DecodeValue

func (cc *ColumnContext) DecodeValue(v any) (any, error)

func (*ColumnContext) DecodeValueByColumn

func (cc *ColumnContext) DecodeValueByColumn(name string, v any) (any, error)

func (*ColumnContext) DecodeValueByType

func (cc *ColumnContext) DecodeValueByType(name string, v any) (any, error)

func (*ColumnContext) EncodeValue

func (cc *ColumnContext) EncodeValue(v any) (any, error)

func (*ColumnContext) EncodeValueByColumn

func (cc *ColumnContext) EncodeValueByColumn(name string, v any) (any, error)

func (*ColumnContext) EncodeValueByType

func (cc *ColumnContext) EncodeValueByType(name string, v any) (any, error)

func (*ColumnContext) GetColumnRawValue

func (cc *ColumnContext) GetColumnRawValue(name string) (any, error)

func (*ColumnContext) GetColumnType

func (cc *ColumnContext) GetColumnType() string

func (*ColumnContext) GetColumnValue

func (cc *ColumnContext) GetColumnValue(name string) (any, error)

func (*ColumnContext) GetRawValue

func (cc *ColumnContext) GetRawValue() (any, error)

func (*ColumnContext) GetValue

func (cc *ColumnContext) GetValue() (any, error)

type DictTransformer

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

func (*DictTransformer) Done

func (ht *DictTransformer) Done(ctx context.Context) error

func (*DictTransformer) GetAffectedColumns

func (ht *DictTransformer) GetAffectedColumns() map[int]string

func (*DictTransformer) Init

func (ht *DictTransformer) Init(ctx context.Context) error

func (*DictTransformer) Transform

func (ht *DictTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type EmailTransformer added in v0.2.0

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

func (*EmailTransformer) Done added in v0.2.0

func (rit *EmailTransformer) Done(ctx context.Context) error

func (*EmailTransformer) GetAffectedColumns added in v0.2.0

func (rit *EmailTransformer) GetAffectedColumns() map[int]string

func (*EmailTransformer) Init added in v0.2.0

func (rit *EmailTransformer) Init(ctx context.Context) error

func (*EmailTransformer) Transform added in v0.2.0

func (rit *EmailTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type FakeTransformer added in v0.1.1

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

func (*FakeTransformer) Done added in v0.1.1

func (fts *FakeTransformer) Done(ctx context.Context) error

func (*FakeTransformer) GetAffectedColumns added in v0.1.1

func (fts *FakeTransformer) GetAffectedColumns() map[int]string

func (*FakeTransformer) Init added in v0.1.1

func (fts *FakeTransformer) Init(ctx context.Context) error

func (*FakeTransformer) Transform added in v0.1.1

func (fts *FakeTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type FakerFunc added in v0.1.1

type FakerFunc func(opts ...options.OptionFunc) string

type FakerTransformerDef added in v0.1.1

type FakerTransformerDef struct {
	SupportedTypes []string
	Description    string
	Generator      FakerFunc
}

type FloatTransformer added in v0.2.0

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

func (*FloatTransformer) Done added in v0.2.0

func (rit *FloatTransformer) Done(ctx context.Context) error

func (*FloatTransformer) GetAffectedColumns added in v0.2.0

func (rit *FloatTransformer) GetAffectedColumns() map[int]string

func (*FloatTransformer) Init added in v0.2.0

func (rit *FloatTransformer) Init(ctx context.Context) error

func (*FloatTransformer) Transform added in v0.2.0

func (rit *FloatTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type HashTransformer

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

func (*HashTransformer) Done

func (ht *HashTransformer) Done(ctx context.Context) error

func (*HashTransformer) GetAffectedColumns

func (ht *HashTransformer) GetAffectedColumns() map[int]string

func (*HashTransformer) Init

func (ht *HashTransformer) Init(ctx context.Context) error

func (*HashTransformer) Transform

func (ht *HashTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type IntegerTransformer added in v0.2.0

type IntegerTransformer struct {
	*transformers.RandomInt64Transformer
	// contains filtered or unexported fields
}

func (*IntegerTransformer) Done added in v0.2.0

func (rit *IntegerTransformer) Done(ctx context.Context) error

func (*IntegerTransformer) GetAffectedColumns added in v0.2.0

func (rit *IntegerTransformer) GetAffectedColumns() map[int]string

func (*IntegerTransformer) Init added in v0.2.0

func (rit *IntegerTransformer) Init(ctx context.Context) error

func (*IntegerTransformer) Transform added in v0.2.0

func (rit *IntegerTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type JsonContext

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

func NewJsonContext

func NewJsonContext() *JsonContext

func (*JsonContext) DecodeValueByColumn

func (jc *JsonContext) DecodeValueByColumn(name string, v any) (any, error)

func (*JsonContext) DecodeValueByType

func (jc *JsonContext) DecodeValueByType(name string, v any) (any, error)

func (*JsonContext) EncodeValueByColumn

func (jc *JsonContext) EncodeValueByColumn(name string, v any) (any, error)

func (*JsonContext) EncodeValueByType

func (jc *JsonContext) EncodeValueByType(name string, v any) (any, error)

func (*JsonContext) GetColumnRawValue

func (jc *JsonContext) GetColumnRawValue(name string) (any, error)

func (*JsonContext) GetColumnValue

func (jc *JsonContext) GetColumnValue(name string) (any, error)

func (*JsonContext) GetOriginalValue

func (jc *JsonContext) GetOriginalValue() any

func (*JsonContext) GetPath

func (jc *JsonContext) GetPath() string

func (*JsonContext) OriginalValueExists

func (jc *JsonContext) OriginalValueExists() bool

type JsonTransformer

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

func (*JsonTransformer) Done

func (jt *JsonTransformer) Done(ctx context.Context) error

func (*JsonTransformer) GetAffectedColumns

func (jt *JsonTransformer) GetAffectedColumns() map[int]string

func (*JsonTransformer) Init

func (jt *JsonTransformer) Init(ctx context.Context) error

func (*JsonTransformer) Transform

func (jt *JsonTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type MaskingTransformer

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

func (*MaskingTransformer) Done

func (mt *MaskingTransformer) Done(ctx context.Context) error

func (*MaskingTransformer) GetAffectedColumns

func (mt *MaskingTransformer) GetAffectedColumns() map[int]string

func (*MaskingTransformer) Init

func (mt *MaskingTransformer) Init(ctx context.Context) error

func (*MaskingTransformer) Transform

func (mt *MaskingTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type NoiseDateTransformer

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

func (*NoiseDateTransformer) Done

func (ndt *NoiseDateTransformer) Done(ctx context.Context) error

func (*NoiseDateTransformer) GetAffectedColumns

func (ndt *NoiseDateTransformer) GetAffectedColumns() map[int]string

func (*NoiseDateTransformer) Init

func (ndt *NoiseDateTransformer) Init(ctx context.Context) error

func (*NoiseDateTransformer) Transform

func (ndt *NoiseDateTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type NoiseFloatTransformer

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

func (*NoiseFloatTransformer) Done

func (nft *NoiseFloatTransformer) Done(ctx context.Context) error

func (*NoiseFloatTransformer) GetAffectedColumns

func (nft *NoiseFloatTransformer) GetAffectedColumns() map[int]string

func (*NoiseFloatTransformer) Init

func (nft *NoiseFloatTransformer) Init(ctx context.Context) error

func (*NoiseFloatTransformer) Transform

func (nft *NoiseFloatTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type NoiseIntTransformer

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

func (*NoiseIntTransformer) Done

func (nit *NoiseIntTransformer) Done(ctx context.Context) error

func (*NoiseIntTransformer) GetAffectedColumns

func (nit *NoiseIntTransformer) GetAffectedColumns() map[int]string

func (*NoiseIntTransformer) Init

func (nit *NoiseIntTransformer) Init(ctx context.Context) error

func (*NoiseIntTransformer) Transform

func (nit *NoiseIntTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type NoiseNumericTransformer added in v0.2.0

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

TODO: Add numeric introspection (getting the Numering settings)

func (*NoiseNumericTransformer) Done added in v0.2.0

func (*NoiseNumericTransformer) GetAffectedColumns added in v0.2.0

func (nft *NoiseNumericTransformer) GetAffectedColumns() map[int]string

func (*NoiseNumericTransformer) Init added in v0.2.0

func (*NoiseNumericTransformer) Transform added in v0.2.0

type NumericTransformer added in v0.2.0

type NumericTransformer struct {
	*transformers.RandomNumericTransformer
	// contains filtered or unexported fields
}

TODO: Add numeric introspection (getting the Numering settings)

func (*NumericTransformer) Done added in v0.2.0

func (bit *NumericTransformer) Done(ctx context.Context) error

func (*NumericTransformer) GetAffectedColumns added in v0.2.0

func (bit *NumericTransformer) GetAffectedColumns() map[int]string

func (*NumericTransformer) Init added in v0.2.0

func (bit *NumericTransformer) Init(ctx context.Context) error

func (*NumericTransformer) Transform added in v0.2.0

func (bit *NumericTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type Operation

type Operation struct {
	Operation     string      `mapstructure:"operation" json:"operation"`
	Value         interface{} `mapstructure:"value,omitempty" json:"value"`
	ValueTemplate string      `mapstructure:"value_template,omitempty" json:"value_template"`
	Path          string      `mapstructure:"path" json:"path"`
	ErrorNotExist bool        `mapstructure:"error_not_exist" json:"error_not_exist"`
	// contains filtered or unexported fields
}

func (*Operation) Apply

func (o *Operation) Apply(inp []byte, tctx *JsonContext, buf *bytes.Buffer) ([]byte, error)

type RandomIp added in v0.2.0

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

func (*RandomIp) Done added in v0.2.0

func (rbt *RandomIp) Done(ctx context.Context) error

func (*RandomIp) GetAffectedColumns added in v0.2.0

func (rbt *RandomIp) GetAffectedColumns() map[int]string

func (*RandomIp) Init added in v0.2.0

func (rbt *RandomIp) Init(ctx context.Context) error

func (*RandomIp) Transform added in v0.2.0

func (rbt *RandomIp) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type RandomMac added in v0.2.0

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

func (*RandomMac) Done added in v0.2.0

func (rbt *RandomMac) Done(ctx context.Context) error

func (*RandomMac) GetAffectedColumns added in v0.2.0

func (rbt *RandomMac) GetAffectedColumns() map[int]string

func (*RandomMac) Init added in v0.2.0

func (rbt *RandomMac) Init(ctx context.Context) error

func (*RandomMac) Transform added in v0.2.0

func (rbt *RandomMac) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type RandomMacSettings added in v0.2.0

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

type RandomNameTransformer added in v0.2.0

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

func (*RandomNameTransformer) Done added in v0.2.0

func (nft *RandomNameTransformer) Done(ctx context.Context) error

func (*RandomNameTransformer) GetAffectedColumns added in v0.2.0

func (nft *RandomNameTransformer) GetAffectedColumns() map[int]string

func (*RandomNameTransformer) Init added in v0.2.0

func (nft *RandomNameTransformer) Init(ctx context.Context) error

func (*RandomNameTransformer) Transform added in v0.2.0

func (nft *RandomNameTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type RandomStringTransformer

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

func (*RandomStringTransformer) Done

func (*RandomStringTransformer) GetAffectedColumns

func (rst *RandomStringTransformer) GetAffectedColumns() map[int]string

func (*RandomStringTransformer) Init

func (*RandomStringTransformer) Transform

type RandomUuidTransformer

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

func (*RandomUuidTransformer) Done

func (rut *RandomUuidTransformer) Done(ctx context.Context) error

func (*RandomUuidTransformer) GetAffectedColumns

func (rut *RandomUuidTransformer) GetAffectedColumns() map[int]string

func (*RandomUuidTransformer) Init

func (rut *RandomUuidTransformer) Init(ctx context.Context) error

func (*RandomUuidTransformer) Transform

func (rut *RandomUuidTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type RealAddressColumn added in v0.1.1

type RealAddressColumn struct {
	Name     string `json:"name"`
	KeepNull bool   `json:"keep_null"`
	Template string `json:"template"`
	// contains filtered or unexported fields
}

type RealAddressTransformer added in v0.1.1

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

func (*RealAddressTransformer) Done added in v0.1.1

func (*RealAddressTransformer) GetAffectedColumns added in v0.1.1

func (rat *RealAddressTransformer) GetAffectedColumns() map[int]string

func (*RealAddressTransformer) Init added in v0.1.1

func (*RealAddressTransformer) Transform added in v0.1.1

type RealAddressValue added in v0.1.1

type RealAddressValue struct {
	Address    string  `json:"address1"`
	City       string  `json:"city"`
	State      string  `json:"state"`
	PostalCode string  `json:"postalCode"`
	Latitude   float64 `json:"lat"`
	Longitude  float64 `json:"lng"`
}

type RegexpReplaceTransformer

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

func (*RegexpReplaceTransformer) Done

func (*RegexpReplaceTransformer) GetAffectedColumns

func (rrt *RegexpReplaceTransformer) GetAffectedColumns() map[int]string

func (*RegexpReplaceTransformer) Init

func (*RegexpReplaceTransformer) Transform

type ReplaceTransformer

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

func (*ReplaceTransformer) Done

func (rt *ReplaceTransformer) Done(ctx context.Context) error

func (*ReplaceTransformer) GetAffectedColumns

func (rt *ReplaceTransformer) GetAffectedColumns() map[int]string

func (*ReplaceTransformer) Init

func (rt *ReplaceTransformer) Init(ctx context.Context) error

func (*ReplaceTransformer) Transform

func (rt *ReplaceTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type RoRecordContext added in v0.2.0

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

func NewRoRecordContext added in v0.2.0

func NewRoRecordContext() *RoRecordContext

func (*RoRecordContext) DecodeValueByColumn added in v0.2.0

func (cc *RoRecordContext) DecodeValueByColumn(name string, v any) (any, error)

func (*RoRecordContext) DecodeValueByType added in v0.2.0

func (cc *RoRecordContext) DecodeValueByType(name string, v any) (any, error)

func (*RoRecordContext) EncodeValueByColumn added in v0.2.0

func (cc *RoRecordContext) EncodeValueByColumn(name string, v any) (any, error)

func (*RoRecordContext) EncodeValueByType added in v0.2.0

func (cc *RoRecordContext) EncodeValueByType(name string, v any) (any, error)

func (*RoRecordContext) GetColumnRawValue added in v0.2.0

func (cc *RoRecordContext) GetColumnRawValue(name string) (any, error)

func (*RoRecordContext) GetColumnValue added in v0.2.0

func (cc *RoRecordContext) GetColumnValue(name string) (any, error)

type SetNullTransformer

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

func (*SetNullTransformer) Done

func (sut *SetNullTransformer) Done(ctx context.Context) error

func (*SetNullTransformer) GetAffectedColumns

func (sut *SetNullTransformer) GetAffectedColumns() map[int]string

func (*SetNullTransformer) Init

func (sut *SetNullTransformer) Init(ctx context.Context) error

func (*SetNullTransformer) Transform

func (sut *SetNullTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type TemplateRecordTransformer

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

func (*TemplateRecordTransformer) Done

func (*TemplateRecordTransformer) GetAffectedColumns

func (sut *TemplateRecordTransformer) GetAffectedColumns() map[int]string

func (*TemplateRecordTransformer) Init

func (*TemplateRecordTransformer) Transform

type TemplateTransformer

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

func (*TemplateTransformer) Done

func (sut *TemplateTransformer) Done(ctx context.Context) error

func (*TemplateTransformer) GetAffectedColumns

func (sut *TemplateTransformer) GetAffectedColumns() map[int]string

func (*TemplateTransformer) Init

func (sut *TemplateTransformer) Init(ctx context.Context) error

func (*TemplateTransformer) Transform

func (sut *TemplateTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type TimestampTransformer added in v0.2.0

type TimestampTransformer struct {
	*transformers.Timestamp
	// contains filtered or unexported fields
}

func (*TimestampTransformer) Done added in v0.2.0

func (rdt *TimestampTransformer) Done(ctx context.Context) error

func (*TimestampTransformer) GetAffectedColumns added in v0.2.0

func (rdt *TimestampTransformer) GetAffectedColumns() map[int]string

func (*TimestampTransformer) Init added in v0.2.0

func (rdt *TimestampTransformer) Init(ctx context.Context) error

func (*TimestampTransformer) Transform added in v0.2.0

func (rdt *TimestampTransformer) Transform(ctx context.Context, r *toolkit.Record) (*toolkit.Record, error)

type UnixTimestampTransformer added in v0.2.0

type UnixTimestampTransformer struct {
	*TimestampTransformer
	// contains filtered or unexported fields
}

func (*UnixTimestampTransformer) Init added in v0.2.0

func (*UnixTimestampTransformer) Transform added in v0.2.0

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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