Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add get/list probe command #204

Merged
merged 18 commits into from
Mar 29, 2024
Merged

Conversation

shivam-Purohit
Copy link
Contributor

closes #176

This will add a new command to litmusctl that will enable the user to get the created probes in a given project

@shivam-Purohit
Copy link
Contributor Author

there seems to be some permission issue in pre-commit file
@aryan-bhokare can you check that out?

@aryan-bhokare
Copy link
Contributor

there seems to be some permission issue in pre-commit file @aryan-bhokare can you check that out?

Yep I'll check that. We have to manually give permissions I'll check to automate it.

@shivam-Purohit shivam-Purohit changed the title add get probe command add get/list probe command Mar 7, 2024
@shivam-Purohit
Copy link
Contributor Author

shivam-Purohit commented Mar 7, 2024

two things:

  1. I cannot get the last row to align properly. I dont know exactly how to do that, i tried a bunch of combination
  2. the probes arent getting filtered based on probeType I tried k8sprobe filter but its giving me all the http type ones. idk why

@shivam-Purohit
Copy link
Contributor Author

./litmusctl get probes --project-id="8adf62d5-64f8-4c66-ab53-63729db9dd9a"

✔ Yes

You chose "Yes"

✔ cmdProbe

✔ done

Selected Probe Types: [cmdProbe]

PROBE ID		 PROBE TYPE		 CREATED AT		 CREATED BY

http probe test		httpProbe		admin		56047-11-12 19:12:28 +0530 IST

shivam			httpProbe		admin		56053-01-12 22:58:59 +0530 IST

shivamtest		httpProbe		admin		56140-09-13 09:17:28 +0530 IST

newhttp		httpProbe		admin		56142-12-05 08:29:41 +0530 IST

✔ Press Enter to show more probes (or type 'q' to quit): q█


./litmusctl get probes --project-id="8adf62d5-64f8-4c66-ab53-63729db9dd9a" --non-interactive=true --probe-types="k8sProbe, promProbe"

PROBE ID		 PROBE TYPE		 CREATED AT		 CREATED BY

http probe test		httpProbe		admin		56047-11-12 19:12:28 +0530 IST

shivam			httpProbe		admin		56053-01-12 22:58:59 +0530 IST

shivamtest		httpProbe		admin		56140-09-13 09:17:28 +0530 IST

newhttp		httpProbe		admin		56142-12-05 08:29:41 +0530 IST

Press Enter to show more probes (or type 'q' to quit): q

@shivam-Purohit
Copy link
Contributor Author

./litmusctl get probes --project-id="8adf62d5-64f8-4c66-ab53-63729db9dd9a" 

✔ Yes

You chose "Yes"

✔ cmdProbe

✔ promProbe

✔ done

Selected Probe Types: [cmdProbe promProbe]

PROBE ID		 PROBE TYPE		 CREATED AT		 CREATED BY

No more probes to display
./litmusctl get probes --project-id="8adf62d5-64f8-4c66-ab53-63729db9dd9a" 

✔ Yes

You chose "Yes"

✔ httpProbe

✔ promProbe

✔ done

Selected Probe Types: [httpProbe promProbe]

PROBE ID		 PROBE TYPE		 CREATED AT		 CREATED BY

http probe test		httpProbe		admin		56047-11-12 19:12:28 +0530 IST

shivamtest		httpProbe		admin		56140-09-13 09:17:28 +0530 IST

newhttp		httpProbe		admin		56142-12-05 08:29:41 +0530 IST

Press Enter to show more probes (or type 'q' to quit): 

No more probes to display

utils.White.Fprintln(writer, "CREATED BY\t", probeGetData.CreatedBy.Username)
utils.White.Fprintln(writer, "UPDATED AT\t", updatedTime)
utils.White.Fprintln(writer, "UPDATED BY\t", probeGetData.UpdatedBy.Username)
utils.White.Fprintln(writer, "TAGS\t", strings.Join(probeGetData.Tags, ", "))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we print all properties for a specific probe type, for e.g if HTTP probe prints URL, Criteria etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

