Skip to content

Commit

Permalink
improve logic for list environment
Browse files Browse the repository at this point in the history
Signed-off-by: Shivam Purohit <[email protected]>
  • Loading branch information
shivam-Purohit committed Mar 15, 2024
1 parent 50d7630 commit a099141
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions pkg/cmd/get/environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@ var GetChaosEnvironmentsCmd = &cobra.Command{
}
}

environmentList, err := environment.ListChaosEnvironments(projectID, credentials)
if err != nil {
if strings.Contains(err.Error(), "permission_denied") {
utils.Red.Println("❌ You don't have enough permissions to access this resource.")
os.Exit(1)
} else {
utils.PrintError(err)
os.Exit(1)
}
}
environmentID, err := cmd.Flags().GetString("environment-id")
utils.PrintError(err)

if environmentID == "" {
environmentList, err := environment.ListChaosEnvironments(projectID, credentials)
if err != nil {
if strings.Contains(err.Error(), "permission_denied") {
utils.Red.Println("❌ You don't have enough permissions to access this resource.")
os.Exit(1)
} else {
utils.PrintError(err)
os.Exit(1)
}
}
environmentListData := environmentList.Data.ListEnvironmentDetails.Environments

itemsPerPage := 5
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var GetCmd = &cobra.Command{
litmusctl get chaos-experiment-runs --project-id=""
#get list of Chaos Environments
litmusctl get chaos-experiments --project-id=""
litmusctl get chaos-environments --project-id=""
Note: The default location of the config file is $HOME/.litmusconfig, and can be overridden by a --config flag
`,
Expand Down

0 comments on commit a099141

Please sign in to comment.