Skip to content

Commit

Permalink
Merge pull request HugoByte#48 from HugoByte/bug-fixes
Browse files Browse the repository at this point in the history
fix: fixed output file names to include uuid
  • Loading branch information
shreyasbhat0 authored Jan 2, 2024
2 parents 84a398a + ea20638 commit 8afa022
Show file tree
Hide file tree
Showing 18 changed files with 289 additions and 61 deletions.
9 changes: 7 additions & 2 deletions cli/cmd/bridge/btp/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,16 @@ func btpRelay(cmd *cobra.Command, args []string) {
cliContext.Fatal(err)
}

serviceFileName := fmt.Sprintf(common.DiveOutFile, common.EnclaveName)
shortUuid, err := cliContext.Context().GetShortUuid(common.EnclaveName)
if err != nil {
cliContext.Fatal(err)
}

serviceFileName := fmt.Sprintf(common.DiveOutFile, common.EnclaveName, shortUuid)

err = cliContext.FileHandler().WriteFile(serviceFileName, []byte(result))
if err != nil {
cliContext.Fatal(err)
}
cliContext.StopSpinnerIfNotVerbose(fmt.Sprintf("BTP Setup Completed between %s and %s. Please find service details in current working directory(%s)", chainA, chainB, serviceFileName), common.DiveLogs)
cliContext.StopSpinnerIfNotVerbose(fmt.Sprintf("BTP Setup Completed between %s and %s. Please find service details in current working directory(%s)\n", chainA, chainB, serviceFileName), common.DiveLogs)
}
11 changes: 9 additions & 2 deletions cli/cmd/bridge/btp/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,15 @@ func runBtpSetupWhenChainsAreNotIcon(cli *common.Cli, enclaveContext *enclaves.E
func runBtpSetupWhenSingleChainRunning(cli *common.Cli, enclaveContext *enclaves.EnclaveContext, chains *utils.Chains, bridge bool) (string, error) {
var chainAServiceResponse, chainBServiceResponse, response string
var services = common.Services{}
serviceFileName := fmt.Sprintf(common.ServiceFilePath, common.EnclaveName)
err := cli.FileHandler().ReadJson(serviceFileName, &services)

shortUuid, err := cli.Context().GetShortUuid(common.EnclaveName)
if err != nil {
return "", common.WrapMessageToError(err, "Failed to get enclave UUID")
}

serviceFileName := fmt.Sprintf(common.ServiceFilePath, common.EnclaveName, shortUuid)

err = cli.FileHandler().ReadJson(serviceFileName, &services)

if err != nil {
return "", common.WrapMessageToError(err, fmt.Sprintf("BTP Setup Failed For ChainA %s and ChainB %s", chains.ChainA, chains.ChainB))
Expand Down
9 changes: 7 additions & 2 deletions cli/cmd/bridge/ibc/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,17 @@ func ibcRelay(cmd *cobra.Command, args []string) {
cliContext.Fatal(err)
}

serviceFileName := fmt.Sprintf(common.DiveOutFile, common.EnclaveName)
shortUuid, err := cliContext.Context().GetShortUuid(common.EnclaveName)
if err != nil {
cliContext.Fatal(err)
}

serviceFileName := fmt.Sprintf(common.DiveOutFile, common.EnclaveName, shortUuid)

err = cliContext.FileHandler().WriteFile(serviceFileName, []byte(result))
if err != nil {
cliContext.Fatal(err)
}

cliContext.StopSpinnerIfNotVerbose(fmt.Sprintf("IBC Setup Completed between %s and %s. Please find service details in current working directory(%s)", chainA, chainB, serviceFileName), common.DiveLogs)
cliContext.StopSpinnerIfNotVerbose(fmt.Sprintf("IBC Setup Completed between %s and %s. Please find service details in current working directory(%s)\n", chainA, chainB, serviceFileName), common.DiveLogs)
}
16 changes: 0 additions & 16 deletions cli/cmd/bridge/ibc/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,10 @@ import (
chainutil "github.com/hugobyte/dive-core/cli/cmd/chains/utils"

"github.com/hugobyte/dive-core/cli/cmd/bridge/utils"
"github.com/hugobyte/dive-core/cli/cmd/chains/archway"
"github.com/hugobyte/dive-core/cli/cmd/chains/icon"
"github.com/hugobyte/dive-core/cli/cmd/chains/neutron"
"github.com/hugobyte/dive-core/cli/common"
"github.com/kurtosis-tech/kurtosis/api/golang/core/lib/enclaves"
)

var runChain = map[string]func(cli *common.Cli) (*common.DiveServiceResponse, error){
"icon": func(cli *common.Cli) (*common.DiveServiceResponse, error) {
return icon.RunIconNode(cli)
},
"archway": func(cli *common.Cli) (*common.DiveServiceResponse, error) {
return archway.RunArchway(cli)

},
"neutron": func(cli *common.Cli) (*common.DiveServiceResponse, error) {
return neutron.RunNeutron(cli)
},
}

func RunIbcRelay(cli *common.Cli) (string, error) {
var starlarkExecutionResponse string
chains := utils.InitChains(chainA, chainB, serviceA, serviceB, false)
Expand Down
9 changes: 7 additions & 2 deletions cli/cmd/bridge/utils/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,15 @@ func (chains *Chains) GetIbcRelayParams(src_service_config string, dst_service_c
func (chains *Chains) GetServicesResponse(cli *common.Cli) (string, string, error) {

var serviceConfig = common.Services{}

shortUuid, err := cli.Context().GetShortUuid(common.EnclaveName)
if err != nil {
return "", "", fmt.Errorf("failed to get short uuid of enclave")
}

serviceFileName := fmt.Sprintf(common.ServiceFilePath, common.EnclaveName)
serviceFileName := fmt.Sprintf(common.ServiceFilePath, common.EnclaveName, shortUuid)

err := cli.FileHandler().ReadJson(serviceFileName, &serviceConfig)
err = cli.FileHandler().ReadJson(serviceFileName, &serviceConfig)

if err != nil {
return "", "", err
Expand Down
9 changes: 7 additions & 2 deletions cli/cmd/chains/archway/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,20 @@ func archway(cmd *cobra.Command, args []string) {
cliContext.Fatal(err)
}

serviceFileName := fmt.Sprintf(common.ServiceFilePath, common.EnclaveName)
shortUuid, err := cliContext.Context().GetShortUuid(common.EnclaveName)
if err != nil {
cliContext.Fatal(err)
}

serviceFileName := fmt.Sprintf(common.ServiceFilePath, common.EnclaveName, shortUuid)

err = common.WriteServiceResponseData(response.ServiceName, *response, cliContext, serviceFileName)
if err != nil {
cliContext.Fatal(err)

}

stopMessage := fmt.Sprintf("Archway Node Started. Please find service details in current working directory(%s)", serviceFileName)
stopMessage := fmt.Sprintf("Archway Node Started. Please find service details in current working directory(%s)\n", serviceFileName)
cliContext.StopSpinnerIfNotVerbose(stopMessage, common.DiveLogs)

}
10 changes: 8 additions & 2 deletions cli/cmd/chains/eth/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,20 @@ func eth(cmd *cobra.Command, args []string) {
cliContext.Fatal(err)
}
}
serviceFileName := fmt.Sprintf(common.ServiceFilePath, common.EnclaveName)

shortUuid, err := cliContext.Context().GetShortUuid(common.EnclaveName)
if err != nil {
cliContext.Fatal(err)
}

serviceFileName := fmt.Sprintf(common.ServiceFilePath, common.EnclaveName, shortUuid)
err = common.WriteServiceResponseData(responseData.ServiceName, *responseData, cliContext, serviceFileName)

if err != nil {
cliContext.Fatal(err)
}

stopMessage := fmt.Sprintf("ETH Node Started. Please find service details in current working directory(%s)", serviceFileName)
stopMessage := fmt.Sprintf("ETH Node Started. Please find service details in current working directory(%s)\n", serviceFileName)
cliContext.Spinner().StopWithMessage(stopMessage)

}
10 changes: 8 additions & 2 deletions cli/cmd/chains/hardhat/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,20 @@ func hardhat(cmd *cobra.Command, args []string) {
cliContext.Fatal(err)
}
}
serviceFileName := fmt.Sprintf(common.ServiceFilePath, common.EnclaveName)

shortUuid, err := cliContext.Context().GetShortUuid(common.EnclaveName)
if err != nil {
cliContext.Fatal(err)
}

serviceFileName := fmt.Sprintf(common.ServiceFilePath, common.EnclaveName, shortUuid)
err = common.WriteServiceResponseData(responseData.ServiceName, *responseData, cliContext, serviceFileName)

if err != nil {
cliContext.Fatal(err)
}

stopMessage := fmt.Sprintf("Hardhat Node Started. Please find service details in current working directory(%s)", serviceFileName)
stopMessage := fmt.Sprintf("Hardhat Node Started. Please find service details in current working directory(%s)\n", serviceFileName)
cliContext.Spinner().StopWithMessage(stopMessage)

}
10 changes: 8 additions & 2 deletions cli/cmd/chains/icon/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ func icon(cmd *cobra.Command, args []string) {
}

}
serviceFileName := fmt.Sprintf(common.ServiceFilePath, common.EnclaveName)

shortUuid, err := cliContext.Context().GetShortUuid(common.EnclaveName)
if err != nil {
cliContext.Fatal(err)
}

serviceFileName := fmt.Sprintf(common.ServiceFilePath, common.EnclaveName, shortUuid)

err = common.WriteServiceResponseData(response.ServiceName, *response, cliContext, serviceFileName)
if err != nil {
Expand All @@ -92,7 +98,7 @@ func icon(cmd *cobra.Command, args []string) {

}

stopMessage := fmt.Sprintf("Icon Node Started. Please find service details in current working directory(%s)", serviceFileName)
stopMessage := fmt.Sprintf("Icon Node Started. Please find service details in current working directory(%s)\n", serviceFileName)
cliContext.Spinner().StopWithMessage(stopMessage)

}
Expand Down
12 changes: 10 additions & 2 deletions cli/cmd/chains/kusama/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const (
runUploadFiles = "upload_files"
runKusamaParaLocalFunctionName = "start_nodes"
runKusamaParaTestMainFunctionName = "run_testnet_mainnet"
runKusamaExplorer = "run_pokadot_js_app"
runKusamaPrometheus = "launch_prometheus"
runKusamaGrafana = "launch_grafana"
)

var KusamaCmd = common.NewDiveCommandBuilder().
Expand Down Expand Up @@ -59,14 +62,19 @@ func kusama(cmd *cobra.Command, args []string) {
}
}

serviceFileName := fmt.Sprintf(common.ServiceFilePath, common.EnclaveName)
shortUuid, err := cliContext.Context().GetShortUuid(common.EnclaveName)
if err != nil {
cliContext.Fatal(err)
}

serviceFileName := fmt.Sprintf(common.ServiceFilePath, common.EnclaveName, shortUuid)

for serviceName := range response.Dive {
err = common.WriteServiceResponseData(response.Dive[serviceName].ServiceName, *response.Dive[serviceName], cliContext, serviceFileName)
if err != nil {
cliContext.Fatal(err)
}
}
stopMessage := fmt.Sprintf("Kusama Node Started. Please find service details in current working directory(%s)", serviceFileName)
stopMessage := fmt.Sprintf("Kusama Node Started. Please find service details in current working directory(%s)\n", serviceFileName)
cliContext.Spinner().StopWithMessage(stopMessage)
}
Loading

0 comments on commit 8afa022

Please sign in to comment.