Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyClientConfigToContext(ctx client.Context, config *ClientConfig) (client.Context, error)
- func DefaultAppConfig() *serverconfig.Config
- func DefaultTmConfig() *tmconfig.Config
- func EnsureConfigDir(cmd *cobra.Command) error
- func ExtractAppConfig(cmd *cobra.Command) (*serverconfig.Config, error)
- func ExtractClientConfigAndMap(cmd *cobra.Command) (*ClientConfig, FieldValueMap, error)
- func ExtractTmConfig(cmd *cobra.Command) (*tmconfig.Config, error)
- func FileExists(fullFilePath string) bool
- func GetFullPathToAppConf(cmd *cobra.Command) string
- func GetFullPathToClientConf(cmd *cobra.Command) string
- func GetFullPathToConfigDir(cmd *cobra.Command) string
- func GetFullPathToPackedConf(cmd *cobra.Command) string
- func GetFullPathToTmConf(cmd *cobra.Command) string
- func GetFullPathToUnmanagedConf(cmd *cobra.Command) string
- func GetHomeDir(cmd *cobra.Command) string
- func GetStringFromValue(v reflect.Value) string
- func InterceptConfigsPreRunHandler(cmd *cobra.Command) error
- func IsPacked(cmd *cobra.Command) bool
- func LoadConfigFromFiles(cmd *cobra.Command) (err error)
- func PackConfig(cmd *cobra.Command) error
- func SaveConfigs(cmd *cobra.Command, appConfig *serverconfig.Config, tmConfig *tmconfig.Config, ...)
- func SetPioConfigFromFlags(flagSet *pflag.FlagSet)
- func UnpackConfig(cmd *cobra.Command) error
- func WriteConfigToFile(configFilePath string, config *ClientConfig)
- type ClientConfig
- func (c *ClientConfig) SetBroadcastMode(broadcastMode string)
- func (c *ClientConfig) SetChainID(chainID string)
- func (c *ClientConfig) SetKeyringBackend(keyringBackend string)
- func (c *ClientConfig) SetNode(node string)
- func (c *ClientConfig) SetOutput(output string)
- func (c ClientConfig) ValidateBasic() error
- type FieldValueMap
- func (m FieldValueMap) AddEntriesFrom(maps ...FieldValueMap)
- func (m FieldValueMap) AsConfigMap() (map[string]interface{}, error)
- func (m FieldValueMap) FindEntries(key string) (FieldValueMap, bool)
- func (m FieldValueMap) GetSortedKeys() []string
- func (m FieldValueMap) GetStringOf(key string) string
- func (m FieldValueMap) Has(key string) bool
- func (m FieldValueMap) SetFromString(key, valueStr string) error
- func (m FieldValueMap) SetToNil(key string)
- type UpdatedField
- type UpdatedFieldMap
Constants ¶
const ( // ConfigSubDir is the subdirectory of HOME that contains the configuration files. ConfigSubDir = "config" // AppConfFilename is the filename of the app/cosmos configuration file. AppConfFilename = "app.toml" // TmConfFilename is the filename of the tendermint configuration file. TmConfFilename = "config.toml" // ClientConfFilename is the filename of the client configuration file. ClientConfFilename = "client.toml" // UnmanagedConfFilename is the filename of the unmanaged configuration file. UnmanagedConfFilename = "custom.toml" // PackedConfFilename is the filename of the packed (non-defaults) file. PackedConfFilename = "packed-conf.json" )
const ( // CustomDenomFlag flag to take in custom denom, defaults to nhash if not passed in. CustomDenomFlag = "custom-denom" // CustomMsgFeeFloorPriceFlag flag to take in custom msg floor fees, defaults to 1905nhash if not passed in. CustomMsgFeeFloorPriceFlag = "msgfee-floor-price" )
Variables ¶
var DefaultConsensusTimeoutCommit = 1500 * time.Millisecond
DefaultConsensusTimeoutCommit is the default value used for the consensus.timeout_commit config value.
Functions ¶
func ApplyClientConfigToContext ¶
ApplyClientConfigToContext returns a client context after having the client config values applied to it.
func DefaultAppConfig ¶ added in v1.13.0
func DefaultAppConfig() *serverconfig.Config
DefaultAppConfig gets our default app config.
func DefaultTmConfig ¶ added in v1.16.0
func EnsureConfigDir ¶
EnsureConfigDir ensures the given directory exists, creating it if necessary. Errors if the config directory doesn't exist and cannot be created (e.g. because of permissions). Errors if the path already exists as a non-directory.
func ExtractAppConfig ¶
func ExtractAppConfig(cmd *cobra.Command) (*serverconfig.Config, error)
ExtractAppConfig creates an app/cosmos config from the command context.
func ExtractClientConfigAndMap ¶
func ExtractClientConfigAndMap(cmd *cobra.Command) (*ClientConfig, FieldValueMap, error)
ExtractClientConfigAndMap from the command context, creates a client config and related string->value map.
func ExtractTmConfig ¶
ExtractTmConfig creates a tendermint config from the command context.
func FileExists ¶
FileExists returns true if there is no error getting stat info of the file. Even returns false if os.IsNotExist(err) is false. I.e. if the file exists but isn't readable, this will still return false.
func GetFullPathToAppConf ¶
GetFullPathToAppConf gets the full path to the app/cosmos config file.
func GetFullPathToClientConf ¶
GetFullPathToClientConf gets the full path to the client config file.
func GetFullPathToConfigDir ¶
GetFullPathToConfigDir gets the full path to the config directory.
func GetFullPathToPackedConf ¶
GetFullPathToPackedConf gets the full path to the packed/non-defaults config file.
func GetFullPathToTmConf ¶
GetFullPathToTmConf gets the full path to the tendermint config file.
func GetFullPathToUnmanagedConf ¶ added in v1.12.0
GetFullPathToUnmanagedConf gets the full path to the unmanaged config file.
func GetHomeDir ¶
GetHomeDir gets the home directory from the provided cobra command.
func GetStringFromValue ¶
GetStringFromValue gets a string of the given value. This creates strings that are more in line with what the values look like in the config files. For slices and arrays, it turns into `["a", "b", "c"]`. For strings, it turns into `"a"`. For anything else, it just uses fmt %v. This wasn't designed with the following kinds in mind:
Invalid, Chan, Func, Interface, Map, Ptr, Struct, or UnsafePointer.
func InterceptConfigsPreRunHandler ¶
InterceptConfigsPreRunHandler performs a pre-run function for all commands. It will finish setting up the client context and create the server context. It will create a Viper literal and the configs will be read and parsed or created from defaults. The viper literal is used to read and parse configurations. Command handlers can fetch the server or client contexts to get the Tendermint, App/Cosmos, or Client configurations, or to get access to viper.
func IsPacked ¶
IsPacked checks to see if we're using a packed config or not. returns true if using the packed config. returns false if using the unpacked multiple config files.
func LoadConfigFromFiles ¶
LoadConfigFromFiles loads configurations appropriately.
func PackConfig ¶
PackConfig generates and saves the packed config file then removes the individual config files.
func SaveConfigs ¶
func SaveConfigs( cmd *cobra.Command, appConfig *serverconfig.Config, tmConfig *tmconfig.Config, clientConfig *ClientConfig, verbose bool, )
SaveConfigs saves the configs to files. If the config is packed, any nil configs provided will extracted from the cmd. If the config is unpacked, only the configs provided will be written. Any errors encountered will result in a panic.
func SetPioConfigFromFlags ¶ added in v1.16.0
func UnpackConfig ¶
UnpackConfig generates the saves the individual config files and removes the packed config file.
func WriteConfigToFile ¶
func WriteConfigToFile(configFilePath string, config *ClientConfig)
WriteConfigToFile creates the file contents using a template and the provided config then writes the contents to the provided configFilePath.
Types ¶
type ClientConfig ¶
type ClientConfig struct { ChainID string `mapstructure:"chain-id" json:"chain-id"` KeyringBackend string `mapstructure:"keyring-backend" json:"keyring-backend"` Output string `mapstructure:"output" json:"output"` Node string `mapstructure:"node" json:"node"` BroadcastMode string `mapstructure:"broadcast-mode" json:"broadcast-mode"` }
func DefaultClientConfig ¶
func DefaultClientConfig() *ClientConfig
DefaultClientConfig returns the reference to ClientConfig with default values.
func ExtractClientConfig ¶
func ExtractClientConfig(cmd *cobra.Command) (*ClientConfig, error)
ExtractClientConfig creates a client config from the command context.
func (*ClientConfig) SetBroadcastMode ¶
func (c *ClientConfig) SetBroadcastMode(broadcastMode string)
func (*ClientConfig) SetChainID ¶
func (c *ClientConfig) SetChainID(chainID string)
func (*ClientConfig) SetKeyringBackend ¶
func (c *ClientConfig) SetKeyringBackend(keyringBackend string)
func (*ClientConfig) SetNode ¶
func (c *ClientConfig) SetNode(node string)
func (*ClientConfig) SetOutput ¶
func (c *ClientConfig) SetOutput(output string)
func (ClientConfig) ValidateBasic ¶
func (c ClientConfig) ValidateBasic() error
type FieldValueMap ¶
FieldValueMap maps field names to reflect.Value objects.
func ExtractAppConfigAndMap ¶
func ExtractAppConfigAndMap(cmd *cobra.Command) (*serverconfig.Config, FieldValueMap, error)
ExtractAppConfigAndMap from the command context, creates an app/cosmos config and related string->value map.
func ExtractTmConfigAndMap ¶
ExtractTmConfigAndMap from the command context, creates a tendermint config and related string->value map.
func GetAllConfigDefaults ¶
func GetAllConfigDefaults() FieldValueMap
GetAllConfigDefaults gets a field map from the defaults of all the configs.
func MakeFieldValueMap ¶
func MakeFieldValueMap(obj interface{}, fillNilsWithZero bool) FieldValueMap
MakeFieldValueMap gets a map of string field names to reflect.Value objects for a given object. An empty map is returned if the provided obj is nil, or isn't either a struct or pointer chain to a struct. Substruct fields will have the parent struct's field name and substruct field name separated by a period. E.g. This struct { Foo { Bar: "foobar" } }, will have an entry for "foo.bar". Each segment of a name comes from getFieldName. I.e. pays attention to mapstruct and is all lowercase. Similarly, if mapstruct says to squash the fields, they won't have the parent field name. If fillNilsWithZero is true, nil fields in the obj will be filled in using zero values for that field type.
Fields in structs created this way cannot be set later using the map values. But the resulting map will contain information about all possible fields in the object. None of the substructures will not have map entries specifically for the parent field containing the substructure. E.g. With { Foo: { Bar: "foobar" } }, there won't be an entry for "foo", but there will be one for "foo.bar".
If fillNilsWithZero is false, nil fields in the obj will have an entry for the field and a value where .IsNil() is true.
If the provided obj is a pointer, then the resulting map values can be used to set values in the obj. Substructures that are nil will have entries in the resulting map. E.g. With { Foo: (*Bar)(nil) }, there will be an entry for "foo". Substructures that are not nill will still not have an entry though; they'll have entries for sub-fields still. E.g. With { Foo: (*Bar)(nil), Ban: { Ana: "banana" } will have entries for "foo" and "ban.ana", but not "ban" (it isn't nil).
func (FieldValueMap) AddEntriesFrom ¶
func (m FieldValueMap) AddEntriesFrom(maps ...FieldValueMap)
AddEntriesFrom Add all entries from the provided map into this map. If the same key exists in both maps, the value from the one provided will overwrite the one in this map.
func (FieldValueMap) AsConfigMap ¶ added in v1.13.0
func (m FieldValueMap) AsConfigMap() (map[string]interface{}, error)
AsConfigMap converts this into a map[string]interface{} adding sub-sections as single entries (as opposed to full keys containing a . (period)).
func (FieldValueMap) FindEntries ¶
func (m FieldValueMap) FindEntries(key string) (FieldValueMap, bool)
FindEntries looks for entries in this map that match the provided key. First, if the key doesn't end in a period, an exact entry match is looked for. If such an entry is found, only that entry will be returned. If no such entry is found, a period is added to the end of the key (if not already there). E.g. Providing "filter_peers" will get just the "filter_peers" entry. Providing "consensus." will bypass the exact key lookup, and return all fields that start with "consensus.". Providing "consensus" will look first for a field specifically called "consensus", then, if/when not found, will return all fields that start with "consensus.". Then, all entries with keys that start with the desired key are returned. The second return value indicates whether or not anything was found.
func (FieldValueMap) GetSortedKeys ¶
func (m FieldValueMap) GetSortedKeys() []string
GetSortedKeys gets the keys of this FieldValueMap and sorts them using sortKeys.
func (FieldValueMap) GetStringOf ¶
func (m FieldValueMap) GetStringOf(key string) string
GetStringOf gets a string representation of the value with the given key. If the key doesn't exist in this FieldValueMap, an empty string is returned.
func (FieldValueMap) Has ¶
func (m FieldValueMap) Has(key string) bool
Has checks if the provided key exists in this FieldValueMap.
func (FieldValueMap) SetFromString ¶
func (m FieldValueMap) SetFromString(key, valueStr string) error
SetFromString sets a value from the provided string. The string is converted appropriately for the underlying value type. Assuming the value came from MakeFieldValueMap, this will actually be updating the value in the config object provided to that function.
func (FieldValueMap) SetToNil ¶
func (m FieldValueMap) SetToNil(key string)
SetToNil sets the given key to a nil value.
type UpdatedField ¶
UpdatedField is a struct holding information about a config field that has been updated.
func MakeUpdatedField ¶
func MakeUpdatedField(key string, wasMap, isNowMap FieldValueMap) (UpdatedField, bool)
MakeUpdatedField creates an UpdateField with the given key getting the values from each provided map. If either one of the maps doesn't have the key, the second returned value will be false.
func (UpdatedField) HasDiff ¶
func (u UpdatedField) HasDiff() bool
HasDiff returns true if IsNow and Was have different values.
func (UpdatedField) String ¶
func (u UpdatedField) String() string
String converts an UpdatedField to a string similar to using %#v but a little cleaner.
func (UpdatedField) StringAsDefault ¶
func (u UpdatedField) StringAsDefault() string
StringAsDefault creates a string from this UpdatedField identifying the Was as a default.
func (UpdatedField) StringAsUpdate ¶
func (u UpdatedField) StringAsUpdate() string
StringAsUpdate creates a string from this UpdatedField indicating a change has being made.
func (*UpdatedField) Update ¶
func (u *UpdatedField) Update(newerInfo UpdatedField)
Update updates the base UpdatedField given information in the provided newerInfo.
type UpdatedFieldMap ¶
type UpdatedFieldMap map[string]*UpdatedField
UpdatedFieldMap maps field names to UpdatedField references.
func MakeUpdatedFieldMap ¶
func MakeUpdatedFieldMap(wasMap, isNowMap FieldValueMap, onlyChanged bool) UpdatedFieldMap
MakeUpdatedFieldMap creates an UpdatedFieldMap with fields that exist in both provided FieldValueMap objects. Set onlyChanged to true to further limit fields to only those with differences.
func (UpdatedFieldMap) AddOrUpdate ¶
func (m UpdatedFieldMap) AddOrUpdate(key, was, isNow string)
AddOrUpdate adds or updates an entry in this map using the provided info. If the key isn't in this map yet, the entry is added. Otherwise UpdatedField.Update us called on the existing entry.
func (UpdatedFieldMap) AddOrUpdateEntriesFrom ¶
func (m UpdatedFieldMap) AddOrUpdateEntriesFrom(maps ...UpdatedFieldMap)
AddOrUpdateEntriesFrom applies AddOrUpdateEntry on this map using each entry in the provided map.
func (UpdatedFieldMap) AddOrUpdateEntry ¶
func (m UpdatedFieldMap) AddOrUpdateEntry(info *UpdatedField)
AddOrUpdateEntry adds or updates an entry in this map using the provided info. If the key isn't in this map yet, the entry is added. Otherwise UpdatedField.Update us called on the existing entry.
func (UpdatedFieldMap) GetSortedKeys ¶
func (m UpdatedFieldMap) GetSortedKeys() []string
GetSortedKeys gets the keys of this UpdatedFieldMap and sorts them using sortKeys.