config

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module("config", fx.Provide(

	func() (*Config, error) {

		if _, err := os.Stat("housekeeper.yaml"); os.IsNotExist(err) {

			return nil, nil
		}

		return LoadConfigFile("housekeeper.yaml")
	},
))

Functions

This section is empty.

Types

type ClickHouse

type ClickHouse struct {
	// Version specifies the target ClickHouse version for schema compatibility
	// This helps ensure generated DDL is compatible with the specified version
	Version string `yaml:"version,omitempty"`

	// ConfigDir specifies the directory where ClickHouse configuration files are stored
	// This directory is used for managing ClickHouse server configuration fragments
	ConfigDir string `yaml:"config_dir,omitempty"`

	// Cluster specifies the default cluster name for distributed ClickHouse deployments
	// This is used for ON CLUSTER operations and distributed DDL statements
	Cluster string `yaml:"cluster,omitempty"`

	// IgnoreDatabases specifies a list of database names to exclude from schema operations
	// These databases will be ignored during dump and diff operations
	IgnoreDatabases []string `yaml:"ignore_databases,omitempty"`
}

ClickHouse represents ClickHouse-specific configuration settings.

This struct contains configuration values that are specific to the ClickHouse database system, including version compatibility and configuration file management.

type Config

type Config struct {
	// ClickHouse contains ClickHouse-specific configuration settings
	ClickHouse ClickHouse `yaml:"clickhouse"`

	// Entrypoint specifies the main SQL file that serves as the entry point for the schema
	Entrypoint string `yaml:"entrypoint"`

	// Dir specifies the directory where migration files are stored
	Dir string `yaml:"dir"`
}

Config represents the project configuration for ClickHouse schema management.

func LoadConfig

func LoadConfig(r io.Reader) (*Config, error)

LoadConfig parses a schema configuration from the provided io.Reader.

The function expects YAML-formatted configuration data that defines the project schema entry point and migration directory. It uses a streaming YAML decoder to handle configuration files efficiently. If no ClickHouse version is specified, it defaults to DefaultClickHouseVersion.

Parameters:

  • r: An io.Reader containing YAML configuration data

Returns:

  • *Config: Successfully parsed configuration
  • error: Any parsing or validation errors encountered

Example:

import (
	"strings"
	"github.com/pseudomuto/housekeeper/pkg/config"
)

yamlData := `
entrypoint: db/main.sql
dir: db/migrations
`

cfg, err := config.LoadConfig(strings.NewReader(yamlData))
if err != nil {
	panic(err)
}

fmt.Printf("Schema entrypoint: %s\n", cfg.Entrypoint)

func LoadConfigFile

func LoadConfigFile(path string) (*Config, error)

LoadConfigFile loads a project configuration from the specified file path. This is a convenience function that opens the file and calls LoadConfig.

Example:

cfg, err := config.LoadConfigFile("housekeeper.yaml")
if err != nil {
	log.Fatal("Failed to load config:", err)
}

fmt.Printf("Entrypoint: %s, Migration dir: %s\n", cfg.Entrypoint, cfg.Dir)

Jump to

Keyboard shortcuts

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