paths

package
v0.58.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: MIT Imports: 11 Imported by: 12

Documentation

Index

Constants

View Source
const (
	// LongestPathNameLen is the length of the longest path name. It is used
	// for text formatting.
	LongestPathNameLen = 35
)

Variables

View Source
var (
	ErrEmptyResponse = errors.New("empty response")
	ErrEmptyFile     = errors.New("empty file")
)
View Source
var (
	// BlockExplorerConfigHome is the folder containing the configuration files
	// used by the block explorer.
	BlockExplorerConfigHome = ConfigPath("blockexplorer")

	// BlockExplorerDefaultConfigFile is the default configuration file for the
	// block explorer.
	BlockExplorerDefaultConfigFile = JoinConfigPath(BlockExplorerConfigHome, "config.toml")

	// DataNodeConfigHome is the folder containing the configuration files
	// used by the node.
	DataNodeConfigHome = ConfigPath("data-node")

	// DataNodeDefaultConfigFile is the default configuration file for the
	// data-node.
	DataNodeDefaultConfigFile = JoinConfigPath(DataNodeConfigHome, "config.toml")

	// FaucetConfigHome is the folder containing the configuration files
	// used by the node.
	FaucetConfigHome = ConfigPath("faucet")

	// FaucetDefaultConfigFile is the default configuration file for the
	// data-node.
	FaucetDefaultConfigFile = JoinConfigPath(FaucetConfigHome, "config.toml")

	// NodeConfigHome is the folder containing the configuration files used by
	// the node.
	NodeConfigHome = ConfigPath("node")

	// NodeDefaultConfigFile is the default configuration file for the node.
	NodeDefaultConfigFile = JoinConfigPath(NodeConfigHome, "config.toml")

	// NodeWalletsConfigFile is the configuration file for the node wallets.
	NodeWalletsConfigFile = JoinConfigPath(NodeConfigHome, "wallets.encrypted")

	// WalletCLIConfigHome is the folder containing the configuration files
	// used by the wallet CLI.
	WalletCLIConfigHome = ConfigPath("wallet-cli")

	// WalletCLIDefaultConfigFile is the default configuration file for the
	// wallet CLI.
	WalletCLIDefaultConfigFile = JoinConfigPath(WalletCLIConfigHome, "config.toml")

	// WalletAppConfigHome is the folder containing the configuration files
	// used by the wallet app application.
	WalletAppConfigHome = ConfigPath("wallet-app")

	// WalletAppDefaultConfigFile is the default configuration file for the
	// wallet app application.
	WalletAppDefaultConfigFile = JoinConfigPath(WalletAppConfigHome, "config.toml")

	// WalletServiceConfigHome is the folder containing the configuration files
	// used by the wallet service application.
	WalletServiceConfigHome = ConfigPath("wallet-service")

	// WalletServiceNetworksConfigHome is the folder containing the
	// configuration files used by the networks.
	WalletServiceNetworksConfigHome = JoinConfigPath(WalletServiceConfigHome, "networks")

	// WalletServicePermissionsConfigFile is the file containing the permissions that
	// control the access to the wallets.
	WalletServicePermissionsConfigFile = ConfigPath(filepath.Join(WalletServiceConfigHome.String(), "permissions.toml"))
)
View Source
var (
	// NodeDataHome is the folder containing the data used by the node.
	NodeDataHome = DataPath("node")

	// NodeWalletsDataHome is the folder containing the data used by the
	// node wallets.
	NodeWalletsDataHome = DataPath(filepath.Join(NodeDataHome.String(), "wallets"))

	// VegaNodeWalletsDataHome is the folder containing the vega wallet
	// used by the node.
	VegaNodeWalletsDataHome = DataPath(filepath.Join(NodeWalletsDataHome.String(), "vega"))

	// EthereumNodeWalletsDataHome is the folder containing the ethereum wallet
	// used by the node.
	EthereumNodeWalletsDataHome = DataPath(filepath.Join(NodeWalletsDataHome.String(), "ethereum"))

	// FaucetDataHome is the folder containing the data used by the faucet.
	FaucetDataHome = DataPath("faucet")

	// FaucetWalletsDataHome is the folder containing the data used by the
	// faucet wallets.
	FaucetWalletsDataHome = DataPath(filepath.Join(FaucetDataHome.String(), "wallets"))

	// WalletsDataHome is the folder containing the user wallets.
	WalletsDataHome = DataPath("wallets")

	// WalletServiceDataHome is the folder containing the data used by the
	// wallet service.
	WalletServiceDataHome = DataPath("wallet-service")

	// WalletServiceRSAKeysDataHome is the folder containing the RSA keys used by
	// the wallet service.
	WalletServiceRSAKeysDataHome = DataPath(filepath.Join(WalletServiceDataHome.String(), "rsa-keys"))

	// WalletServicePublicRSAKeyDataFile is the file containing the public RSA key
	// used by the wallet service.
	WalletServicePublicRSAKeyDataFile = DataPath(filepath.Join(WalletServiceRSAKeysDataHome.String(), "public.pem"))

	// WalletServicePrivateRSAKeyDataFile is the file containing the private RSA key
	// used by the wallet service.
	WalletServicePrivateRSAKeyDataFile = DataPath(filepath.Join(WalletServiceRSAKeysDataHome.String(), "private.pem"))
)
View Source
var (
	// DataNodeStateHome is the folder containing the state used by the
	// data-node.
	DataNodeStateHome = StatePath("data-node")

	// DataNodeLogsHome is the folder containing the logs of the data-node.
	DataNodeLogsHome = StatePath(filepath.Join(DataNodeStateHome.String(), "logs"))

	// DataNodeStorageHome is the folder containing the data storage of the
	// data-node.
	DataNodeStorageHome = StatePath(filepath.Join(DataNodeStateHome.String(), "storage"))

	// DataNodeSnapshotHome is the folder containing the snapshots of the data-node.
	DataNodeSnapshotHome = StatePath(filepath.Join(DataNodeStateHome.String(), "snapshots"))

	// NodeStateHome is the folder containing the state of the node.
	NodeStateHome = StatePath("node")

	// NodeLogsHome is the folder containing the logs of the node.
	NodeLogsHome = StatePath(filepath.Join(NodeStateHome.String(), "logs"))

	// CheckpointStateHome is the folder containing the checkpoint files
	// of to the node.
	CheckpointStateHome = StatePath(filepath.Join(NodeStateHome.String(), "checkpoints"))

	// SnapshotStateHome is the folder containing the snapshot files
	// of to the node.
	SnapshotStateHome = StatePath(filepath.Join(NodeStateHome.String(), "snapshots"))

	// SnapshotDBStateFile is the DB file for GoLevelDB used in snapshots.
	SnapshotDBStateFile = StatePath(filepath.Join(SnapshotStateHome.String(), "ldb"))

	// WalletCLIStateHome is the folder containing the state of the wallet CLI.
	WalletCLIStateHome = StatePath("wallet-cli")

	// WalletCLILogsHome is the folder containing the logs of the wallet CLI.
	WalletCLILogsHome = StatePath(filepath.Join(WalletCLIStateHome.String(), "logs"))

	// WalletAppStateHome is the folder containing the state of the wallet
	// app.
	WalletAppStateHome = StatePath("wallet-app")

	// WalletAppLogsHome is the folder containing the logs of the wallet
	// app.
	WalletAppLogsHome = StatePath(filepath.Join(WalletAppStateHome.String(), "logs"))

	// WalletServiceStateHome is the folder containing the state of the node.
	WalletServiceStateHome = StatePath("wallet-service")

	// WalletServiceLogsHome is the folder containing the logs of the node.
	WalletServiceLogsHome = StatePath(filepath.Join(WalletServiceStateHome.String(), "logs"))
)
View Source
var DataNodeCacheHome = CachePath("data-node")

