-
Notifications
You must be signed in to change notification settings - Fork 46
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
Get chaos environments command #170
Conversation
Suggest if further changes are required. |
@SarthakJain26 @Saranya-jena can I get a review? |
pkg/cmd/get/environment.go
Outdated
environmentList, err := environment.GetEnvironmentList(projectID, credentials); | ||
if err != nil { | ||
if strings.Contains(err.Error(), "permission_denied") { | ||
utils.Red.Println("❌ The specified Project ID doesn't exist.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the message to, "You don't have enough permissions to access this resource"
pkg/cmd/get/environment.go
Outdated
func init() { | ||
GetCmd.AddCommand(ChaosEnvironmentCmd); | ||
ChaosEnvironmentCmd.Flags().String("project-id", "", "Set the project-id to list Chaos Environment from a particular project.") | ||
ChaosEnvironmentCmd.Flags().String("environment-id", "", "Set the environment-id to list Chaos Environment") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ChaosEnvironmentCmd.Flags().String("environment-id", "", "Set the environment-id to list Chaos Environment") | |
ChaosEnvironmentCmd.Flags().String("environment-id", "", "Set the environment-id to get Chaos Environment") |
pkg/cmd/get/environment.go
Outdated
} | ||
func init() { | ||
GetCmd.AddCommand(ChaosEnvironmentCmd); | ||
ChaosEnvironmentCmd.Flags().String("project-id", "", "Set the project-id to list Chaos Environment from a particular project.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ChaosEnvironmentCmd.Flags().String("project-id", "", "Set the project-id to list Chaos Environment from a particular project.") | |
ChaosEnvironmentCmd.Flags().String("project-id", "", "Set the project-id to get Chaos Environment from a particular project.") |
pkg/cmd/list/environment.go
Outdated
environmentList, err := environment.GetEnvironmentList(projectID, credentials); | ||
if err != nil { | ||
if strings.Contains(err.Error(), "permission_denied") { | ||
utils.Red.Println("❌ The specified Project ID doesn't exist.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the message to, "You don't have enough permissions to access this resource"
pkg/cmd/list/list.go
Outdated
var ListCmd = &cobra.Command{ | ||
Use: "list", | ||
Short: `Examples: | ||
#get list of chaos Chaos Experiments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#get list of chaos Chaos Experiments | |
#get list of chaos Chaos Environments |
@shivam-Purohit can you please also share the screen shots of the command and the output |
@shivam-Purohit please add these commands in the readme and usage docs as well |
|
I added these in 0.23.0. Do we need to add in any other versions? i think we do not need that. @SarthakJain26 I fixed all the changes you requested. Let me know if further changes are required. |
@shivam-Purohit , you have displayed the complete response coming from the API which is not a very good user experience. You will have to extract required fields and you can display them in table format. I have attached the screenshot for reference. You can display environmentID, name, createdAt and createdBy fields. Please update the PR accordingly |
hey @SarthakJain26 I am currently getting the response as null in many fields which ig should not. I tried rechecking the API. Is there something I am doing here to retrieve the data? |
@shivam-Purohit Possibly yes. You need to check on what is the graphql request you are sending and then what is the data you are expecting back. While decoding the response from the graphql server you need to check if the struct you are using to decode the response has the required fields or not. |
1be4745
to
2d8cd74
Compare
@SarthakJain26 the error was actually due to query itself which we were sending through api. I changed it a bit for the newcommand. |
Thanks @shivam-Purohit, update output looks awesome |
@SarthakJain26, do we need two separate commands for this, i.e., list and get? Maybe |
@Nageshbansal , by convention, list command can be used to list the resources under the project with required info, and get command can be used to get additional info about a particular resource. We can follow the same in other places as well. |
these are the details we can get from the response. @SarthakJain26 let me know what details you want to add, imo we can add type, description or maybe updated at and updated by. |
@shivam-Purohit you can also add the InfraIDs along with what you mentioned so that it infras within the environment can be linked. |
sure! |
i also added the environment type after the screenshot was taken. Switched the structure to row like as it was overflowing and difficult to manage in table format. Hope this helps @SarthakJain26 |
@shivam-Purohit can you please fix the fmt issues due to which build pipeline is failing and also sign your commits so that DCO can pass. We can then merge the PR |
should I squash the commits into one? |
@shivam-Purohit Squashing the commit is not required ( it will be taken care of while merging) , for now please fix the fmt in go files ( you can use |
Signed-off-by: Shivam Purohit <[email protected]>
99fb654
to
5ceb2ac
Compare
@Nageshbansal my first commit was unsigned i could not find any other way to sign it. So I merged it. If the workflows get approval i can test the changes i just made . I use gofmt -w . that should be able to get rid of the fmt error |
@SarthakJain26 can you run the workflow again ig this should be fine now at least the fmt error |
pkg/cmd/get/environment.go
Outdated
if environmentListData[i].EnvironmentID == environmentID { | ||
intUpdateTime, err := strconv.ParseInt(environmentListData[i].UpdatedAt, 10, 64) | ||
if err != nil { | ||
fmt.Println("Error converting UpdatedAt to int64:", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utils.Red.Println
pkg/cmd/get/environment.go
Outdated
utils.White_B.Print("\nEnter the Project ID: ") | ||
fmt.Scanln(&projectID) | ||
|
||
for projectID == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use if
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I picked it from experiments
get command so the same code is repeated there but doesn't make any sense to put for
and then exit anyway. If
would be a better choice
pkg/cmd/get/environment.go
Outdated
utils.White_B.Print("\nEnter the Environment ID: ") | ||
fmt.Scanln(&environmentID) | ||
|
||
for environmentID == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use if
here?
pkg/cmd/get/environment.go
Outdated
updatedTime := time.Unix(intUpdateTime, 0).String() | ||
intCreatedTime, err := strconv.ParseInt(environmentListData[i].CreatedAt, 10, 64) | ||
if err != nil { | ||
fmt.Println("Error converting CreatedAt to int64:", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utils.Red.Println
Please make the changes suggested by @Jonsy13 . Rest all looks good. 🚀 |
Signed-off-by: Shivam Purohit <[email protected]>
@Jonsy13 @Saranya-jena I made the changes suggested you can take a look. Suggest if any further changes needs to be done. |
@shivam-Purohit please fix the build pipeline |
Signed-off-by: Shivam Purohit <[email protected]>
@SarthakJain26 fixed the fmt error. Hope it resolves the build workflow |
Looks like it worked! |
refers issue #164
Addition of new commands :