Skip to content

Commit

Permalink
not must need config
Browse files Browse the repository at this point in the history
  • Loading branch information
fyInALT committed Apr 1, 2024
1 parent 26be29b commit 233a84a
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 41 deletions.
19 changes: 11 additions & 8 deletions cli/actions/deposit_into_strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ func DepositIntoStrategy(ctx *cli.Context) error {

configPath := ctx.GlobalString(config.ConfigFileFlag.Name)
nodeConfig := config.NodeConfig{}
err := sdkutils.ReadYamlConfig(configPath, &nodeConfig)
if err != nil {
return err
}
configJson, err := json.MarshalIndent(nodeConfig, "", " ")
if err != nil {
log.Fatalf(err.Error())

if configPath != "" {
err := sdkutils.ReadYamlConfig(configPath, &nodeConfig)
if err != nil {
return err
}
configJson, err := json.MarshalIndent(nodeConfig, "", " ")
if err != nil {
log.Fatalf(err.Error())
}
log.Println("Config:", string(configJson))
}
log.Println("Config:", string(configJson))

operator, err := operator.NewOperatorFromConfig(nodeConfig)
if err != nil {
Expand Down
19 changes: 11 additions & 8 deletions cli/actions/print_operator_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ func PrintOperatorStatus(ctx *cli.Context) error {

configPath := ctx.GlobalString(config.ConfigFileFlag.Name)
nodeConfig := config.NodeConfig{}
err := sdkutils.ReadYamlConfig(configPath, &nodeConfig)
if err != nil {
return err
}
configJson, err := json.MarshalIndent(nodeConfig, "", " ")
if err != nil {
log.Fatalf(err.Error())

if configPath != "" {
err := sdkutils.ReadYamlConfig(configPath, &nodeConfig)
if err != nil {
return err
}
configJson, err := json.MarshalIndent(nodeConfig, "", " ")
if err != nil {
log.Fatalf(err.Error())
}
log.Println("Config:", string(configJson))
}
log.Println("Config:", string(configJson))

operator, err := operator.NewOperatorFromConfig(nodeConfig)
if err != nil {
Expand Down
19 changes: 11 additions & 8 deletions cli/actions/register_operator_with_avs.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ func RegisterOperatorWithAvs(ctx *cli.Context) error {

configPath := ctx.GlobalString(config.ConfigFileFlag.Name)
nodeConfig := config.NodeConfig{}
err := sdkutils.ReadYamlConfig(configPath, &nodeConfig)
if err != nil {
return err
}
configJson, err := json.MarshalIndent(nodeConfig, "", " ")
if err != nil {
log.Fatalf(err.Error())

if configPath != "" {
err := sdkutils.ReadYamlConfig(configPath, &nodeConfig)
if err != nil {
return err
}
configJson, err := json.MarshalIndent(nodeConfig, "", " ")
if err != nil {
log.Fatalf(err.Error())
}
log.Println("Config:", string(configJson))
}
log.Println("Config:", string(configJson))

operator, err := operator.NewOperatorFromConfig(nodeConfig)
if err != nil {
Expand Down
19 changes: 11 additions & 8 deletions cli/actions/register_operator_with_eigenlayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ func RegisterOperatorWithEigenlayer(ctx *cli.Context) error {

configPath := ctx.GlobalString(config.ConfigFileFlag.Name)
nodeConfig := config.NodeConfig{}
err := sdkutils.ReadYamlConfig(configPath, &nodeConfig)
if err != nil {
return err
}
configJson, err := json.MarshalIndent(nodeConfig, "", " ")
if err != nil {
log.Fatalf(err.Error())

if configPath != "" {
err := sdkutils.ReadYamlConfig(configPath, &nodeConfig)
if err != nil {
return err
}
configJson, err := json.MarshalIndent(nodeConfig, "", " ")
if err != nil {
log.Fatalf(err.Error())
}
log.Println("Config:", string(configJson))
}
log.Println("Config:", string(configJson))

operator, err := operator.NewOperatorFromConfig(nodeConfig)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion core/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ var (
/* Required Flags */
ConfigFileFlag = cli.StringFlag{
Name: "config",
Required: true,
Required: false,
Usage: "Load configuration from `FILE`",
}
DeploymentFileFlag = cli.StringFlag{
Expand Down
19 changes: 11 additions & 8 deletions operator/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@ func operatorMain(ctx *cli.Context) error {
log.Println("Initializing Operator")
configPath := ctx.GlobalString(config.ConfigFileFlag.Name)
nodeConfig := config.NodeConfig{}
err := sdkutils.ReadYamlConfig(configPath, &nodeConfig)
if err != nil {
return err
}
configJson, err := json.MarshalIndent(nodeConfig, "", " ")
if err != nil {
log.Fatalf(err.Error())

if configPath != "" {
err := sdkutils.ReadYamlConfig(configPath, &nodeConfig)
if err != nil {
return err
}
configJson, err := json.MarshalIndent(nodeConfig, "", " ")
if err != nil {
log.Fatalf(err.Error())
}
log.Println("Config from file:", string(configJson))
}
log.Println("Config from file:", string(configJson))

log.Println("initializing operator")
operator, err := operator.NewOperatorFromConfig(nodeConfig)
Expand Down
5 changes: 5 additions & 0 deletions operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ func withEnvConfig(c config.NodeConfig) config.NodeConfig {
// - `OPERATOR_SERVER_URL` : operator_server_ip_port_addr
// - `METADATA_URI` : metadata_uri

Production, ok := os.LookupEnv("OPERATOR_PRODUCTION")
if ok && Production != "" {
c.Production = Production == "true"
}

ethRpcUrl, ok := os.LookupEnv("ETH_RPC_URL")
if ok && ethRpcUrl != "" {
c.EthRpcUrl = ethRpcUrl
Expand Down

0 comments on commit 233a84a

Please sign in to comment.