Skip to content

Commit

Permalink
refactor: move prepare command to dataloss sub command
Browse files Browse the repository at this point in the history
  • Loading branch information
deepthidevaki committed Nov 15, 2022
1 parent d6f13ad commit 3cb2943
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 47 deletions.
22 changes: 22 additions & 0 deletions go-chaos/cmd/dataloss_sim.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

func init() {
rootCmd.AddCommand(datalossCmd)
rootCmd.AddCommand(prepareCmd)
datalossCmd.AddCommand(datalossDelete)
datalossCmd.AddCommand(datalossRecover)

Expand All @@ -35,6 +36,27 @@ var datalossCmd = &cobra.Command{
Long: `Simulate dataloss of a broker, and restart from it. "zbchaos prepare" must be executed once on this cluster before this command`,
}

var prepareCmd = &cobra.Command{
Use: "prepare",
Short: "Prepare the k8s deployment for dataloss test",
Long: `Prepares the k8s deployment - such as applying patches to statefulsets - to enable applying dataloss commands.`,
Run: func(cmd *cobra.Command, args []string) {
k8Client, err := internal.CreateK8Client()
if err != nil {
panic(err)
}

// Add Init container for dataloss simulation test
err = k8Client.ApplyInitContainerPatch()

if err != nil {
panic(err)
}

fmt.Printf("Prepared cluster in namesapce %s\n", k8Client.GetCurrentNamespace())
},
}

var datalossDelete = &cobra.Command{
Use: "delete",
Short: "Delete data of a broker",
Expand Down
47 changes: 0 additions & 47 deletions go-chaos/cmd/prepare.go

This file was deleted.

0 comments on commit 3cb2943

Please sign in to comment.