From f44e8840ea020efc2de3501944d8f9a4f5bd28e1 Mon Sep 17 00:00:00 2001 From: Sarthak Jain Date: Tue, 16 Aug 2022 15:15:59 +0530 Subject: [PATCH] Fixed "index out of bound issue" in describe chaos-scenario command (#90) * Fixed out of bound issue in describe chaos-scenario command Signed-off-by: Sarthak Jain * reverted compatibility matrix version changes Signed-off-by: Sarthak Jain Signed-off-by: Sarthak Jain --- pkg/cmd/describe/workflow.go | 5 +++++ pkg/utils/compatibility.go | 14 ++++++++++++++ pkg/utils/constants.go | 13 ------------- 3 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 pkg/utils/compatibility.go diff --git a/pkg/cmd/describe/workflow.go b/pkg/cmd/describe/workflow.go index fba33836..edab1539 100644 --- a/pkg/cmd/describe/workflow.go +++ b/pkg/cmd/describe/workflow.go @@ -69,6 +69,11 @@ var workflowCmd = &cobra.Command{ workflow, err := apis.GetWorkflowList(describeWorkflowRequest, credentials) utils.PrintError(err) + if len(workflow.Data.ListWorkflowDetails.Workflows) == 0 { + utils.Red.Println("⛔ No chaos scenarios found with ID: ", workflowID) + os.Exit(1) + } + yamlManifest, err := yaml.JSONToYAML([]byte(workflow.Data.ListWorkflowDetails.Workflows[0].WorkflowManifest)) if err != nil { utils.Red.Println("❌ Error parsing Chaos Scenario manifest: " + err.Error()) diff --git a/pkg/utils/compatibility.go b/pkg/utils/compatibility.go new file mode 100644 index 00000000..8d46087e --- /dev/null +++ b/pkg/utils/compatibility.go @@ -0,0 +1,14 @@ +package utils + +var ( + // CompatibilityMatrix to store the compatible versions of litmusctl and ChaosCenter + CompatibilityMatrix = map[string][]string{ + "0.6.0": {"2.2.0", "2.3.0"}, + "0.7.0": {"2.4.0", "2.5.0", "2.6.0", "2.7.0", "2.8.0"}, + "0.8.0": {"2.4.0", "2.5.0", "2.6.0", "2.7.0", "2.8.0"}, + "0.9.0": {"2.4.0", "2.5.0", "2.6.0", "2.7.0", "2.8.0"}, + "0.10.0": {"2.9.0", "2.10.0", "2.11.0", "2.12.0"}, + "0.11.0": {"2.9.0", "2.10.0", "2.11.0", "2.12.0"}, + "0.12.0": {"2.9.0", "2.10.0", "2.11.0", "2.12.0"}, + } +) diff --git a/pkg/utils/constants.go b/pkg/utils/constants.go index 5d11ba4b..b4013d10 100644 --- a/pkg/utils/constants.go +++ b/pkg/utils/constants.go @@ -62,16 +62,3 @@ const ( // Auth server api path AuthAPIPath = "/auth" ) - -var ( - // CompatibilityMatrix to store the compatible versions of litmusctl and ChaosCenter - CompatibilityMatrix = map[string][]string{ - "0.6.0": {"2.2.0", "2.3.0"}, - "0.7.0": {"2.4.0", "2.5.0", "2.6.0", "2.7.0", "2.8.0"}, - "0.8.0": {"2.4.0", "2.5.0", "2.6.0", "2.7.0", "2.8.0"}, - "0.9.0": {"2.4.0", "2.5.0", "2.6.0", "2.7.0", "2.8.0"}, - "0.10.0": {"2.9.0", "2.10.0", "2.11.0", "2.12.0"}, - "0.11.0": {"2.9.0", "2.10.0", "2.11.0", "2.12.0"}, - "0.12.0": {"2.9.0", "2.10.0", "2.11.0", "2.12.0"}, - } -)