Skip to content

Commit

Permalink
fix:fmt
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 5, 2024
1 parent 900d771 commit 22f1d1d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
5 changes: 2 additions & 3 deletions pkg/apis/probe/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -60,4 +59,4 @@ func ListProbeRequest(pid string, probetypes []* models.ProbeType, cred types.Cr
return ListProbeResponse{}, errors.New("Unmatched status code:" + string(bodyBytes))
}

}
}
1 change: 0 additions & 1 deletion pkg/apis/probe/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ const (
}
`
)

8 changes: 4 additions & 4 deletions pkg/apis/probe/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
28 changes: 15 additions & 13 deletions pkg/cmd/get/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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{
Expand Down Expand Up @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -141,7 +143,7 @@ var probesCmd = &cobra.Command{
// Move to the next page
page++
}
},
},
}

func init() {
Expand All @@ -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")
}
}

0 comments on commit 22f1d1d

Please sign in to comment.