DataNodeCacheHome is the folder containing the cache used by the data-node.

View Source
var VegaHome = "vega"

VegaHome is the name of the Vega folder for every type of file structure.

Functions

func CreateCustomCacheDirFor

func CreateCustomCacheDirFor(customHome string, relDirPath CachePath) (string, error)

CreateCustomCacheDirFor builds the path for cache directories at a given root path and creates intermediate directories. It scoped the files under a "data" folder, and follow the default structure.

func CreateCustomCachePathFor

func CreateCustomCachePathFor(customHome string, relFilePath CachePath) (string, error)

CreateCustomCachePathFor builds the path for cache files at a given root path and creates intermediate directories. It scoped the files under a "cache" folder, and follow the default structure.

func CreateCustomConfigDirFor

func CreateCustomConfigDirFor(customHome string, relDirPath ConfigPath) (string, error)

CreateCustomConfigDirFor builds the path for config directories at a given root path and creates intermediate directories. It scoped the files under a "data" folder, and follow the default structure.

func CreateCustomConfigPathFor

func CreateCustomConfigPathFor(customHome string, relFilePath ConfigPath) (string, error)

CreateCustomConfigPathFor builds the path for configuration files at a given root path and creates intermediate directories. It scoped the files under a "config" folder, and follow the default structure.

