From 22f1d1d13ec0d0a0259929af08e5e2c1b119a906 Mon Sep 17 00:00:00 2001 From: Shivam Purohit Date: Tue, 5 Mar 2024 19:56:05 +0530 Subject: [PATCH] fix:fmt Signed-off-by: Shivam Purohit --- pkg/apis/probe/probe.go | 5 ++--- pkg/apis/probe/query.go | 1 - pkg/apis/probe/types.go | 8 ++++---- pkg/cmd/get/probe.go | 28 +++++++++++++++------------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/pkg/apis/probe/probe.go b/pkg/apis/probe/probe.go index a0c173ba..9daa14d4 100644 --- a/pkg/apis/probe/probe.go +++ b/pkg/apis/probe/probe.go @@ -6,14 +6,13 @@ import ( "io" "net/http" - models "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" "github.com/litmuschaos/litmusctl/pkg/apis" "github.com/litmuschaos/litmusctl/pkg/types" "github.com/litmuschaos/litmusctl/pkg/utils" ) -func ListProbeRequest(pid string, probetypes []* models.ProbeType, cred types.Credentials) (ListProbeResponse, error) { +func ListProbeRequest(pid string, probetypes []*models.ProbeType, cred types.Credentials) (ListProbeResponse, error) { var gqlReq ListProbeGQLRequest gqlReq.Query = ListProbeQuery gqlReq.Variables.ProjectID = pid @@ -60,4 +59,4 @@ func ListProbeRequest(pid string, probetypes []* models.ProbeType, cred types.Cr return ListProbeResponse{}, errors.New("Unmatched status code:" + string(bodyBytes)) } -} \ No newline at end of file +} diff --git a/pkg/apis/probe/query.go b/pkg/apis/probe/query.go index b40212f7..9a8939f0 100644 --- a/pkg/apis/probe/query.go +++ b/pkg/apis/probe/query.go @@ -14,4 +14,3 @@ const ( } ` ) - diff --git a/pkg/apis/probe/types.go b/pkg/apis/probe/types.go index c60af906..36edac99 100644 --- a/pkg/apis/probe/types.go +++ b/pkg/apis/probe/types.go @@ -5,10 +5,10 @@ import model "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/mod type ListProbeGQLRequest struct { Query string `json:"query"` Variables struct { - ProjectID string `json:"projectID"` - InfrastructureType *model.InfrastructureType `json:"infrastructureType"` - ProbeNames []string `json:"probeNames"` - Filter model.ProbeFilterInput `json:"probeFilterInput"` + ProjectID string `json:"projectID"` + InfrastructureType *model.InfrastructureType `json:"infrastructureType"` + ProbeNames []string `json:"probeNames"` + Filter model.ProbeFilterInput `json:"probeFilterInput"` } `json:"variables"` } diff --git a/pkg/cmd/get/probe.go b/pkg/cmd/get/probe.go index adea93b1..c50d3fe8 100644 --- a/pkg/cmd/get/probe.go +++ b/pkg/cmd/get/probe.go @@ -3,7 +3,9 @@ Copyright © 2021 The LitmusChaos Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,11 +21,11 @@ import ( "text/tabwriter" "time" - apis "github.com/litmuschaos/litmusctl/pkg/apis/probe" models "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" + apis "github.com/litmuschaos/litmusctl/pkg/apis/probe" "github.com/litmuschaos/litmusctl/pkg/utils" - "github.com/spf13/cobra" "github.com/manifoldco/promptui" + "github.com/spf13/cobra" ) var probesCmd = &cobra.Command{ @@ -58,9 +60,9 @@ var probesCmd = &cobra.Command{ return } fmt.Printf("You chose %q\n", option) - var selectedItems []* models.ProbeType + var selectedItems []*models.ProbeType if option == "Yes" { - items := [] models.ProbeType{"httpProbe", "cmdProbe", "promProbe", "k8sProbe", "done"} + items := []models.ProbeType{"httpProbe", "cmdProbe", "promProbe", "k8sProbe", "done"} for { prompt := promptui.Select{ Label: "Select ProbeType", @@ -77,30 +79,30 @@ var probesCmd = &cobra.Command{ fmt.Printf("Prompt failed %v\n", err) os.Exit(1) } - + if items[selectedIndex] == "done" { break } - + final := models.ProbeType(result) selectedItems = append(selectedItems, &final) items = append(items[:selectedIndex], items[selectedIndex+1:]...) } - + fmt.Printf("Selected Probe Types: %v\n", selectedItems) - } - + } + probes_get, _ := apis.ListProbeRequest(projectID, selectedItems, credentials) probes_data := probes_get.Data.Probes itemsPerPage := 5 page := 1 totalProbes := len(probes_data) - + writer := tabwriter.NewWriter(os.Stdout, 8, 8, 8, '\t', tabwriter.AlignRight) utils.White_B.Fprintln(writer, "PROBE ID\t PROBE TYPE\t CREATED AT\t CREATED BY") - + for { writer.Flush() // calculating the start and end indices for the current page @@ -141,7 +143,7 @@ var probesCmd = &cobra.Command{ // Move to the next page page++ } -}, + }, } func init() { @@ -150,4 +152,4 @@ func init() { probesCmd.Flags().String("project-id", "", "Set the project-id to get Probe from a particular project.") probesCmd.Flags().String("non-intereactive-mode", "", "Set the non-intereactive-mode to true to false to pass probetype value as a flag") probesCmd.Flags().String("probe-types", "", "Set the probe-types as comma separated values to filter the probes") -} \ No newline at end of file +}