filemanager

package
v1.203.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUpdateFailed indicates that updating file managers failed.
	ErrUpdateFailed = errors.New("update failed")

	// ErrVerificationFailed indicates that verification of file managers failed.
	ErrVerificationFailed = errors.New("verification failed")
)

Sentinel errors for file manager operations.

Functions

This section is empty.

Types

type AddConfig

type AddConfig struct {
	AsDefault bool
	Platform  string
	Checksum  string
	URL       string
	Size      int64
}

AddConfig holds configuration for adding tools.

type AddOption

type AddOption func(*AddConfig)

AddOption configures tool addition behavior.

func WithAsDefault

func WithAsDefault() AddOption

WithAsDefault adds the tool as the default version.

func WithChecksum

func WithChecksum(checksum string) AddOption

WithChecksum adds checksum for lock file.

func WithPlatform

func WithPlatform(platform string) AddOption

WithPlatform specifies the platform for multi-platform lock files.

func WithSize

func WithSize(size int64) AddOption

WithSize adds file size for lock file.

func WithURL

func WithURL(url string) AddOption

WithURL adds download URL for lock file.

type FileManager

type FileManager interface {
	// Enabled returns true if this file manager is enabled by configuration.
	Enabled() bool

	// AddTool adds or updates a tool version.
	AddTool(ctx context.Context, tool, version string, opts ...AddOption) error

	// RemoveTool removes a tool version.
	RemoveTool(ctx context.Context, tool, version string) error

	// SetDefault sets a tool version as default.
	SetDefault(ctx context.Context, tool, version string) error

	// GetTools returns all tools managed by this file.
	GetTools(ctx context.Context) (map[string][]string, error)

	// Verify verifies the integrity of the managed file.
	Verify(ctx context.Context) error

	// Name returns the manager name for logging.
	Name() string
}

FileManager manages a specific toolchain file type.

type LockFileManager

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

LockFileManager manages toolchain.lock.yaml file.

func NewLockFileManager

func NewLockFileManager(config *schema.AtmosConfiguration) *LockFileManager

NewLockFileManager creates a new lock file manager.

func (*LockFileManager) AddTool

func (m *LockFileManager) AddTool(ctx context.Context, tool, version string, opts ...AddOption) error

AddTool adds or updates a tool version in the lock file with optional platform-specific metadata. Creates a new lock file if one doesn't exist. Platform metadata can be specified via AddOption parameters.

func (*LockFileManager) Enabled

func (m *LockFileManager) Enabled() bool

Enabled returns true if this file manager is enabled by configuration.

func (*LockFileManager) GetTools

func (m *LockFileManager) GetTools(ctx context.Context) (map[string][]string, error)

GetTools returns all tools managed by the lock file as a map of tool names to version slices. Each tool maps to a single version (represented as a one-element slice).

func (*LockFileManager) Name

func (m *LockFileManager) Name() string

Name returns the manager name for logging.

func (*LockFileManager) RemoveTool

func (m *LockFileManager) RemoveTool(ctx context.Context, tool, version string) error

RemoveTool removes a tool version.

func (*LockFileManager) SetDefault

func (m *LockFileManager) SetDefault(ctx context.Context, tool, version string) error

SetDefault sets a tool version as default.

func (*LockFileManager) Verify

func (m *LockFileManager) Verify(ctx context.Context) error

Verify verifies the integrity of the managed file.

type Registry

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

Registry coordinates updates across multiple file managers.

func NewRegistry

func NewRegistry(managers ...FileManager) *Registry

NewRegistry creates a new file manager registry.

func (*Registry) AddTool

func (r *Registry) AddTool(ctx context.Context, tool, version string, opts ...AddOption) error

AddTool adds a tool to all enabled managers.

func (*Registry) RemoveTool

func (r *Registry) RemoveTool(ctx context.Context, tool, version string) error

RemoveTool removes a tool from all enabled managers.

func (*Registry) SetDefault

func (r *Registry) SetDefault(ctx context.Context, tool, version string) error

SetDefault sets a tool version as default in all enabled managers.

func (*Registry) VerifyAll

func (r *Registry) VerifyAll(ctx context.Context) error

VerifyAll verifies all enabled managers.

type ToolVersionsFileManager

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

ToolVersionsFileManager manages .tool-versions file.

func NewToolVersionsFileManager

func NewToolVersionsFileManager(config *schema.AtmosConfiguration) *ToolVersionsFileManager

NewToolVersionsFileManager creates a new .tool-versions manager.

func (*ToolVersionsFileManager) AddTool

func (m *ToolVersionsFileManager) AddTool(ctx context.Context, tool, version string, opts ...AddOption) error

AddTool adds or updates a tool version.

func (*ToolVersionsFileManager) Enabled

func (m *ToolVersionsFileManager) Enabled() bool

Enabled returns true if this file manager is enabled by configuration.

func (*ToolVersionsFileManager) GetTools

func (m *ToolVersionsFileManager) GetTools(ctx context.Context) (map[string][]string, error)

GetTools returns all tools managed by this file.

func (*ToolVersionsFileManager) Name

func (m *ToolVersionsFileManager) Name() string

Name returns the manager name for logging.

func (*ToolVersionsFileManager) RemoveTool

func (m *ToolVersionsFileManager) RemoveTool(ctx context.Context, tool, version string) error

RemoveTool removes a tool version.

func (*ToolVersionsFileManager) SetDefault

func (m *ToolVersionsFileManager) SetDefault(ctx context.Context, tool, version string) error

SetDefault sets a tool version as default.

func (*ToolVersionsFileManager) Verify

Verify verifies the integrity of the managed file.

Jump to

Keyboard shortcuts

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