func CreateCustomDataDirFor

func CreateCustomDataDirFor(customHome string, relDirPath DataPath) (string, error)

CreateCustomDataDirFor builds the path for data directories at a given root path and creates intermediate directories. It scoped the files under a "data" folder, and follow the default structure.

func CreateCustomDataPathFor

func CreateCustomDataPathFor(customHome string, relFilePath DataPath) (string, error)

CreateCustomDataPathFor builds the path for data files at a given root path and creates intermediate directories. It scoped the files under a "data" folder, and follow the default structure.

func CreateCustomStateDirFor

func CreateCustomStateDirFor(customHome string, relDirPath StatePath) (string, error)

CreateCustomStateDirFor builds the path for data directories at a given root path and creates intermediate directories. It scoped the files under a "data" folder, and follow the default structure.

func CreateCustomStatePathFor

func CreateCustomStatePathFor(customHome string, relFilePath StatePath) (string, error)

CreateCustomStatePathFor builds the path for cache files at a given root path and creates intermediate directories. It scoped the files under a "cache" folder, and follow the default structure.

func CreateDefaultCacheDirFor

func CreateDefaultCacheDirFor(relDirPath CachePath) (string, error)

CreateDefaultCacheDirFor builds the default path for a cache directory and creates it, along with intermediate directories, if needed.

func CreateDefaultCachePathFor

func CreateDefaultCachePathFor(relFilePath CachePath) (string, error)

CreateDefaultCachePathFor builds the default path for a cache file and creates intermediate directories, if needed.

func CreateDefaultConfigDirFor

func CreateDefaultConfigDirFor(relDirPath ConfigPath) (string, error)

CreateDefaultConfigDirFor builds the default path for a config directory and creates it, along with intermediate directories, if needed.

func CreateDefaultConfigPathFor

func CreateDefaultConfigPathFor(relFilePath ConfigPath) (string, error)

CreateDefaultConfigPathFor builds the default path for a configuration file and creates intermediate directories, if needed.

func CreateDefaultDataDirFor

func CreateDefaultDataDirFor(relDirPath DataPath) (string, error)

CreateDefaultDataDirFor builds the default path for a data directory and creates it, along with intermediate directories, if needed.

func CreateDefaultDataPathFor

func CreateDefaultDataPathFor(relFilePath DataPath) (string, error)

CreateDefaultDataPathFor builds the default path for a data file and creates intermediate directories, if needed.

func CreateDefaultStateDirFor

func CreateDefaultStateDirFor(relDirPath StatePath) (string, error)

CreateDefaultStateDirFor builds the default path for a state directory and creates it, along with intermediate directories, if needed.

func CreateDefaultStatePathFor

func CreateDefaultStatePathFor(relFilePath StatePath) (string, error)

CreateDefaultStatePathFor builds the default path for a state file and creates intermediate directories, if needed.

func CustomCachePathFor

func CustomCachePathFor(customHome string, relPath CachePath) string

CustomCachePathFor builds the path for a cache file or directories at a given root path. It doesn't create any resources.

func CustomConfigPathFor

func CustomConfigPathFor(customHome string, relPath ConfigPath) string

CustomConfigPathFor builds the path for a config file or directories at a given root path. It doesn't create any resources.

func CustomDataPathFor

func CustomDataPathFor(customHome string, relPath DataPath) string

CustomDataPathFor builds the path for a data file or directories at a given root path. It doesn't create any resources.

func CustomStatePathFor

func CustomStatePathFor(customHome string, relPath StatePath) string

CustomStatePathFor builds the path for a state file or directories at a given root path. It doesn't create any resources.

func DefaultCachePathFor

func DefaultCachePathFor(relPath CachePath) string

DefaultCachePathFor build the default path for a cache file or directory. It doesn't create any resources.

func DefaultConfigPathFor

func DefaultConfigPathFor(relPath ConfigPath) string

DefaultConfigPathFor build the default path for a config file or directory. It doesn't create any resources.

func DefaultDataPathFor

func DefaultDataPathFor(relPath DataPath) string

DefaultDataPathFor build the default path for a data file or directory. It doesn't create any resources.

func DefaultStatePathFor

func DefaultStatePathFor(relPath StatePath) string

DefaultStatePathFor build the default path for a state file or directory. It doesn't create any resources.

func Explain

func Explain(name string) (string, error)

func FetchStructuredFile

func FetchStructuredFile(url string, v interface{}) error

func JoinCachePathStr

func JoinCachePathStr(p CachePath, elem ...string) string

JoinCachePathStr joins any number of path elements with a root CachePath into a single path, separating them with an OS specific Separator, and returns it as a string.

