From a099141dfe8ae94c1da527785c22d536949ebeaa Mon Sep 17 00:00:00 2001 From: Shivam Purohit Date: Fri, 15 Mar 2024 17:42:29 +0530 Subject: [PATCH] improve logic for list environment Signed-off-by: Shivam Purohit --- pkg/cmd/get/environments.go | 20 ++++++++++---------- pkg/cmd/get/get.go | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/cmd/get/environments.go b/pkg/cmd/get/environments.go index 1661487e..31232699 100644 --- a/pkg/cmd/get/environments.go +++ b/pkg/cmd/get/environments.go @@ -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 diff --git a/pkg/cmd/get/get.go b/pkg/cmd/get/get.go index 50bcbc1f..ce7399ae 100644 --- a/pkg/cmd/get/get.go +++ b/pkg/cmd/get/get.go @@ -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 `,