generated from kurtosis-tech/package-template-repo
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
97bcfdc
commit 1edc95b
Showing
11 changed files
with
285 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,51 @@ | ||
package eth | ||
|
||
import ( | ||
"github.com/hugobyte/dive-core/cli/common" | ||
) | ||
|
||
func RunEth(cli *common.Cli) (*common.DiveServiceResponse, error) { | ||
|
||
enclaveContext, err := cli.Context().GetEnclaveContext(common.DiveEnclave) | ||
if err != nil { | ||
return nil, common.Errorc(common.InvalidEnclaveContextError, err.Error()) | ||
} | ||
runConfig := common.GetStarlarkRunConfig(`{}`, common.DiveEthHardhatNodeScript, "start_eth_node") | ||
|
||
response, _, err := enclaveContext.RunStarlarkRemotePackage(cli.Context().GetContext(), common.DiveRemotePackagePath, runConfig) | ||
|
||
if err != nil { | ||
return nil, common.WrapCodeToError(err, common.KurtosisContextError, "Starlark Run Failed") | ||
} | ||
|
||
responseData, services, skippedInstructions, err := common.GetSerializedData(cli, response) | ||
|
||
if err != nil { | ||
err = cli.Context().RemoveServicesByServiceNames(services, common.DiveEnclave) | ||
if err != nil { | ||
return nil, common.Errorc(common.InvalidEnclaveContextError, err.Error()) | ||
} | ||
|
||
return nil, common.Errorc(common.KurtosisContextError, err.Error()) | ||
|
||
} | ||
|
||
if cli.Context().CheckSkippedInstructions(skippedInstructions) { | ||
return nil, common.Errorc(common.KurtosisContextError, "Already Running") | ||
} | ||
|
||
ethResponseData := &common.DiveServiceResponse{} | ||
|
||
result, err := ethResponseData.Decode([]byte(responseData)) | ||
|
||
if err != nil { | ||
err = cli.Context().RemoveServicesByServiceNames(services, common.DiveEnclave) | ||
if err != nil { | ||
return nil, common.Errorc(common.InvalidEnclaveContextError, err.Error()) | ||
} | ||
|
||
return nil, common.Errorc(common.KurtosisContextError, err.Error()) | ||
} | ||
|
||
return result, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,75 @@ | ||
package utility | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hugobyte/dive-core/cli/common" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var enclaveName = "" | ||
|
||
var CleanCmd = common.NewDiveCommandBuilder(). | ||
SetUse("clean"). | ||
SetShort("Cleans up Kurtosis leftover artifacts"). | ||
SetLong("Destroys and removes any running encalves. If no enclaves running to remove it will throw an error"). | ||
AddBoolFlagP("all", "a", false, "To Clean All the Service in Enclave"). | ||
AddStringFlagWithShortHand(&enclaveName, "enclaveName", "e", common.DiveEnclave, "Please Provide enclave name to clean"). | ||
SetRun(clean).Build() | ||
|
||
func clean(cmd *cobra.Command, args []string) { | ||
cliContext := common.GetCliWithKurtosisContext() | ||
|
||
err := common.ValidateArgs(args) | ||
|
||
if err != nil { | ||
cliContext.Logger().Fatal(common.CodeOf(err), err.Error()) | ||
} | ||
|
||
cleanAll, err := cmd.Flags().GetBool("all") | ||
if err != nil { | ||
cliContext.Logger().SetErrorToStderr() | ||
cliContext.Logger().Error(common.InvalidCommandError, err.Error()) | ||
} | ||
|
||
if err != nil { | ||
cliContext.Logger().SetErrorToStderr() | ||
cliContext.Logger().Fatal(common.CodeOf(err), err.Error()) | ||
} | ||
|
||
err = cliContext.FileHandler().RemoveFiles([]string{common.DiveOutFile, common.ServiceFilePath}) | ||
if err != nil { | ||
cliContext.Logger().SetErrorToStderr() | ||
cliContext.Logger().Fatal(common.CodeOf(err), err.Error()) | ||
} | ||
|
||
enclaves, err := cliContext.Context().GetEnclaves() | ||
if err != nil { | ||
cliContext.Logger().SetErrorToStderr() | ||
cliContext.Logger().Fatal(common.CodeOf(err), err.Error()) | ||
} | ||
|
||
if len(enclaves) == 0 { | ||
cliContext.Logger().SetOutputToStdout() | ||
cliContext.Logger().Info("No Enclaves Running") | ||
cliContext.Context().Exit(0) | ||
|
||
} | ||
|
||
if cleanAll { | ||
enclavesInfo, err := cliContext.Context().CleanEnclaves() | ||
if err != nil { | ||
cliContext.Logger().SetErrorToStderr() | ||
cliContext.Logger().Fatal(common.CodeOf(err), err.Error()) | ||
} | ||
|
||
cliContext.Logger().Info(fmt.Sprintf("Enclaves Cleaned %v", enclavesInfo)) | ||
|
||
} else { | ||
err = cliContext.Context().CleanEnclaveByName(enclaveName) | ||
if err != nil { | ||
cliContext.Logger().SetErrorToStderr() | ||
cliContext.Logger().Fatal(common.CodeOf(err), err.Error()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.