func JoinConfigPathStr

func JoinConfigPathStr(p ConfigPath, elem ...string) string

JoinConfigPathStr joins any number of path elements with a root ConfigPath into a single path, separating them with an OS specific Separator, and returns it as a string.

func JoinDataPathStr

func JoinDataPathStr(p DataPath, elem ...string) string

JoinDataPathStr joins any number of path elements with a root DataPath into a single path, separating them with an OS specific Separator, and returns it as a string.

func JoinStatePathStr

func JoinStatePathStr(p StatePath, elem ...string) string

JoinStatePathStr joins any number of path elements with a root StatePath into a single path, separating them with an OS specific Separator, and returns it as a string.

func ReadEncryptedFile

func ReadEncryptedFile(path string, passphrase string, v interface{}) error

func ReadStructuredFile

func ReadStructuredFile(path string, v interface{}) error

func WriteEncryptedFile

func WriteEncryptedFile(path string, passphrase string, v interface{}) error

func WriteStructuredFile

func WriteStructuredFile(path string, v interface{}) error

Types

type CachePath

type CachePath string

func JoinCachePath

func JoinCachePath(p CachePath, elem ...string) CachePath

JoinCachePath joins any number of path elements with a root CachePath into a single path, separating them with an OS specific Separator, and returns it as a CachePath.

func (CachePath) String

func (p CachePath) String() string

type ConfigPath

type ConfigPath string

func JoinConfigPath

func JoinConfigPath(p ConfigPath, elem ...string) ConfigPath

JoinConfigPath joins any number of path elements with a root ConfigPath into a single path, separating them with an OS specific Separator, and returns it as a ConfigPath.

func (ConfigPath) String

func (p ConfigPath) String() string

type CustomPaths

type CustomPaths struct {
	CustomHome string
}

func (*CustomPaths) CachePathFor

func (p *CustomPaths) CachePathFor(relPath CachePath) string

CachePathFor builds the path for a cache file or directories at the configured home. It doesn't create any resources.

func (*CustomPaths) ConfigPathFor

func (p *CustomPaths) ConfigPathFor(relPath ConfigPath) string

ConfigPathFor builds the path for a config file or directories at the configured home. It doesn't create any resources.

func (*CustomPaths) CreateCacheDirFor

func (p *CustomPaths) CreateCacheDirFor(relDirPath CachePath) (string, error)

CreateCacheDirFor builds the path for cache files at the configured home and creates intermediate directories.

func (*CustomPaths) CreateCachePathFor

func (p *CustomPaths) CreateCachePathFor(relFilePath CachePath) (string, error)

CreateCachePathFor builds the path for cache directories at the configured home and creates intermediate directories.

func (*CustomPaths) CreateConfigDirFor

func (p *CustomPaths) CreateConfigDirFor(relDirPath ConfigPath) (string, error)

CreateConfigDirFor builds the path for configuration files at a given configured home and creates intermediate directories.

func (*CustomPaths) CreateConfigPathFor

func (p *CustomPaths) CreateConfigPathFor(relFilePath ConfigPath) (string, error)

CreateConfigPathFor builds the path for config directories at the configured home and creates intermediate directories.

func (*CustomPaths) CreateDataDirFor

func (p *CustomPaths) CreateDataDirFor(relDirPath DataPath) (string, error)

CreateDataDirFor builds the path for data files at the configured home and creates intermediate directories.

func (*CustomPaths) CreateDataPathFor

func (p *CustomPaths) CreateDataPathFor(relFilePath DataPath) (string, error)

CreateDataPathFor builds the path for data directories at the configured home and creates intermediate directories.

func (*CustomPaths) CreateStateDirFor

func (p *CustomPaths) CreateStateDirFor(relDirPath StatePath) (string, error)

CreateStateDirFor builds the path for cache files at the configured home and creates intermediate directories.

func (*CustomPaths) CreateStatePathFor

func (p *CustomPaths) CreateStatePathFor(relFilePath StatePath) (string, error)

CreateStatePathFor builds the path for data directories at the configured home and creates intermediate directories.

func (*CustomPaths) DataPathFor

func (p *CustomPaths) DataPathFor(relPath DataPath) string

DataPathFor builds the path for a data file or directories at the configured home. It doesn't create any resources.

func (*CustomPaths) StatePathFor

func (p *CustomPaths) StatePathFor(relPath StatePath) string

StatePathFor builds the path for a state file or directories at the configured home. It doesn't create any resources.

type DataPath

type DataPath string

func JoinDataPath

func JoinDataPath(p DataPath, elem ...string) DataPath

