configmigrate

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 6, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package configmigrate used to migrate older configuration versions to the current one.

Index

Constants

View Source
const BackupDateTimeFormat = time.DateOnly + "-15-04-05"

BackupDateTimeFormat is the format for timestamps in the backup directory name.

View Source
const BackupDirNameFormat = "backup-configmigrate-v%d-to-v%d-%s.dir"

BackupDirNameFormat is the format for the backup directory name, which should be filled with the current and target schema versions, and current datetime formatted according to BackupDateTimeFormat.

View Source
const SchemaVersionKey = "schema_version"

SchemaVersionKey is the key for the schema version in the YAML configuration file.

NOTE: Don't change this value.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Clock is the source of current time.
	Clock timeutil.Clock

	// Logger used to log migrator operations.
	Logger *slog.Logger

	// WorkingDir is the absolute path to the working directory of AdGuardDNS
	// Client.
	WorkingDir string

	// ConfigFileName is the name of the configuration file within the working
	// directory.
	ConfigFileName string
}

Config is the configuration for Migrator.

type Migrator

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

Migrator performs the YAML configuration file migrations.

func New

func New(c *Config) (m *Migrator)

New creates a new Migrator.

func (*Migrator) Run

func (m *Migrator) Run(ctx context.Context, target SchemaVersion) (err error)

Run performs necessary upgrade operations to upgrade file to target schema version, if needed.

type SchemaVersion

type SchemaVersion uint

SchemaVersion is the type for the configuration structure revision.

const (
	// VersionInitial is the first version of the configuration structure ever
	// existed.
	VersionInitial SchemaVersion = 1

	// VersionLatest is the current version of the configuration structure.
	VersionLatest SchemaVersion = 3
)

Jump to

Keyboard shortcuts

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