Config V2.0.0 PR fixes

- Added dumpconfig command back for backward compatibility
- Added dns.server-port flag and change dns.port flag description
pull/3681/head
ntsanov 4 years ago
parent cb3fc64267
commit a1550504c8
  1. 29
      cmd/harmony/config.go
  2. 12
      cmd/harmony/flags.go
  3. 4
      cmd/harmony/flags_test.go
  4. 1
      cmd/harmony/main.go

@ -314,24 +314,35 @@ var updateConfigCmd = &cobra.Command{
},
}
func dumpConfig(cmd *cobra.Command, args []string) {
nt := getNetworkType(cmd)
config := getDefaultHmyConfigCopy(nt)
if err := writeHarmonyConfigToFile(config, args[0]); err != nil {
fmt.Println(err)
os.Exit(128)
}
}
var dumpConfigCmd = &cobra.Command{
Use: "dump [config_file]",
Short: "dump default file for harmony binary configurations",
Short: "dump default config file for harmony binary configurations",
Long: "dump default config file for harmony binary configurations",
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
nt := getNetworkType(cmd)
config := getDefaultHmyConfigCopy(nt)
Run: dumpConfig,
}
if err := writeHarmonyConfigToFile(config, args[0]); err != nil {
fmt.Println(err)
os.Exit(128)
}
},
var dumpConfigLegacyCmd = &cobra.Command{
Use: "dumpconfig [config_file]",
Short: "depricated - use config dump instead",
Long: "depricated - use config dump instead",
Args: cobra.MinimumNArgs(1),
Run: dumpConfig,
}
func registerDumpConfigFlags() error {
return cli.RegisterFlags(dumpConfigCmd, []cli.Flag{networkTypeFlag})
return cli.RegisterFlags(dumpConfigLegacyCmd, []cli.Flag{networkTypeFlag})
}
func promptConfigUpdate() bool {

@ -32,6 +32,7 @@ var (
dnsSyncFlags = []cli.Flag{
dnsZoneFlag,
dnsPortFlag,
dnsServerPortFlag,
dnsClientFlag,
dnsServerFlag,
@ -382,7 +383,12 @@ var (
dnsPortFlag = cli.IntFlag{
Name: "dns.port",
DefValue: nodeconfig.DefaultDNSPort,
Usage: "port of customized dns node",
Usage: "dns sync remote server port",
}
dnsServerPortFlag = cli.IntFlag{
Name: "dns.server-port",
DefValue: nodeconfig.DefaultDNSPort,
Usage: "dns sync local server port",
}
syncLegacyClientFlag = cli.BoolFlag{
Name: "sync.legacy.client",
@ -455,6 +461,10 @@ func applyDNSSyncFlags(cmd *cobra.Command, cfg *harmonyConfig) {
cfg.DNSSync.Client = cli.GetBoolFlagValue(cmd, dnsClientFlag)
}
if cli.IsFlagChanged(cmd, dnsServerPortFlag) {
cfg.DNSSync.ServerPort = cli.GetIntFlagValue(cmd, dnsServerPortFlag)
}
}
func applyNetworkFlags(cmd *cobra.Command, cfg *harmonyConfig) {

@ -248,7 +248,7 @@ func TestNetworkFlags(t *testing.T) {
},
{
args: []string{"--network", "stk", "--bootnodes", "1,2,3,4", "--dns.zone", "8.8.8.8",
"--dns.port", "9001"},
"--dns.port", "9001", "--dns.server-port", "9002"},
expConfig: harmonyConfig{
Network: networkConfig{
NetworkType: "pangaea",
@ -259,7 +259,7 @@ func TestNetworkFlags(t *testing.T) {
Zone: "8.8.8.8",
LegacySyncing: false,
Server: true,
ServerPort: nodeconfig.GetDefaultDNSPort(nodeconfig.Pangaea),
ServerPort: 9002,
},
},
},

@ -94,6 +94,7 @@ func init() {
configCmd.AddCommand(updateConfigCmd)
rootCmd.AddCommand(configCmd)
rootCmd.AddCommand(versionCmd)
rootCmd.AddCommand(dumpConfigLegacyCmd)
if err := registerRootCmdFlags(); err != nil {
os.Exit(2)

Loading…
Cancel
Save