utils

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AWSSecretAccessKey = "AWS_SECRET_ACCESS_KEY"
	GCPCredentials     = "CREDENTIALS"
)
View Source
const DefaultFilterString = ".*"

Variables

View Source
var FileConventionRegex = regexp.MustCompile(`part_[\d+]{8}(\.csv|\.tar\.gz)`)
View Source
var RedactedQueryParams = map[string]struct{}{}

redactedQueryParams is the set of query parameter names registered by the external storage providers that should be redacted from external storage URIs whenever they are displayed to a user.

Functions

func BuildTable

func BuildTable(of []OutputFormat) (string, error)

BuildTable builds the table from the table header and structured table data and returns a string that can be outputted to the command or stdout.

func FormatDurationToTimeString

func FormatDurationToTimeString(duration time.Duration) string

func MatchesFileConvention

func MatchesFileConvention(fileName string) bool

func MatchesFilter

func MatchesFilter(n dbtable.Name, schemaRe, tableRe *regexp.Regexp) bool

func MaybeFormatCDCCursor

func MaybeFormatCDCCursor(testOnly bool, s string) string

MaybeFormatCDCCursor is to make a deterministic CDC cursor for test.

func MaybeFormatDurationForTest

func MaybeFormatDurationForTest(testOnly bool, duration time.Duration) time.Duration

MaybeFormatDurationForTest is to make a deterministic duration for test.

func MaybeFormatFetchID

func MaybeFormatFetchID(testOnly bool, s string) string

MaybeFormatFetchID is to make a deterministic fetch id for test.

func MaybeFormatID

func MaybeFormatID(testOnly bool, s uuid.UUID) uuid.UUID

MaybeFormatID is to make a deterministic UUID for test.

func PrettyJSON

func PrettyJSON(v any) string

func SanitizeExternalStorageURI

func SanitizeExternalStorageURI(path string, extraParams []string) (string, error)

SanitizeExternalStorageURI returns the external storage URI with with some secrets redacted, for use when showing these URIs in the UI, to provide some protection from shoulder-surfing. The param is still present -- just redacted -- to make it clearer that that value is indeed persisted interally. extraParams which should be scrubbed -- for params beyond those that the various cloud-storage URIs supported by this package know about -- can be passed allowing this function to be used to scrub other URIs too.

func SchemaTableString

func SchemaTableString(schema, table tree.Name) string

Types

type ExtraneousTable

type ExtraneousTable struct {
	dbtable.DBTable
}

ExtraneousTable represents a table that is extraneous to a database.

type FilterConfig

type FilterConfig struct {
	SchemaFilter FilterString
	TableFilter  FilterString
}

func DefaultFilterConfig

func DefaultFilterConfig() FilterConfig

type FilterString

type FilterString = string

type MissingTable

type MissingTable struct {
	dbtable.DBTable
}

MissingTable represents a table that is missing from a database.

type OutputFormat

type OutputFormat interface {
	Caption() string
	JSONFormat() string
	TableFormat() []string
	TableHeaders() []string
}

type Result

type Result struct {
	Verified [][2]dbtable.DBTable

	MissingTables    []MissingTable
	ExtraneousTables []ExtraneousTable
}

func FilterResult

func FilterResult(cfg FilterConfig, r Result) (Result, error)

func (*Result) AllTablesFromSource

func (r *Result) AllTablesFromSource() []dbtable.DBTable

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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