util

package
v0.0.0-...-d56b225 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IgnoreFileName is the default name of the ignore file
	IgnoreFileName = ".pgschemaignore"
)

Variables

This section is empty.

Functions

func Connect

func Connect(config *ConnectionConfig) (*sql.DB, error)

Connect establishes a database connection using the provided configuration

func GetEnvIntWithDefault

func GetEnvIntWithDefault(envVar string, defaultValue int) int

GetEnvIntWithDefault returns the value of an environment variable as int or a default value if not set

func GetEnvWithDefault

func GetEnvWithDefault(envVar, defaultValue string) string

GetEnvWithDefault returns the value of an environment variable or a default value if not set

func GetIRFromDatabase

func GetIRFromDatabase(host string, port int, db, user, password, schemaName, applicationName string, ignoreConfig *ir.IgnoreConfig) (*ir.IR, error)

GetIRFromDatabase gets the IR from a database with ignore configuration

func LoadIgnoreFile

func LoadIgnoreFile() (*ir.IgnoreConfig, error)

LoadIgnoreFile loads the .pgschemaignore file from the current directory Returns nil if the file doesn't exist (ignore functionality is optional)

func LoadIgnoreFileFromPath

func LoadIgnoreFileFromPath(filePath string) (*ir.IgnoreConfig, error)

LoadIgnoreFileFromPath loads an ignore file from the specified path Returns nil if the file doesn't exist (ignore functionality is optional) Uses the structured TOML format internally

func LoadIgnoreFileWithStructure

func LoadIgnoreFileWithStructure() (*ir.IgnoreConfig, error)

LoadIgnoreFileWithStructure loads the .pgschemaignore file using the structured TOML format and converts it to the simple IgnoreConfig structure

func LoadIgnoreFileWithStructureFromPath

func LoadIgnoreFileWithStructureFromPath(filePath string) (*ir.IgnoreConfig, error)

LoadIgnoreFileWithStructureFromPath loads an ignore file using structured format from the specified path

func PreRunEWithEnvVars

func PreRunEWithEnvVars(dbPtr, userPtr *string) func(*cobra.Command, []string) error

PreRunEWithEnvVars creates a PreRunE function that validates required database connection parameters It checks environment variables if the corresponding flags weren't explicitly set

func PreRunEWithEnvVarsAndConnection

func PreRunEWithEnvVarsAndConnection(dbPtr, userPtr *string, hostPtr *string, portPtr *int) func(*cobra.Command, []string) error

PreRunEWithEnvVarsAndConnection creates a PreRunE function that validates database connection parameters It checks environment variables if the corresponding flags weren't explicitly set This version also handles optional host, port, and application name parameters

func PreRunEWithEnvVarsAndConnectionAndApp

func PreRunEWithEnvVarsAndConnectionAndApp(dbPtr, userPtr *string, hostPtr *string, portPtr *int, appNamePtr *string) func(*cobra.Command, []string) error

PreRunEWithEnvVarsAndConnectionAndApp creates a PreRunE function that validates database connection parameters It checks environment variables if the corresponding flags weren't explicitly set This version handles all optional connection parameters including application name

Types

type ConnectionConfig

type ConnectionConfig struct {
	Host            string
	Port            int
	Database        string
	User            string
	Password        string
	SSLMode         string
	ApplicationName string
}

ConnectionConfig holds database connection parameters

type FunctionIgnoreConfig

type FunctionIgnoreConfig struct {
	Patterns []string `toml:"patterns,omitempty"`
}

FunctionIgnoreConfig represents function-specific ignore configuration

type ProcedureIgnoreConfig

type ProcedureIgnoreConfig struct {
	Patterns []string `toml:"patterns,omitempty"`
}

ProcedureIgnoreConfig represents procedure-specific ignore configuration

type SequenceIgnoreConfig

type SequenceIgnoreConfig struct {
	Patterns []string `toml:"patterns,omitempty"`
}

SequenceIgnoreConfig represents sequence-specific ignore configuration

type TableIgnoreConfig

type TableIgnoreConfig struct {
	Patterns []string `toml:"patterns,omitempty"`
}

TableIgnoreConfig represents table-specific ignore configuration

type TomlConfig

type TomlConfig struct {
	Tables     TableIgnoreConfig     `toml:"tables,omitempty"`
	Views      ViewIgnoreConfig      `toml:"views,omitempty"`
	Functions  FunctionIgnoreConfig  `toml:"functions,omitempty"`
	Procedures ProcedureIgnoreConfig `toml:"procedures,omitempty"`
	Types      TypeIgnoreConfig      `toml:"types,omitempty"`
	Sequences  SequenceIgnoreConfig  `toml:"sequences,omitempty"`
}

TomlConfig represents the TOML structure of the .pgschemaignore file This is used for parsing more complex configurations if needed in the future

type TypeIgnoreConfig

type TypeIgnoreConfig struct {
	Patterns []string `toml:"patterns,omitempty"`
}

TypeIgnoreConfig represents type-specific ignore configuration

type ViewIgnoreConfig

type ViewIgnoreConfig struct {
	Patterns []string `toml:"patterns,omitempty"`
}

ViewIgnoreConfig represents view-specific ignore configuration

Jump to

Keyboard shortcuts

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