backend

package
v0.0.0-...-240c781 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SYNC_POLICY_NEVER   = "never"
	SYNC_POLICY_ALWAYS  = "always"
	SYNC_POLICY_HOURLY  = "hourly"
	SYNC_POLICY_DAILY   = "daily"
	SYNC_POLICY_WEEKLY  = "weekly"
	SYNC_POLICY_MONTHLY = "monthly"
)
View Source
const DEFAULT_REPO_ID = "default"
View Source
const DEFAULT_REPO_INDEX = 1
View Source
const DROPIN_REPO_ID = "dropin"
View Source
const DROPIN_REPO_INDEX = 0
View Source
const RENAME_FILE_NAME = "rename.json"

Variables

View Source
var RESERVED_CMD_SEARCH_KEY map[string]bool = map[string]bool{
	"#login":      true,
	"#package":    true,
	"#remote":     true,
	"#update":     true,
	"#rename":     true,
	"#config":     true,
	"#version":    true,
	"#help":       true,
	"#completion": true,
}

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// Load all managed repositories
	Reload() error
	// Find a command with its group name and command name.
	// For the root level executable command, the group is empty string.
	// For the group command, the name is empty
	//
	// The group and cmd could be an alias defined by the RenameCommand
	// function. In this case, the FindCommand function is able to return
	// the original command
	// It maps the (group, name) to (registry/repository, package, group, name)
	FindCommand(group string, name string) (command.Command, error)

	FindCommandByFullName(fullName string) (command.Command, error)

	// Get all group commands
	GroupCommands() []command.Command

	// Get all executable commands
	ExecutableCommands() []command.Command

	// Get system command by name
	SystemCommand(name string) command.Command

	// Rename a command with a new name
	RenameCommand(cmd command.Command, new_name string) error

	// Get all renamed commands
	AllRenamedCommands() map[string]string

	// Find a system command by its name
	FindSystemCommand(name string) (command.Command, error)

	// Get all packages sources managed by this backend
	AllPackageSources() []*PackageSource

	// get extra package sources without counting the default and dropin
	ExtraPackageSources() []*PackageSource

	// Return all repositories or an empty slice
	AllRepositories() []repository.PackageRepository

	// Return default local repository
	DefaultRepository() repository.PackageRepository

	// Return dropin local repsository
	DropinRepository() repository.PackageRepository

	// Print out the command resolution details
	Debug()
}

func NewDefaultBackend

func NewDefaultBackend(homeDir string, dropinSource *PackageSource, defaultSource *PackageSource, additionalSources ...*PackageSource) (Backend, error)

Create a new default backend with multiple local repository directories When any of these repositories failed to load, an error is returned.

type DefaultBackend

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

DefaultBackend supports multiple managed repositories and 1 dropin repository It contains: - 1 dropin local repository - index 0 - 1 default managed repository - index 1 - n additional managed repository - index 2 ..

func (DefaultBackend) AllPackageSources

func (backend DefaultBackend) AllPackageSources() []*PackageSource

func (*DefaultBackend) AllRenamedCommands

func (backend *DefaultBackend) AllRenamedCommands() map[string]string

func (DefaultBackend) AllRepositories

func (backend DefaultBackend) AllRepositories() []repository.PackageRepository

func (DefaultBackend) Debug

func (backend DefaultBackend) Debug()

func (DefaultBackend) DefaultRepository

func (backend DefaultBackend) DefaultRepository() repository.PackageRepository

func (DefaultBackend) DropinRepository

func (backend DefaultBackend) DropinRepository() repository.PackageRepository

func (DefaultBackend) ExecutableCommands

func (backend DefaultBackend) ExecutableCommands() []command.Command

func (DefaultBackend) ExtraPackageSources

func (backend DefaultBackend) ExtraPackageSources() []*PackageSource

func (*DefaultBackend) FindCommand

func (backend *DefaultBackend) FindCommand(group string, name string) (command.Command, error)

func (DefaultBackend) FindCommandByFullName

func (backend DefaultBackend) FindCommandByFullName(fullName string) (command.Command, error)

func (*DefaultBackend) FindSystemCommand

func (backend *DefaultBackend) FindSystemCommand(name string) (command.Command, error)

func (DefaultBackend) GroupCommands

func (backend DefaultBackend) GroupCommands() []command.Command

func (*DefaultBackend) Reload

func (backend *DefaultBackend) Reload() error

func (*DefaultBackend) RenameCommand

func (backend *DefaultBackend) RenameCommand(cmd command.Command, new_name string) error

func (DefaultBackend) SystemCommand

func (backend DefaultBackend) SystemCommand(name string) command.Command

type PackageSource

type PackageSource struct {
	Name              string
	RepoDir           string
	RemoteBaseURL     string
	RemoteRegistryURL string
	SyncPolicy        string
	IsManaged         bool

	Repo    repository.PackageRepository
	Failure error

	Updater *updater.CmdUpdater
}

func NewDropinSource

func NewDropinSource(repoDir string) *PackageSource

func NewManagedSource

func NewManagedSource(name, repoDir, remoteBaseURL string, syncPolicy string) *PackageSource

func (*PackageSource) InitUpdater

func (src *PackageSource) InitUpdater(user *user.User, timeout time.Duration, enableCI bool, lockFile string, verifyChecksum bool, verifySignature bool) *updater.CmdUpdater

func (*PackageSource) InitialInstallCommands

func (src *PackageSource) InitialInstallCommands(user *user.User, enableCI bool, lockFilePath string, verifyChecksum bool, verifySignature bool) error

func (PackageSource) IsInstalled

func (src PackageSource) IsInstalled() bool

Jump to

Keyboard shortcuts

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