Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: document the config file #194

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions cmd/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package main

import (
"os"
"strings"

"github.com/0xPolygon/cdk/config"
"github.com/urfave/cli/v2"
)

func configCmd(*cli.Context) error {
// var files []config.FileData
// fileData := make([]config.FileData, 0)
// fileData = append(fileData, config.FileData{Name: "default_mandatory_vars", Content: config.DefaultMandatoryVars})
// fileData = append(fileData, config.FileData{Name: "default_vars", Content: config.DefaultVars})
// fileData = append(fileData, config.FileData{Name: "default_values", Content: config.DefaultValues})
// fileData = append(fileData, files...)
// String buffer to concatenate all the default config vars
defaultConfig := strings.Builder{}
defaultConfig.WriteString(config.DefaultMandatoryVars)
defaultConfig.WriteString(config.DefaultVars)
defaultConfig.WriteString(config.DefaultValues)

// merger := config.NewConfigRender(fileData, config.EnvVarPrefix)

// renderedCfg, err := merger.Render()
// if err != nil {
// return err
// }

_, err := os.Stdout.WriteString(defaultConfig.String())
if err != nil {
return err
}

return nil
}
14 changes: 14 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ var (
Usage: "Allow that config-files contains deprecated fields",
Required: false,
}

extendedConfigFlag = cli.StringFlag{
Name: config.FlagExtendedConfig,
Aliases: []string{"e"},
Usage: "Save final configuration into to the indicated path (name: cdk-node-config.toml)",
Required: false,
}
)

func main() {
Expand Down Expand Up @@ -90,6 +97,13 @@ func main() {
Action: start,
Flags: append(flags, &customNetworkFlag),
},
{
Name: "config",
Aliases: []string{},
Usage: "Output a default configuration file",
Action: configCmd,
Flags: []cli.Flag{&extendedConfigFlag},
},
}

err := app.Run(os.Args)
Expand Down
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const (
FlagDisableDefaultConfigVars = "disable-default-config-vars"
// FlagAllowDeprecatedFields is the flag to allow deprecated fields
FlagAllowDeprecatedFields = "allow-deprecated-fields"
// FlagExtendedConfig is the flag to print extended configuration
FlagExtendedConfig = "extended"

deprecatedFieldSyncDB = "Aggregator.Synchronizer.DB is deprecated. Use Aggregator.Synchronizer.SQLDB instead."

Expand Down
Loading
Loading