upgrade

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	LatestWorkspaceSchemaVersion = 3
)

Variables

View Source
var ErrUpgradeLocked = errors.New("workspace upgrade is already running")

Functions

func AcquireFileLock

func AcquireFileLock(path string, appVersion string) (func() error, error)

func ClearJournal

func ClearJournal(path string) error

func CreateBackup

func CreateBackup(ctx context.Context, uc *Context, backupID string) (string, error)

func SaveJournal

func SaveJournal(path string, journal Journal) error

func SaveMeta

func SaveMeta(path string, meta Meta) error

func UpgradeIfNeeded

func UpgradeIfNeeded(ctx context.Context, resolved *appconfig.Resolved, appVersion string) error

Types

type Context

type Context struct {
	Resolved    *appconfig.Resolved
	Paths       Paths
	AppVersion  string
	Inspection  *Inspection
	BackupDir   string
	CurrentMeta *Meta
	Warnings    []string
}

func NewContext

func NewContext(resolved *appconfig.Resolved, appVersion string) *Context

type Detection

type Detection struct {
	CurrentVersion             int    `json:"current_version"`
	LatestVersion              int    `json:"latest_version"`
	CurrentVersionSource       string `json:"current_version_source"`
	Empty                      bool   `json:"empty"`
	HasWorkspace               bool   `json:"has_workspace"`
	HasLegacy                  bool   `json:"has_legacy"`
	ConfigExists               bool   `json:"config_exists"`
	LegacyConfigExists         bool   `json:"legacy_config_exists"`
	ConfigSchemaVersion        int    `json:"config_schema_version"`
	ConfigError                string `json:"config_error,omitempty"`
	IdentityIndexExists        bool   `json:"identity_index_exists"`
	IdentityIndexSchemaVersion int    `json:"identity_index_schema_version"`
	IdentityIndexError         string `json:"identity_index_error,omitempty"`
	DatabaseExists             bool   `json:"database_exists"`
	DatabaseSchemaVersion      int    `json:"database_schema_version"`
	DatabaseError              string `json:"database_error,omitempty"`
	LegacyIdentityExists       bool   `json:"legacy_identity_exists"`
	LegacyIdentityError        string `json:"legacy_identity_error,omitempty"`
	LegacyDatabaseExists       bool   `json:"legacy_database_exists"`
	LegacyDatabaseError        string `json:"legacy_database_error,omitempty"`
	LegacySettingsExists       bool   `json:"legacy_settings_exists"`
}

func Detect

func Detect(ctx context.Context, resolved *appconfig.Resolved, meta *Meta) Detection

type Inspection

type Inspection struct {
	Paths     Paths     `json:"paths"`
	Meta      *Meta     `json:"meta,omitempty"`
	Journal   *Journal  `json:"journal,omitempty"`
	Detection Detection `json:"detection"`
}

func Inspect

func Inspect(ctx context.Context, resolved *appconfig.Resolved, appVersion string) (*Inspection, error)

type Journal

type Journal struct {
	UpgradeID   string `json:"upgrade_id"`
	FromVersion int    `json:"from_version"`
	ToVersion   int    `json:"to_version"`
	CurrentStep string `json:"current_step"`
	Phase       string `json:"phase"`
	BackupDir   string `json:"backup_dir,omitempty"`
	StartedAt   string `json:"started_at"`
	AppVersion  string `json:"app_version,omitempty"`
}

func LoadJournal

func LoadJournal(path string) (*Journal, error)

type Meta

type Meta struct {
	WorkspaceSchemaVersion int      `json:"workspace_schema_version"`
	AppVersion             string   `json:"app_version,omitempty"`
	UpdatedAt              string   `json:"updated_at"`
	LastUpgradeID          string   `json:"last_upgrade_id,omitempty"`
	LastBackupDir          string   `json:"last_backup_dir,omitempty"`
	Warnings               []string `json:"warnings,omitempty"`
}

func LoadMeta

func LoadMeta(path string) (*Meta, error)

type Migration

type Migration interface {
	From() int
	To() int
	Name() string
	IsDone(ctx context.Context, uc *Context) (bool, error)
	Apply(ctx context.Context, uc *Context) error
	Validate(ctx context.Context, uc *Context) error
}

type Paths

type Paths struct {
	ConfigFile           string `json:"config_file"`
	LegacyConfigFile     string `json:"legacy_config_file"`
	IdentityDir          string `json:"identity_dir"`
	DatabaseFile         string `json:"database_file"`
	LegacyCredentialsDir string `json:"legacy_credentials_dir"`
	LegacyDataDir        string `json:"legacy_data_dir"`
	LegacySettingsPath   string `json:"legacy_settings_path"`
	MetaPath             string `json:"meta_path"`
	JournalPath          string `json:"journal_path"`
	LockPath             string `json:"lock_path"`
	BackupRoot           string `json:"backup_root"`
}

func ResolvePaths

func ResolvePaths(resolved *appconfig.Resolved) Paths

type Upgrader

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

func NewDefaultUpgrader

func NewDefaultUpgrader() *Upgrader

func (*Upgrader) Plan

func (u *Upgrader) Plan(fromVersion, toVersion int) ([]Migration, error)

func (*Upgrader) UpgradeIfNeeded

func (u *Upgrader) UpgradeIfNeeded(ctx context.Context, uc *Context) error

Jump to

Keyboard shortcuts

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