utils

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SSLModeRequire    = "require"
	SSLModeDisable    = "disable"
	SSLModeVerifyCA   = "verify-ca"
	SSLModeVerifyFull = "verify-full"

	Unknown = ""
)

Variables

This section is empty.

Functions

func Absolute

func Absolute[T int | int8 | int16 | int32 | int64 | float32 | float64](value T) T

func AddConstantToInterface

func AddConstantToInterface(val interface{}, increment int) (interface{}, error)

func ArrayContains

func ArrayContains[T any](set []T, match func(elem T) bool) (int, bool)

func CheckIfFilesExists

func CheckIfFilesExists(files ...string) error

func ComputeConfigHash added in v0.1.2

func ComputeConfigHash(srcPath, destPath string) string

func Concurrent

func Concurrent[T any](ctx context.Context, array []T, concurrency int, execute func(ctx context.Context, one T, executionNumber int) error) error

func ConcurrentC

func ConcurrentC[T any](ctx context.Context, next *Next[T], concurrency int, execute func(ctx context.Context, one T, sequence int64) error) error

func ConcurrentF

func ConcurrentF(ctx context.Context, functions ...CtxFunc) error

func ConcurrentInGroup

func ConcurrentInGroup[T any](group *CxGroup, array []T, execute func(ctx context.Context, one T) error)

func ConnWithCustomDeadlineSupport added in v0.3.5

func ConnWithCustomDeadlineSupport(conn net.Conn) (net.Conn, error)

The crypto/ssh package does not support deadline methods.

  • Required for: mongodb and oracle drivers, which internally set default deadlines or call these methods unconditionally.
  • Not Required for: mysql driver (only calls SetDeadline if a timeout is explicitly configured) or postgres driver (uses context for timeouts).

func ConvertToString

func ConvertToString(value interface{}) string

func Decrypt added in v0.1.3

func Decrypt(encryptedText string) (string, error)

func DetermineSystemMemoryGB

func DetermineSystemMemoryGB() int64

DetermineSystemMemoryGB returns the total system memory in GB. Returns -1 if unable to determine memory.

func ErrExec

func ErrExec(functions ...func() error) error

func ErrExecFormat

func ErrExecFormat(format string, function func() error) func() error

func ErrExecSequential

func ErrExecSequential(functions ...func() error) error

func ExecCommand added in v0.1.7

func ExecCommand(
	ctx context.Context,
	c testcontainers.Container,
	cmd string,
) (int, []byte, error)

Helper function to execute container commands

func ExistInArray

func ExistInArray[T ~string | int | int8 | int16 | int32 | int64 | float32 | float64](set []T, value T) bool

func ExtractColumnName added in v0.3.5

func ExtractColumnName(groups ...string) string

ExtractColumnName extracts a column name from regex capture groups. It returns the first non-empty group from the provided groups. This is used when parsing filter expressions where column names can be:

  • Quoted (for special characters): "user-name", "email@domain", "column.with.dots"
  • Unquoted (for normal identifiers): age, status, count

Example usage:

// For filter: \"user-name\" = \"John\"
// matches[1] = "user-name" (quoted column), matches[2] = "" (unquoted column)
columnName := ExtractColumnName(matches[1], matches[2]) // Returns: "user-name"

// For filter: age > 18
// matches[1] = "" (quoted column), matches[2] = "age" (unquoted column)
columnName := ExtractColumnName(matches[1], matches[2]) // Returns: "age"

func ForEach

func ForEach[T any](set []T, action func(elem T) error) error

func GenerateDestinationDetails added in v0.2.0

func GenerateDestinationDetails(namespace, name string, sourceDatabase *string) (string, string)

GenerateDestinationDetails creates the default Iceberg database and table names. It combines prefix, source database, and namespace into a proper DB name.

func GetHash

func GetHash(m map[string]interface{}) string

GetHash returns GetKeysHash result with keys from m

func GetKeysHash

func GetKeysHash(m map[string]interface{}, keys ...string) string

GetKeysHash returns md5 hashsum of concatenated map values (sort keys before)

func IsInstance

func IsInstance(val any, typ reflect.Kind) bool

func IsJSON

func IsJSON(str string) bool

func IsLetterOrNumber added in v0.2.0

func IsLetterOrNumber(symbol int32) bool

IsLetterOrNumber returns true if input symbol is:

A - Z: 65-90
a - z: 97-122

func IsOfType

func IsOfType(object any, decidingKey string) (bool, error)

func IsSubset

func IsSubset[T comparable](setArray, subsetArray []T) bool

func IsValidSubcommand

func IsValidSubcommand(available []*cobra.Command, sub string) bool

