application

package
v1.16.40 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Overview

Package application provides application context and configuration management.

Index

Constants

View Source
const (
	WriteReadReadPerms = 0o644
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Downloader

type Downloader interface {
	Download(url string) ([]byte, error)
	DownloadWithTee(url string, filePath string) ([]byte, error)
	GetLatestReleaseVersion(releaseURL string) (string, error)
	GetLatestPreReleaseVersion(releaseURL string) (string, error)
	GetAllReleasesForRepo(org, repo string) ([]string, error)
}

Downloader is a generic interface for performing highly testable downloads. All methods here involve external http requests. To write tests using these functions, provide a mocked version of this interface to your application object.

func NewDownloader

func NewDownloader() Downloader

type LastActions

type LastActions struct {
	LastSkipCheck time.Time
	LastUpdated   time.Time
}

type Lux

type Lux struct {
	Log luxlog.Logger

	Conf       *config.Config
	Prompt     Prompter
	Lpm        *lpm.Client
	LpmDir     string
	Apm        *lpm.Client // APM is similar to LPM
	ApmDir     func() string
	Downloader Downloader
	Cmd        interface{} // Current command being executed (cobra.Command)
	// contains filtered or unexported fields
}

func New

func New() *Lux

func (*Lux) AddDefaultBlockchainRPCsToSidecar

func (app *Lux) AddDefaultBlockchainRPCsToSidecar(
	blockchainName string,
	network models.Network,
	nodeURIs []string,
) (bool, error)

AddDefaultBlockchainRPCsToSidecar adds default RPC endpoints to sidecar

func (*Lux) BlockchainConfigExists

func (app *Lux) BlockchainConfigExists(blockchainName string) bool

BlockchainConfigExists checks if blockchain config exists This checks for the sidecar.json file which is always created by `blockchain create`

func (*Lux) CaptureYesNo

func (app *Lux) CaptureYesNo(prompt string) (bool, error)

CaptureYesNo delegates to the internal prompt

func (*Lux) ChainConfigExists

func (app *Lux) ChainConfigExists(subnetName string) bool

ChainConfigExists checks if chain config exists

func (*Lux) ClustersConfigExists

func (app *Lux) ClustersConfigExists() bool

ClustersConfigExists checks if clusters config exists

func (*Lux) ConfigFileExists

func (app *Lux) ConfigFileExists() bool

func (*Lux) CopyGenesisFile

func (app *Lux) CopyGenesisFile(inputFilename string, subnetName string) error

func (*Lux) CopyKeyFile

func (app *Lux) CopyKeyFile(inputFilename string, keyName string) error

func (*Lux) CopyVMBinary

func (app *Lux) CopyVMBinary(inputFilename string, subnetName string) error

func (*Lux) CreateElasticChainConfig added in v1.3.8

func (app *Lux) CreateElasticChainConfig(subnetName string, es *models.ElasticChainConfig) error

func (*Lux) CreateSidecar

func (app *Lux) CreateSidecar(sc *models.Sidecar) error

func (*Lux) GenesisExists

func (app *Lux) GenesisExists(subnetName string) bool

func (*Lux) GetAnsibleInventoryDirPath

func (app *Lux) GetAnsibleInventoryDirPath(clusterName string) string

GetAnsibleInventoryDirPath returns the ansible inventory directory path

func (*Lux) GetBaseDir

func (app *Lux) GetBaseDir() string

func (*Lux) GetBasePath

func (app *Lux) GetBasePath() string

GetBasePath returns the base directory path for the CLI

func (*Lux) GetBlockchainNamesOnNetwork

func (app *Lux) GetBlockchainNamesOnNetwork(network models.Network, onlySOV bool) ([]string, error)

GetBlockchainNamesOnNetwork returns blockchain names deployed on a network

func (*Lux) GetChainConfigDir added in v1.16.38

func (app *Lux) GetChainConfigDir() string

GetChainConfigDir returns the chain config directory for luxd's --chain-config-dir This is the same as GetChainsDir - chain configs live alongside chain definitions

func (*Lux) GetChainConfigPath

func (app *Lux) GetChainConfigPath(subnetName string) string

GetChainConfigPath returns the chain config path for a subnet

func (*Lux) GetChainsDir added in v1.3.8

func (app *Lux) GetChainsDir() string

func (*Lux) GetClusterConfig

func (app *Lux) GetClusterConfig(clusterName string) (map[string]interface{}, error)

GetClusterConfig returns cluster configuration

func (*Lux) GetClusterNetwork

func (app *Lux) GetClusterNetwork(clusterName string) (models.Network, error)

GetClusterNetwork returns the network for a given cluster

func (*Lux) GetConfigPath

func (app *Lux) GetConfigPath() string

GetConfigPath returns the SDK config file path (~/.lux/sdk.json) Note: CLI should override this to return ~/.lux/cli.json

func (*Lux) GetCurrentPluginsDir added in v1.3.8

func (app *Lux) GetCurrentPluginsDir() string

GetCurrentPluginsDir returns the directory for active plugin symlinks Plugins are linked at ~/.lux/plugins/current/<vmid> DEPRECATED: Use GetNetworkPluginsDir for network-isolated plugins

func (*Lux) GetCustomVMDir

func (app *Lux) GetCustomVMDir() string

func (*Lux) GetCustomVMPath

func (app *Lux) GetCustomVMPath(subnetName string) string

func (*Lux) GetDevDir added in v1.16.38

func (app *Lux) GetDevDir() string

GetDevDir returns the dev mode data directory (~/.lux/dev/)

func (*Lux) GetDownloader

func (app *Lux) GetDownloader() Downloader

func (*Lux) GetEVMBinDir

func (app *Lux) GetEVMBinDir() string

func (*Lux) GetElasticChainConfigPath added in v1.3.8

func (app *Lux) GetElasticChainConfigPath(subnetName string) string

func (*Lux) GetGenesisPath

func (app *Lux) GetGenesisPath(subnetName string) string

func (*Lux) GetKey

func (app *Lux) GetKey(keyName string) (string, error)

GetKey returns the key for a given name

func (*Lux) GetKeyDir

func (app *Lux) GetKeyDir() string

func (*Lux) GetKeyPath

func (app *Lux) GetKeyPath(keyName string) string

func (*Lux) GetLPMBaseDir

func (app *Lux) GetLPMBaseDir() string

func (*Lux) GetLPMLog

func (app *Lux) GetLPMLog() string

func (*Lux) GetLPMPluginDir

func (app *Lux) GetLPMPluginDir() string

func (*Lux) GetLPMVMPath

func (app *Lux) GetLPMVMPath(vmid string) string

func (*Lux) GetLocalClusterDir

func (app *Lux) GetLocalClusterDir(clusterName string) string

GetLocalClusterDir returns the directory for a specific local cluster

func (*Lux) GetLocalClustersDir

func (app *Lux) GetLocalClustersDir() string

GetLocalClustersDir returns the directory for local clusters

func (*Lux) GetLocalRelayerConfigPath

func (app *Lux) GetLocalRelayerConfigPath() string

GetLocalRelayerConfigPath returns the path for local relayer config

func (*Lux) GetLocalRelayerLogPath

func (app *Lux) GetLocalRelayerLogPath(network models.Network) string

GetLocalRelayerLogPath returns the path to the relayer log file

func (*Lux) GetLocalRelayerRunPath

func (app *Lux) GetLocalRelayerRunPath(network models.Network) string

GetLocalRelayerRunPath returns the path to the relayer run file

func (*Lux) GetLocalRelayerStorageDir

func (app *Lux) GetLocalRelayerStorageDir(network models.Network) string

GetLocalRelayerStorageDir returns the path to the relayer storage directory

func (*Lux) GetLogDir

func (app *Lux) GetLogDir() string

GetLogDir returns the log directory path

func (*Lux) GetLuxBinDir

func (app *Lux) GetLuxBinDir() string

func (*Lux) GetLuxCompatibilityURL

func (*Lux) GetLuxCompatibilityURL() string

func (*Lux) GetLuxdNodeConfigPath

func (app *Lux) GetLuxdNodeConfigPath(subnetName string) string

GetLuxdNodeConfigPath returns the node config path for a subnet

func (*Lux) GetLuxdSubnetConfigPath

func (app *Lux) GetLuxdSubnetConfigPath(subnetName string) string

GetLuxdSubnetConfigPath returns the luxd subnet config path for a subnet

func (*Lux) GetLuxgoBinDir

func (app *Lux) GetLuxgoBinDir() string

func (*Lux) GetMonitoringInventoryDir

func (app *Lux) GetMonitoringInventoryDir(clusterName string) string

GetMonitoringInventoryDir returns the monitoring inventory directory path

func (*Lux) GetNetDir added in v1.3.8

func (app *Lux) GetNetDir() string

func (*Lux) GetNetworkFromSidecarNetworkName

func (app *Lux) GetNetworkFromSidecarNetworkName(name string) (models.Network, error)

GetNetworkFromSidecarNetworkName returns the network from sidecar network name

func (*Lux) GetNetworkPluginsDir added in v1.3.8

func (app *Lux) GetNetworkPluginsDir(networkType string) string

GetNetworkPluginsDir returns the network-specific plugin directory Each network (mainnet, testnet, devnet, custom) has isolated plugins to prevent interference between different networks. Returns ~/.lux/plugins/{mainnet,testnet,devnet,custom}/

func (*Lux) GetNodesDir

func (app *Lux) GetNodesDir() string

GetNodesDir returns the nodes directory path

func (*Lux) GetPerNodeBlockchainConfig

func (app *Lux) GetPerNodeBlockchainConfig(subnetName string) map[string]interface{}

GetPerNodeBlockchainConfig returns per-node blockchain config

func (*Lux) GetPluginsDir

func (app *Lux) GetPluginsDir() string

func (*Lux) GetReposDir

func (app *Lux) GetReposDir() string

func (*Lux) GetRunDir

func (app *Lux) GetRunDir() string

func (*Lux) GetRunFile

func (app *Lux) GetRunFile() string

func (*Lux) GetSidecarNames

func (app *Lux) GetSidecarNames() ([]string, error)

func (*Lux) GetSidecarPath

func (app *Lux) GetSidecarPath(subnetName string) string

func (*Lux) GetSnapshotPath

func (app *Lux) GetSnapshotPath(snapshotName string) string

GetSnapshotPath returns the path to a snapshot

func (*Lux) GetSnapshotsDir

func (app *Lux) GetSnapshotsDir() string

func (*Lux) GetSubnetDir

func (app *Lux) GetSubnetDir() string

GetSubnetDir is deprecated, use GetChainsDir instead

func (*Lux) GetTmpPluginDir

func (*Lux) GetTmpPluginDir() string

func (*Lux) GetTokenName

func (app *Lux) GetTokenName(subnetName string) string

func (*Lux) GetUpgradeBytesFilePath

func (app *Lux) GetUpgradeBytesFilePath(subnetName string) string

func (*Lux) GetUpgradeBytesFilepath

func (app *Lux) GetUpgradeBytesFilepath(subnetName string) string

func (*Lux) GetVersion

func (app *Lux) GetVersion() string

func (*Lux) IsLocalNetworkRunning

func (app *Lux) IsLocalNetworkRunning() bool

func (*Lux) IsPathProtected added in v1.16.38

func (app *Lux) IsPathProtected(path string) bool

IsPathProtected checks if a path is protected or would delete a protected directory

func (*Lux) KeyExists

func (app *Lux) KeyExists(keyName string) bool

func (*Lux) ListClusterNames

func (app *Lux) ListClusterNames() ([]string, error)

ListClusterNames returns a list of cluster names

func (*Lux) LoadClusterNodeConfig

func (app *Lux) LoadClusterNodeConfig(clusterName string, nodeID string) (map[string]interface{}, error)

LoadClusterNodeConfig loads node configuration for a cluster

func (*Lux) LoadClustersConfig

func (app *Lux) LoadClustersConfig() (map[string]interface{}, error)

LoadClustersConfig loads the clusters configuration

func (*Lux) LoadConfig

func (app *Lux) LoadConfig() (types.Config, error)

func (*Lux) LoadElasticChainConfig added in v1.3.8

func (app *Lux) LoadElasticChainConfig(subnetName string) (models.ElasticChainConfig, error)

func (*Lux) LoadEvmGenesis

func (app *Lux) LoadEvmGenesis(subnetName string) (core.Genesis, error)

func (*Lux) LoadRawChainConfig

func (app *Lux) LoadRawChainConfig(subnetName string) ([]byte, error)

LoadRawChainConfig loads raw chain config

func (*Lux) LoadRawGenesis

func (app *Lux) LoadRawGenesis(subnetName string) ([]byte, error)

func (*Lux) LoadRawLuxdSubnetConfig

func (app *Lux) LoadRawLuxdSubnetConfig(subnetName string) ([]byte, error)

LoadRawLuxdSubnetConfig loads raw subnet config

func (*Lux) LoadRawNetworkUpgrades

func (app *Lux) LoadRawNetworkUpgrades(subnetName string) ([]byte, error)

LoadRawNetworkUpgrades loads raw network upgrades

func (*Lux) LoadSidecar

func (app *Lux) LoadSidecar(subnetName string) (models.Sidecar, error)

func (*Lux) LuxdNodeConfigExists

func (app *Lux) LuxdNodeConfigExists(subnetName string) bool

LuxdNodeConfigExists checks if luxd node config exists

func (*Lux) LuxdSubnetConfigExists

func (app *Lux) LuxdSubnetConfigExists(subnetName string) bool

LuxdSubnetConfigExists checks if subnet config exists

func (*Lux) NetworkUpgradeExists

func (app *Lux) NetworkUpgradeExists(subnetName string) bool

NetworkUpgradeExists checks if network upgrade file exists

func (*Lux) ProtectedDirectories added in v1.16.38

func (app *Lux) ProtectedDirectories() []string

ProtectedDirectories returns the list of directories that should NEVER be deleted These contain user-created chain configurations that are NOT ephemeral

func (*Lux) ReadLastActionsFile

func (app *Lux) ReadLastActionsFile() (*LastActions, error)

func (*Lux) ReadLockUpgradeFile

func (app *Lux) ReadLockUpgradeFile(subnetName string) ([]byte, error)

func (*Lux) ReadUpgradeFile

func (app *Lux) ReadUpgradeFile(subnetName string) ([]byte, error)

func (*Lux) ResetPluginsDir

func (app *Lux) ResetPluginsDir() error

ResetPluginsDir resets the plugins directory and creates the current/ subdirectory

func (*Lux) SafeRemoveAll added in v1.16.38

func (app *Lux) SafeRemoveAll(path string) error

SafeRemoveAll wraps os.RemoveAll with safety checks to prevent accidental deletion of protected directories. Returns an error if the path would delete a protected directory.

func (*Lux) Setup

func (app *Lux) Setup(baseDir string, log luxlog.Logger, conf *config.Config, prompt Prompter, downloader Downloader)

func (*Lux) SidecarExists

func (app *Lux) SidecarExists(subnetName string) bool

func (*Lux) SubnetConfigExists

func (app *Lux) SubnetConfigExists(subnetName string) bool

func (*Lux) UpdateSidecar

func (app *Lux) UpdateSidecar(sc *models.Sidecar) error

func (*Lux) UpdateSidecarElasticChain added in v1.3.8

func (app *Lux) UpdateSidecarElasticChain(
	sc *models.Sidecar,
	network models.Network,
	subnetID ids.ID,
	assetID ids.ID,
	pchainTXID ids.ID,
	tokenName string,
	tokenSymbol string,
) error

func (*Lux) UpdateSidecarElasticChainPartialTx added in v1.3.8

func (app *Lux) UpdateSidecarElasticChainPartialTx(
	sc *models.Sidecar,
	network models.Network,
	txName string,
	txID ids.ID,
) error

func (*Lux) UpdateSidecarNetworks

func (app *Lux) UpdateSidecarNetworks(
	sc *models.Sidecar,
	network models.Network,
	subnetID ids.ID,
	blockchainID ids.ID,
) error

func (*Lux) UpdateSidecarPermissionlessValidator

func (app *Lux) UpdateSidecarPermissionlessValidator(
	sc *models.Sidecar,
	network models.Network,
	nodeID string,
	txID ids.ID,
) error

func (*Lux) WriteConfigFile

func (app *Lux) WriteConfigFile(data []byte) error

func (*Lux) WriteGenesisFile

func (app *Lux) WriteGenesisFile(subnetName string, genesisBytes []byte) error

func (*Lux) WriteLastActionsFile

func (app *Lux) WriteLastActionsFile(acts *LastActions)

func (*Lux) WriteLockUpgradeFile

func (app *Lux) WriteLockUpgradeFile(subnetName string, bytes []byte) error

func (*Lux) WriteSidecarFile

func (app *Lux) WriteSidecarFile(sc *models.Sidecar) error

func (*Lux) WriteUpgradeFile

func (app *Lux) WriteUpgradeFile(subnetName string, bytes []byte) error

type Prompter added in v0.2.1

type Prompter = prompts.Prompter

Prompter is an alias for the prompts.Prompter interface

Jump to

Keyboard shortcuts

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