Skip to content

Commit

Permalink
fix: fixed output file names to include uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
riyasng12 committed Jan 2, 2024
1 parent 84a398a commit e2c7c69
Show file tree
Hide file tree
Showing 16 changed files with 358 additions and 61 deletions.
16 changes: 14 additions & 2 deletions cli/cmd/bridge/btp/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,24 @@ func btpRelay(cmd *cobra.Command, args []string) {
if err != nil {
cliContext.Fatal(err)
}

enclaves, err := cliContext.Context().GetEnclaves()
if err != nil {
cliContext.Fatal(err)
}

var ShortUuid string
for _, enclave := range enclaves {
if enclave.Name == common.EnclaveName {
ShortUuid = enclave.ShortUuid
}
}

serviceFileName := fmt.Sprintf(common.DiveOutFile, common.EnclaveName)
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)
}
17 changes: 15 additions & 2 deletions cli/cmd/bridge/btp/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,21 @@ 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)

enclaves, err := cli.Context().GetEnclaves()
if err != nil {
cli.Fatal(err)
}

var ShortUuid string
for _, enclave := range enclaves {
if enclave.Name == common.EnclaveName {
ShortUuid = enclave.ShortUuid
}
}
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
16 changes: 14 additions & 2 deletions cli/cmd/bridge/ibc/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,24 @@ func ibcRelay(cmd *cobra.Command, args []string) {
cliContext.Fatal(err)
}

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

var ShortUuid string
for _, enclave := range enclaves {
if enclave.Name == common.EnclaveName {
ShortUuid = enclave.ShortUuid
}
}

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
14 changes: 12 additions & 2 deletions cli/cmd/bridge/utils/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,20 @@ 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{}
enclaves, err := cli.Context().GetEnclaves()
if err != nil {
cli.Fatal(err)
}

serviceFileName := fmt.Sprintf(common.ServiceFilePath, common.EnclaveName)
var ShortUuid string
for _, enclave := range enclaves {
if enclave.Name == common.EnclaveName {
ShortUuid = enclave.ShortUuid
}
}
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
16 changes: 14 additions & 2 deletions cli/cmd/chains/archway/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,27 @@ func archway(cmd *cobra.Command, args []string) {
cliContext.Fatal(err)
}

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

var ShortUuid string
for _, enclave := range enclaves {
if enclave.Name == common.EnclaveName {
ShortUuid = enclave.ShortUuid
}
}

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)

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

enclaves, err := cliContext.Context().GetEnclaves()
if err != nil {
cliContext.Fatal(err)
}

var ShortUuid string
for _, enclave := range enclaves {
if enclave.Name == common.EnclaveName {
ShortUuid = enclave.ShortUuid
}
}

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)

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

enclaves, err := cliContext.Context().GetEnclaves()
if err != nil {
cliContext.Fatal(err)
}

var ShortUuid string
for _, enclave := range enclaves {
if enclave.Name == common.EnclaveName {
ShortUuid = enclave.ShortUuid
}
}

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)

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

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

enclaves, err := cliContext.Context().GetEnclaves()
if err != nil {
cliContext.Fatal(err)
}

var ShortUuid string
for _, enclave := range enclaves {
if enclave.Name == common.EnclaveName {
ShortUuid = enclave.ShortUuid
}
}

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

err = common.WriteServiceResponseData(response.ServiceName, *response, cliContext, serviceFileName)
if err != nil {
Expand All @@ -92,7 +105,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
19 changes: 17 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,26 @@ func kusama(cmd *cobra.Command, args []string) {
}
}

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

var ShortUuid string
for _, enclave := range enclaves {
if enclave.Name == common.EnclaveName {
ShortUuid = enclave.ShortUuid
}
}

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 e2c7c69

Please sign in to comment.