IsValidSubcommand checks if the passed subcommand is supported by the parent command

func MaxDate

func MaxDate(v1, v2 time.Time) time.Time

func NormalizedEqual added in v0.1.7

func NormalizedEqual(strune1, strune2 string) bool

func ParsePrivateKey added in v0.2.2

func ParsePrivateKey(pemText, passphrase string) (ssh.Signer, error)

ParsePrivateKey parses a private key from a PEM string

func Reformat added in v0.2.0

func Reformat(key string) string

Reformat makes all keys to lower case and replaces all special symbols with '_'

func SizeOf

func SizeOf(v any) int

Of returns the size of 'v' in bytes. If there is an error during calculation, Of returns -1.

func SplitAndTrim added in v0.3.0

func SplitAndTrim(s string) []string

splitAndTrim splits a comma-separated string and trims whitespace

func StreamIdentifier

func StreamIdentifier(name, namespace string) string

func Ternary

func Ternary(cond bool, a, b any) any

returns cond ? a ; b (note: it is not function ternary)

func TimestampedFileName

func TimestampedFileName(extension string) string

Returns a timestamped

func ULID

func ULID() string

func Unmarshal

func Unmarshal(from, object any) error

Unmarshal serializes and deserializes any from into the object return error if occurred

func UnmarshalFile

func UnmarshalFile(file string, dest any, credsFile bool) error

func Validate

func Validate[T any](structure T) error

Types

type CtxFunc

type CtxFunc = func(ctx context.Context) error

type CxGroup

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

func NewCGroup

func NewCGroup(ctx context.Context) *CxGroup

func NewCGroupWithLimit

func NewCGroupWithLimit(ctx context.Context, limit int) *CxGroup

func (*CxGroup) Add

func (g *CxGroup) Add(execute func(ctx context.Context) error)

func (*CxGroup) Block

func (g *CxGroup) Block() error

func (*CxGroup) Ctx

func (g *CxGroup) Ctx() context.Context

type Next

type Next[T any] struct {
	// contains filtered or unexported fields
}

func Yield

func Yield[T any](next func(prev T) (bool, T, error)) *Next[T]

func (*Next[T]) Close

func (n *Next[T]) Close()

func (*Next[T]) Next

func (n *Next[T]) Next() bool

type NoDeadlineConn added in v0.3.5

type NoDeadlineConn struct {
	net.Conn
}

NoDeadlineConn wraps a net.Conn to suppress "deadline not supported" errors from the crypto/ssh package.

func (*NoDeadlineConn) SetDeadline added in v0.3.5

func (c *NoDeadlineConn) SetDeadline(_ time.Time) error

func (*NoDeadlineConn) SetReadDeadline added in v0.3.5

func (c *NoDeadlineConn) SetReadDeadline(_ time.Time) error

func (*NoDeadlineConn) SetWriteDeadline added in v0.3.5

func (c *NoDeadlineConn) SetWriteDeadline(_ time.Time) error

type SSHConfig added in v0.2.2

type SSHConfig struct {
	Host       string `json:"host,omitempty"`
	Port       int    `json:"port,omitempty"`
	Username   string `json:"username,omitempty"`
	PrivateKey string `json:"private_key,omitempty"`
	Passphrase string `json:"passphrase,omitempty"`
	Password   string `json:"password,omitempty"`
}

func (*SSHConfig) SetupSSHConnection added in v0.2.2

func (c *SSHConfig) SetupSSHConnection() (*ssh.Client, error)

func (*SSHConfig) Validate added in v0.2.2

func (c *SSHConfig) Validate() error

type SSLConfig

type SSLConfig struct {
	Mode       string `mapstructure:"mode,omitempty" json:"mode,omitempty" yaml:"mode,omitempty"`
	ServerCA   string `mapstructure:"server_ca,omitempty" json:"server_ca,omitempty" yaml:"server_ca,omitempty"`
	ClientCert string `mapstructure:"client_cert,omitempty" json:"client_cert,omitempty" yaml:"client_cert,omitempty"`
	ClientKey  string `mapstructure:"client_key,omitempty" json:"client_key,omitempty" yaml:"client_key,omitempty"`
}

SSLConfig is a dto for deserialized SSL configuration for Postgres

func (*SSLConfig) Validate

func (sc *SSLConfig) Validate() error

Validate returns err if the ssl configuration is invalid

Directories

Path Synopsis
uischema is used to serve the UI specifications of the jsonschema of all the drivers and destinations
uischema is used to serve the UI specifications of the jsonschema of all the drivers and destinations

Jump to

Keyboard shortcuts

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