Documentation ¶
Overview ¶
package config implements the ipfs config file datastructures and utilities.
Index ¶
- Constants
- Variables
- func DataStorePath(configroot string) (string, error)
- func Decode(r io.Reader, value interface{}) error
- func Encode(w io.Writer, value interface{}) error
- func Filename(configroot string) (string, error)
- func HumanOutput(value interface{}) ([]byte, error)
- func LogsPath(configroot string) (string, error)
- func Marshal(value interface{}) ([]byte, error)
- func Path(configroot, extension string) (string, error)
- func PathRoot() (string, error)
- func ReadConfigFile(filename string, cfg interface{}) error
- func ReadConfigKey(filename, key string) (interface{}, error)
- func RecordUpdateCheck(cfg *Config, filename string)
- func Set(filename, key, value string) error
- func WriteConfigFile(filename string, cfg interface{}) error
- func WriteConfigKey(filename, key string, value interface{}) error
- func WriteFile(filename string, buf []byte) error
- type Addresses
- type AutoUpdateSetting
- type BootstrapPeer
- type Config
- type Datastore
- type Identity
- type Logs
- type Mounts
- type Tour
- type Version
Constants ¶
const ( // CheckError value for Version.Check to raise error and exit if version is obsolete CheckError = "error" // CheckWarn value for Version.Check to show warning message if version is obsolete CheckWarn = "warn" // CheckIgnore value for Version.Check to not perform update check CheckIgnore = "ignore" )
supported Version.Check values
const CurrentVersionNumber = "0.1.7"
CurrentVersionNumber is the current application's version literal
const DefaultConfigFile = "config"
DefaultConfigFile is the filename of the configuration file
const DefaultDataStoreDirectory = "datastore"
DefaultDataStoreDirectory is the directory to store all the local IPFS data.
const DefaultPathRoot = "~/.go-ipfs"
DefaultPathRoot is the path to the default config dir location.
const EnvDir = "IPFS_DIR"
EnvDir is the environment variable used to change the path root.
Variables ¶
var ErrUnknownAutoUpdateSetting = errors.New("unknown value for AutoUpdate")
ErrUnknownAutoUpdateSetting is returned when an unknown value is read from the config
var LogsDefaultDirectory = "logs"
LogsDefaultDirectory is the directory to store all IPFS event logs.
Functions ¶
func DataStorePath ¶
DataStorePath returns the default data store path given a configuration root (set an empty string to have the default configuration root)
func Filename ¶
Filename returns the configuration file path given a configuration root directory. If the configuration root directory is empty, use the default one
func HumanOutput ¶
HumanOutput gets a config value ready for printing
func LogsPath ¶
LogsPath returns the default path for event logs given a configuration root (set an empty string to have the default configuration root)
func Path ¶
Path returns the path `extension` relative to the configuration root. If an empty string is provided for `configroot`, the default root is used.
func ReadConfigFile ¶
ReadConfigFile reads the config from `filename` into `cfg`.
func ReadConfigKey ¶
ReadConfigKey retrieves only the value of a particular key
func RecordUpdateCheck ¶
RecordUpdateCheck is called to record that an update check was performed, showing that the running version is the most recent one.
func WriteConfigFile ¶
WriteConfigFile writes the config from `cfg` into `filename`.
func WriteConfigKey ¶
WriteConfigKey writes the value of a particular key
Types ¶
type Addresses ¶
type Addresses struct { Swarm []string // addresses for the swarm network API string // address for the local API (RPC) }
Addresses stores the (string) multiaddr addresses for the node.
type AutoUpdateSetting ¶
type AutoUpdateSetting int
AutoUpdateSetting implements json.Unmarshaler to check values in config
const ( AutoUpdateNever AutoUpdateSetting = iota // do not auto-update AutoUpdatePatch // only on new patch versions AutoUpdateMinor // on new minor or patch versions (Default) AutoUpdateMajor // on all, even Major, version changes )
AutoUpdateSetting values
func (AutoUpdateSetting) MarshalJSON ¶
func (s AutoUpdateSetting) MarshalJSON() ([]byte, error)
MarshalJSON converts the value back to JSON string
func (AutoUpdateSetting) String ¶
func (s AutoUpdateSetting) String() string
String converts valye to human readable string
func (*AutoUpdateSetting) UnmarshalJSON ¶
func (s *AutoUpdateSetting) UnmarshalJSON(in []byte) error
UnmarshalJSON checks the input against known strings
type BootstrapPeer ¶
type BootstrapPeer struct { Address string PeerID string // until multiaddr supports ipfs, use another field. }
BootstrapPeer is a peer used to bootstrap the network.
func (*BootstrapPeer) String ¶
func (bp *BootstrapPeer) String() string
type Config ¶
type Config struct { Identity Identity // local node's peer identity Datastore Datastore // local node's storage Addresses Addresses // local node's addresses Mounts Mounts // local node's mount points Version Version // local node's version management Bootstrap []*BootstrapPeer // local nodes's bootstrap peers Tour Tour // local node's tour position Logs Logs // local node's event log configuration }
Config is used to load IPFS config files.
type Identity ¶
Identity tracks the configuration of the local node's identity.
func (*Identity) DecodePrivateKey ¶
func (i *Identity) DecodePrivateKey(passphrase string) (crypto.PrivateKey, error)
DecodePrivateKey is a helper to decode the users PrivateKey
type Tour ¶
type Tour struct {
Last string // last tour topic read
}
Tour stores the ipfs tour read-list and resume point
type Version ¶
type Version struct { // Current is the ipfs version for which config was generated Current string // Check signals how to react on updates: // - "ignore" for not checking // - "warn" for issuing a warning and proceeding // - "error" for exiting with an error Check string // CheckDate is a timestamp for the last time API endpoint was checked for updates CheckDate time.Time // CheckPeriod is the time duration over which the update check will not be performed // (Note: cannot use time.Duration because marshalling with json breaks it) CheckPeriod string // AutoUpdate is optional AutoUpdate AutoUpdateSetting }
Version regulates checking if the most recent version is run
func VersionDefaultValue ¶
func VersionDefaultValue() Version
VersionDefaultValue returns the default version config value (for init).
func (*Version) ShouldCheckForUpdate ¶
ShouldCheckForUpdate returns if update check API endpoint is needed for this specific runtime