JoinDataPath joins any number of path elements with a root DataPath into a single path, separating them with an OS specific Separator, and returns it as a DataPath.

func (DataPath) String

func (p DataPath) String() string

type DefaultPaths

type DefaultPaths struct{}

func (*DefaultPaths) CachePathFor

func (p *DefaultPaths) CachePathFor(relPath CachePath) string

CachePathFor build the default path for a cache file or directory. It doesn't create any resources.

func (*DefaultPaths) ConfigPathFor

func (p *DefaultPaths) ConfigPathFor(relPath ConfigPath) string

ConfigPathFor build the default path for a config file or directory. It doesn't create any resources.

func (*DefaultPaths) CreateCacheDirFor

func (p *DefaultPaths) CreateCacheDirFor(relDirPath CachePath) (string, error)

CreateCacheDirFor builds the default path for a cache directory and creates it, along with intermediate directories, if needed.

func (*DefaultPaths) CreateCachePathFor

func (p *DefaultPaths) CreateCachePathFor(relFilePath CachePath) (string, error)

CreateCachePathFor builds the default path for a cache file and creates intermediate directories, if needed.

func (*DefaultPaths) CreateConfigDirFor

func (p *DefaultPaths) CreateConfigDirFor(relDirPath ConfigPath) (string, error)

CreateConfigDirFor builds the default path for a config directory and creates it, along with intermediate directories, if needed.

func (*DefaultPaths) CreateConfigPathFor

func (p *DefaultPaths) CreateConfigPathFor(relFilePath ConfigPath) (string, error)

CreateConfigPathFor builds the default path for a configuration file and creates intermediate directories, if needed.

func (*DefaultPaths) CreateDataDirFor

func (p *DefaultPaths) CreateDataDirFor(relDirPath DataPath) (string, error)

CreateDataDirFor builds the default path for a data directory and creates it, along with intermediate directories, if needed.

func (*DefaultPaths) CreateDataPathFor

func (p *DefaultPaths) CreateDataPathFor(relFilePath DataPath) (string, error)

CreateDataPathFor builds the default path for a data file and creates intermediate directories, if needed.

func (*DefaultPaths) CreateStateDirFor

func (p *DefaultPaths) CreateStateDirFor(relDirPath StatePath) (string, error)

CreateStateDirFor builds the default path for a state directory and creates it, along with intermediate directories, if needed.

func (*DefaultPaths) CreateStatePathFor

func (p *DefaultPaths) CreateStatePathFor(relFilePath StatePath) (string, error)

CreateStatePathFor builds the default path for a state file and creates intermediate directories, if needed.

func (*DefaultPaths) DataPathFor

func (p *DefaultPaths) DataPathFor(relPath DataPath) string

DataPathFor build the default path for a data file or directory. It doesn't create any resources.

func (*DefaultPaths) StatePathFor

func (p *DefaultPaths) StatePathFor(relPath StatePath) string

StatePathFor build the default path for a state file or directory. It doesn't create any resources.

type ListPathsResponse

type ListPathsResponse struct {
	CachePaths  map[string]string `json:"cachePaths"`
	ConfigPaths map[string]string `json:"configPaths"`
	DataPaths   map[string]string `json:"dataPaths"`
	StatePaths  map[string]string `json:"statePaths"`
}

func List

func List(vegaPaths Paths) *ListPathsResponse

type Paths

type Paths interface {
	CreateCachePathFor(CachePath) (string, error)
	CreateCacheDirFor(CachePath) (string, error)
	CreateConfigPathFor(ConfigPath) (string, error)
	CreateConfigDirFor(ConfigPath) (string, error)
	CreateDataPathFor(DataPath) (string, error)
	CreateDataDirFor(DataPath) (string, error)
	CreateStatePathFor(StatePath) (string, error)
	CreateStateDirFor(StatePath) (string, error)
	CachePathFor(CachePath) string
	ConfigPathFor(ConfigPath) string
	DataPathFor(DataPath) string
	StatePathFor(StatePath) string
}

nolint: interfacebloat

func New

func New(customHome string) Paths

New instantiates the specific implementation of the Paths interface based on the value of the customHome. If a customHome is specified the custom implementation CustomPaths is returned, the standard DefaultPaths otherwise.

type StatePath

type StatePath string

func JoinStatePath

func JoinStatePath(p StatePath, elem ...string) StatePath

JoinStatePath joins any number of path elements with a root StatePath into a single path, separating them with an OS specific Separator, and returns it as a StatePath.

func (StatePath) String

func (p StatePath) String() string

Jump to

Keyboard shortcuts

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