Skip to content

Conversation

yiraeChristineKim
Copy link
Contributor

@yiraeChristineKim yiraeChristineKim commented Feb 4, 2025

isStatusMatch := compareStatusObj(cmd, true, "", inputStatus, resultStatus)

if isStatusMatch {
cmd.Println(successColor("\033[1m Expected status matches the actual status \033[0m"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

bold

Copy link
Member

Choose a reason for hiding this comment

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

If we'll have terminal escapes for bold, I wonder if we should just "manually" do the terminal escapes for the colors ourselves, as opposed to using that library. How much trouble do you think that would it be?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me try I don't think it is big deal

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed Could you check

Copy link
Member

Choose a reason for hiding this comment

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

I think that's looking good. What do you think about a --no-colors option that would turn off those escapes?

@yiraeChristineKim
Copy link
Contributor Author

/cc @JustinKuli

Copy link
Member

@JustinKuli JustinKuli left a comment

Choose a reason for hiding this comment

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

Sorry for the many small comments. Overall this looks really great.

I personally like the colors, but I feel like it's common to give a --no-color option. Especially if this is a tool used in someone's CI, it can be a headache to look at the output with a bunch of terminal escape codes.

I think the exit code of the CLI is still just whether the result is compliant or not... I think we'd want to adjust that so that if the user provided a desired status, the exit code is zero if the status matches.


cmd.Flags().StringVarP(
&d.configStatus,
"config-status",
Copy link
Member

Choose a reason for hiding this comment

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

What do you think of "desired-status"? Would that be more clear?

I just worry that "config-status" makes it sound like it configures some piece of the status somehow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lovely

isStatusMatch := compareStatusObj(cmd, true, "", inputStatus, resultStatus)

if isStatusMatch {
cmd.Println(successColor("\033[1m Expected status matches the actual status \033[0m"))
Copy link
Member

Choose a reason for hiding this comment

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

If we'll have terminal escapes for bold, I wonder if we should just "manually" do the terminal escapes for the colors ourselves, as opposed to using that library. How much trouble do you think that would it be?

}

switch typedV[0].(type) {
case map[interface{}]interface{}, map[string]interface{}:
Copy link
Member

Choose a reason for hiding this comment

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

Isn't map[string]interface{} a sub-case of map[interface{}]interface{}? Is it necessary to make it a specific case?

Copy link
Member

Choose a reason for hiding this comment

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

It seems like other pieces here want to only deal with map[string]interface. So I think that could be made a case on its own, and then if the next case was map[interface{}]interface{}, that would catch the errors all together. Might be cleaner (assuming it actually works like that).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I don’t understand why these are separated—the code would be duplicated. Could you suggest an alternative implementation?


mapObj, ok := convertMapStringKey(obj).(map[string]interface{})
if !ok {
failedParsePrint(cmd, path)
Copy link
Member

Choose a reason for hiding this comment

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

I think we can consider it not a match if we fail to parse something. Warnings are too likely to be ignored in my opinion.

}

func successMatchArrayPrint(cmd *cobra.Command, path string) {
cmd.Println(successColor(fmt.Sprintf("%s is founded", path)))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
cmd.Println(successColor(fmt.Sprintf("%s is founded", path)))
cmd.Println(successColor(fmt.Sprintf("%s matches", path)))

I'm worried this message is very repetitive. Maybe it shouldn't be printed at all?

Copy link
Contributor Author

@yiraeChristineKim yiraeChristineKim Feb 5, 2025

Choose a reason for hiding this comment

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

should we remove

	if !allMatch {
			errorMatchArrayPrint(cmd, path)

			isStatusMatch = false
		} 

This case print too?

isStatusMatch := compareStatusObj(cmd, true, "", inputStatus, resultStatus)

if isStatusMatch {
cmd.Println(successColor("\033[1m Expected status matches the actual status \033[0m"))
Copy link
Member

Choose a reason for hiding this comment

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

I think that's looking good. What do you think about a --no-colors option that would turn off those escapes?

@yiraeChristineKim yiraeChristineKim force-pushed the ACM-17517 branch 2 times, most recently from dbc8f98 to e25fa04 Compare February 6, 2025 15:55
Copy link
Member

@JustinKuli JustinKuli left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks

@openshift-ci openshift-ci bot added the lgtm label Feb 10, 2025
Copy link

openshift-ci bot commented Feb 10, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JustinKuli, yiraeChristineKim

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [JustinKuli,yiraeChristineKim]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit bf7ec7d into open-cluster-management-io:main Feb 10, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants