Skip to content

Commit

Permalink
chore(e2e): use 2 spaces for yaml (#3070)
Browse files Browse the repository at this point in the history
* e2e: use 2 spaces for yaml

* fixes

* address feedback
  • Loading branch information
gartnera authored Nov 1, 2024
1 parent 2e5d794 commit f9dab52
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
20 changes: 11 additions & 9 deletions cmd/zetae2e/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/zeta-chain/node/e2e/config"
)

var initConf = config.Config{}
var initConf = config.DefaultConfig()
var configFile = ""

func NewInitCmd() *cobra.Command {
Expand All @@ -19,18 +19,20 @@ func NewInitCmd() *cobra.Command {
RunE: initConfig,
}

InitCmd.Flags().StringVar(&initConf.RPCs.EVM, "ethURL", "http://eth:8545", "--ethURL http://eth:8545")
InitCmd.Flags().StringVar(&initConf.RPCs.ZetaCoreGRPC, "grpcURL", "zetacore0:9090", "--grpcURL zetacore0:9090")
InitCmd.Flags().StringVar(&initConf.RPCs.EVM, "ethURL", initConf.RPCs.EVM, "--ethURL http://eth:8545")
InitCmd.Flags().
StringVar(&initConf.RPCs.ZetaCoreRPC, "rpcURL", "http://zetacore0:26657", "--rpcURL http://zetacore0:26657")
StringVar(&initConf.RPCs.ZetaCoreGRPC, "grpcURL", initConf.RPCs.ZetaCoreGRPC, "--grpcURL zetacore0:9090")
InitCmd.Flags().
StringVar(&initConf.RPCs.Zevm, "zevmURL", "http://zetacore0:8545", "--zevmURL http://zetacore0:8545")
InitCmd.Flags().StringVar(&initConf.RPCs.Bitcoin.Host, "btcURL", "bitcoin:18443", "--grpcURL bitcoin:18443")
StringVar(&initConf.RPCs.ZetaCoreRPC, "rpcURL", initConf.RPCs.ZetaCoreRPC, "--rpcURL http://zetacore0:26657")
InitCmd.Flags().
StringVar(&initConf.RPCs.Solana, "solanaURL", "http://solana:8899", "--solanaURL http://solana:8899")
StringVar(&initConf.RPCs.Zevm, "zevmURL", initConf.RPCs.Zevm, "--zevmURL http://zetacore0:8545")
InitCmd.Flags().
StringVar(&initConf.RPCs.TONSidecarURL, "tonSidecarURL", "http://ton:8000", "--tonSidecarURL http://ton:8000")
InitCmd.Flags().StringVar(&initConf.ZetaChainID, "chainID", "athens_101-1", "--chainID athens_101-1")
StringVar(&initConf.RPCs.Bitcoin.Host, "btcURL", initConf.RPCs.Bitcoin.Host, "--btcURL bitcoin:18443")
InitCmd.Flags().
StringVar(&initConf.RPCs.Solana, "solanaURL", initConf.RPCs.Solana, "--solanaURL http://solana:8899")
InitCmd.Flags().
StringVar(&initConf.RPCs.TONSidecarURL, "tonSidecarURL", initConf.RPCs.TONSidecarURL, "--tonSidecarURL http://ton:8000")
InitCmd.Flags().StringVar(&initConf.ZetaChainID, "chainID", initConf.ZetaChainID, "--chainID athens_101-1")
InitCmd.Flags().StringVar(&configFile, local.FlagConfigFile, "e2e.config", "--cfg ./e2e.config")

return InitCmd
Expand Down
15 changes: 11 additions & 4 deletions e2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,20 @@ func WriteConfig(file string, config Config) error {
return errors.New("file name cannot be empty")
}

b, err := yaml.Marshal(config)
// #nosec G304 -- the variable is expected to be controlled by the user
fHandle, err := os.OpenFile(file, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
return err
return fmt.Errorf("open file: %w", err)
}
err = os.WriteFile(file, b, 0600)
defer fHandle.Close()

// use a custom encoder so we can set the indentation level
encoder := yaml.NewEncoder(fHandle)
defer encoder.Close()
encoder.SetIndent(2)
err = encoder.Encode(config)
if err != nil {
return err
return fmt.Errorf("encode config: %w", err)
}
return nil
}
Expand Down

0 comments on commit f9dab52

Please sign in to comment.