printed all the properties for different probe types

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please share a screenshot for this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

./litmusctl get probes --project-id="8adf62d5-64f8-4c66-ab53-63729db9dd9a" --probe-id="shivamcmd"

PROBE DETAILS

PROBE ID 			 shivamcmd

PROBE DESCRIPTION 		 

PROBE TYPE 			 cmdProbe

PROBE INFRASTRUCTURE TYPE 	 Kubernetes

TIMEOUT 			 1s

INTERVAL 			 1s

CREATED AT			 56175-10-19 08:28:39 +0530 IST

CREATED BY			 admin

UPDATED AT			 56175-10-19 08:28:39 +0530 IST

UPDATED BY			 admin

TAGS				 

./litmusctl get probes --project-id="8adf62d5-64f8-4c66-ab53-63729db9dd9a"

✔ No

You chose "No"

PROBE ID		 PROBE TYPE		 CREATED AT		 CREATED BY

http probe test		httpProbe		admin		56047-11-12 19:12:28 +0530 IST

newhttp		httpProbe		admin		56142-12-05 08:29:41 +0530 IST

shivam99		httpProbe		admin		56175-07-01 21:35:07 +0530 IST

shivamcmd		cmdProbe		admin		56175-10-19 08:28:39 +0530 IST

shivamcmd1		cmdProbe		admin		56176-02-14 18:40:30 +0530 IST

Press Enter to show more probes (or type 'q' to quit): q

pkg/cmd/get/get.go Outdated Show resolved Hide resolved

var probesCmd = &cobra.Command{
Use: "probes",
Short: "Display list of probes",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can write this: "Display a list or a specific probe"
WDYT @SarthakJain26 ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "Details of a specific probe" we can avoid using "list"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, sounds good

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but we are now majorly listing the probes and giving few details if passed probe_id. We are using describe for that right?

}
ProbeID, err := cmd.Flags().GetString("probe-id")

if ProbeID == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shivam-Purohit , please try to split the functions into multiple small functions, it will help in reducing the cognitive complexity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done PTAL

@shivam-Purohit
Copy link
Contributor Author

shivam-Purohit commented Mar 21, 2024

its failing as soon as i rebased the master. But was working fine on local. what should i do?

Edit : fixed

Signed-off-by: Shivam Purohit <shivampurohit900@gmail.com>
Signed-off-by: Shivam Purohit <shivampurohit900@gmail.com>
Signed-off-by: Shivam Purohit <shivampurohit900@gmail.com>
Signed-off-by: Shivam Purohit <shivampurohit900@gmail.com>
Signed-off-by: Shivam Purohit <shivampurohit900@gmail.com>
Signed-off-by: Shivam Purohit <shivampurohit900@gmail.com>
Signed-off-by: Shivam Purohit <shivampurohit900@gmail.com>
Signed-off-by: Shivam Purohit <shivampurohit900@gmail.com>
Signed-off-by: Shivam Purohit <shivampurohit900@gmail.com>
Signed-off-by: Shivam Purohit <shivampurohit900@gmail.com>
Signed-off-by: Shivam Purohit <shivampurohit900@gmail.com>
Signed-off-by: Shivam Purohit <shivampurohit900@gmail.com>
Signed-off-by: Shivam Purohit <shivampurohit900@gmail.com>
Signed-off-by: Shivam Purohit <shivampurohit900@gmail.com>
Signed-off-by: Shivam Purohit <shivampurohit900@gmail.com>
kubernetesHTTPProperties{
probeTimeout
interval
retry
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we using all the properties? If not, then we can consider removing them from query

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 BY\t CREATED AT")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have referencedBy also here ( as we also show this UI Overview )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done you can take a look

Signed-off-by: Shivam Purohit <shivampurohit900@gmail.com>
Signed-off-by: Shivam Purohit <shivampurohit900@gmail.com>
Signed-off-by: Shivam Purohit <shivampurohit900@gmail.com>
@SarthakJain26 SarthakJain26 merged commit 6b276da into litmuschaos:master Mar 29, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Will the litmusctl to support create/list/delete probe?
4 participants