Documentation ¶
Overview ¶
Package confix applies changes to a Cosmos SDK TOML configuration file, to update configurations created with an older version of Cosmos SDK to a compatible format for a newer version.
Index ¶
- Constants
- Variables
- func CheckValid(fileName string, data []byte) error
- func LoadConfig(path string) (*tomledit.Document, error)
- func LoadLocalConfig(name, configType string) (*tomledit.Document, error)
- func MatchKeys(lhs, rhs *tomledit.Document) map[string]string
- func NoPlan(from *tomledit.Document, to, planType string) (transform.Plan, *tomledit.Document)
- func PlanBuilder(from *tomledit.Document, to, planType string, loadFn loadDestConfigFile) (transform.Plan, *tomledit.Document)
- func PrintDiff(w io.Writer, diffs []Diff)
- func Upgrade(ctx context.Context, plan transform.Plan, doc *tomledit.Document, ...) error
- func V2PlanBuilder(from *tomledit.Document, to, planType string) (transform.Plan, *tomledit.Document)
- func WithLogWriter(ctx context.Context, w io.Writer) context.Context
- type Diff
- type DiffType
- type KV
- type MigrationMap
Constants ¶
const ( AppConfig = "app.toml" AppConfigType = "app" ClientConfig = "client.toml" ClientConfigType = "client" CMTConfig = "config.toml" )
Variables ¶
var Migrations = MigrationMap{ "v0.45": NoPlan, "v0.46": defaultPlanBuilder, "v0.47": defaultPlanBuilder, "v0.50": defaultPlanBuilder, "v0.52": defaultPlanBuilder, "v2": V2PlanBuilder, }
Functions ¶
func CheckValid ¶
CheckValid checks whether the specified config appears to be a valid Cosmos SDK config file. It tries to unmarshal the config into both the server and client config structs.
func LoadConfig ¶
LoadConfig loads and parses the TOML document from path.
func LoadLocalConfig ¶
LoadLocalConfig loads and parses the TOML document from confix data
func MatchKeys ¶
MatchKeys diffs the keyspaces of the TOML documents in files lhs and rhs. Comments, order, and values are ignored for comparison purposes. It will return in the format of map[oldKey]newKey
func PlanBuilder ¶
func PlanBuilder(from *tomledit.Document, to, planType string, loadFn loadDestConfigFile) (transform.Plan, *tomledit.Document)
PlanBuilder is a function that returns a transformation plan for a given diff between two files.
func PrintDiff ¶
PrintDiff output prints one line per key that differs: -S name -- section exists in f1 but not f2 +S name -- section exists in f2 but not f1 -M name -- mapping exists in f1 but not f2 +M name -- mapping exists in f2 but not f1
func Upgrade ¶
func Upgrade(ctx context.Context, plan transform.Plan, doc *tomledit.Document, configPath, outputPath string, skipValidate bool) error
Upgrade reads the configuration file at configPath and applies any transformations necessary to Upgrade it to the current version. If this succeeds, the transformed output is written to outputPath. As a special case, if outputPath == "" the output is written to stdout.
It is safe if outputPath == inputPath. If a regular file outputPath already exists, it is overwritten. In case of error, the output is not written.
Upgrade is a convenience wrapper for calls to LoadConfig, ApplyFixes, and CheckValid. If the caller requires more control over the behavior of the Upgrade, call those functions directly.