Documentation ¶
Overview ¶
Package postgres is a PosgreSQL specific implementation of the 'gotidus.QueryBuilder' interface as well as several 'gotidus.Anonymizer' interface.
Index ¶
- type AnonymizationCondition
- type ConditionAnonymizer
- type EmailAnonymizer
- type NullAnonymizer
- type OverlayAnonymizer
- type QueryBuilder
- func (qb *QueryBuilder) CreateViewQuery(viewName string, tableName string, columns []string) string
- func (qb *QueryBuilder) DropViewQuery(viewName string) string
- func (qb *QueryBuilder) ListColumnsQuery() string
- func (qb *QueryBuilder) ListTablesQuery() string
- func (qb *QueryBuilder) ListViewsQuery() string
- type RegexReplaceAnonymizer
- type RemoveJSONKeysAnonymizer
- type TextAnonymizer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnonymizationCondition ¶
type AnonymizationCondition struct {
// contains filtered or unexported fields
}
AnonymizationCondition is the implementation which holds the conditions for the ConditionAnonymizer.
func NewAnonymizationCondition ¶
func NewAnonymizationCondition( column string, comparator string, value string, dataType string, anonymizer gotidus.Anonymizer, ) AnonymizationCondition
NewAnonymizationCondition initializes a new AnonymizationCondition object
type ConditionAnonymizer ¶
type ConditionAnonymizer struct {
// contains filtered or unexported fields
}
ConditionAnonymizer is a gotidus.Anonymizer interface implementation which allows elaborate case statements for anonymizing columns based on values in the same or other columns.
func NewConditionAnonymizer ¶
func NewConditionAnonymizer( dataType string, defaultAnonymizer gotidus.Anonymizer, conditions ...AnonymizationCondition, ) *ConditionAnonymizer
NewConditionAnonymizer initializes a new ConditionAnonymizer object
func (*ConditionAnonymizer) Build ¶
func (a *ConditionAnonymizer) Build(tableName, columnName string) string
Build returns the partial query from the configured data. If no conditions were given, it behaves as if the defaultAnonymizer was called directly. If one or more conditions are configured, they are defined as cases in a CASE statement and the defaultAnonymizer covers the ELSE branch.
type EmailAnonymizer ¶
type EmailAnonymizer struct {
// contains filtered or unexported fields
}
EmailAnonymizer is a gotidus.Anonymizer interface implementation, which allows anonymizing the local part of a string matching the general pattern of a mail address. For example
"test@example.com"
would be anonymized by a 15 character string based on the md5 hash of the local part.
func NewEmailAnonymizer ¶
func NewEmailAnonymizer() *EmailAnonymizer
NewEmailAnonymizer initializes a new EmailAnonymizer object
func (*EmailAnonymizer) Build ¶
func (a *EmailAnonymizer) Build(tableName, columnName string) string
Build returns the partial query holding the logic to overwrite the local part of an email address.
type NullAnonymizer ¶
type NullAnonymizer struct{}
NullAnonymizer is a gotidus.Anonymizer interface implementation. It overwrites any given value with NULL.
func NewNullAnonymizer ¶
func NewNullAnonymizer() *NullAnonymizer
NewNullAnonymizer initializes a new NullAnonymizer object.
func (*NullAnonymizer) Build ¶
func (a *NullAnonymizer) Build(tableName, columnName string) string
Build returns 'NULL::unknown' as partial query.
type OverlayAnonymizer ¶
type OverlayAnonymizer struct {
// contains filtered or unexported fields
}
OverlayAnonymizer is a gotidus.Anonymizer implementation which allows to overlay parts of a text field with a string based on the given overlayBase. count defines the number of repetitions of the overlayBase to be overlayed. start defines the first character to be overlayed.
func NewOverlayAnonymizer ¶
func NewOverlayAnonymizer(overlayBase string, start int, count int) *OverlayAnonymizer
NewOverlayAnonymizer intiializes a new OverlayAnonymizer object
func (*OverlayAnonymizer) Build ¶
func (a *OverlayAnonymizer) Build(tableName, columnName string) string
Build returns the partiql query to overlay the column content with a string.
type QueryBuilder ¶
type QueryBuilder struct{}
QueryBuilder is the specific implementation of the gotidus.QueryBuilder interface for PostgreSQL.
func NewQueryBuilder ¶
func NewQueryBuilder() *QueryBuilder
NewQueryBuilder initializes a new QueryBuilder object.
func (*QueryBuilder) CreateViewQuery ¶
func (qb *QueryBuilder) CreateViewQuery( viewName string, tableName string, columns []string, ) string
CreateViewQuery returns the query for creating a view. It builds the query using the view name, table name and the data for the selectable columns.
func (*QueryBuilder) DropViewQuery ¶
func (qb *QueryBuilder) DropViewQuery(viewName string) string
DropViewQuery returns the query for removing the view for which the name is given.
func (*QueryBuilder) ListColumnsQuery ¶
func (qb *QueryBuilder) ListColumnsQuery() string
ListColumnsQuery returns the query for listing existing columns. It requires passing the table name on query execution for which the columns should be listed.
func (*QueryBuilder) ListTablesQuery ¶
func (qb *QueryBuilder) ListTablesQuery() string
ListTablesQuery returns the query for listing existing tables.
func (*QueryBuilder) ListViewsQuery ¶
func (qb *QueryBuilder) ListViewsQuery() string
ListViewsQuery returns the query for listing existing views. It requires passing the view postfix on query execution.
type RegexReplaceAnonymizer ¶
type RegexReplaceAnonymizer struct {
// contains filtered or unexported fields
}
RegexReplaceAnonymizer is a gotidus.Anonymizer interface implementation which allows defining a pattern which is used to pick a part of a string which is then replaced with the defined replacement.
func NewRegexReplaceAnonymizer ¶
func NewRegexReplaceAnonymizer(pattern, replacement string) *RegexReplaceAnonymizer
NewRegexReplaceAnonymizer intializes a new RegexReplaceAnonymizer object.
func (*RegexReplaceAnonymizer) Build ¶
func (a *RegexReplaceAnonymizer) Build(tableName, columnName string) string
Build returns the partial query containing the PostgreSQL REGEXP_REPLACE function. It uses the configured pattern and replacement and applies it to the given column.
type RemoveJSONKeysAnonymizer ¶
type RemoveJSONKeysAnonymizer struct {
// contains filtered or unexported fields
}
RemoveJSONKeysAnonymizer is a gotidus.Anonymizer interface implementation which allows removing specific keys from a JSON object.
func NewRemoveJSONKeysAnonymizer ¶
func NewRemoveJSONKeysAnonymizer(keys []string) *RemoveJSONKeysAnonymizer
NewRemoveJSONKeysAnonymizer initializes a new RemoveJSONKeysAnonymizer object. The slice of strings given is the keys that are removed from the JSON content if they exist.
func (*RemoveJSONKeysAnonymizer) Build ¶
func (a *RemoveJSONKeysAnonymizer) Build(tableName, columnName string) string
Build returns the partial query to remove specific keys from the given column.
type TextAnonymizer ¶
type TextAnonymizer struct {
// contains filtered or unexported fields
}
TextAnonymizer is a gotidus.Anonymizer interface implementation. It can be used to randomize the text of a column.
func NewTextAnonymizer ¶
func NewTextAnonymizer() *TextAnonymizer
NewTextAnonymizer initializes a new TextAnonymizer object
func (*TextAnonymizer) Build ¶
func (a *TextAnonymizer) Build(tableName, columnName string) string
Build returns the partial query to randomize the text of a column while still keeping the general structure.