Skip to content

Add an API endpoint to generate a CSV compliance report #167

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

Merged

Conversation

yiraeChristineKim
Copy link
Contributor

@yiraeChristineKim yiraeChristineKim commented Feb 1, 2024

Generating a report as described in the design.

Ref: https://issues.redhat.com/browse/ACM-6884

@openshift-ci openshift-ci bot requested review from dhaiducek and gparvin February 1, 2024 14:32
@openshift-ci openshift-ci bot added the approved label Feb 1, 2024
@yiraeChristineKim yiraeChristineKim force-pushed the ACM-6884 branch 2 times, most recently from 825fdd8 to e69ffa9 Compare February 1, 2024 15:24
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.

Looks pretty good overall! Easy to follow.

@yiraeChristineKim
Copy link
Contributor Author

@JustinKuli @mprahl Ready again Thanks!!!

JustinKuli
JustinKuli previously approved these changes Feb 8, 2024
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.

/hold for Matt

LGTM overall! I just had one (almost inconsequential) comment. I didn't check if Matt had any remaining requests.

return vv
case int32:
// All int32 related id
if int(vv) == 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

0 mean id is empty

@yiraeChristineKim
Copy link
Contributor Author

@mprahl @JustinKuli Ready Again! Thanks all

case int32:
// All int32 related id
if int(vv) == 0 {
return "nil"
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 no value is more readable in a spreadsheet.

Suggested change
return "nil"
return ""

Copy link
Contributor Author

@yiraeChristineKim yiraeChristineKim Feb 13, 2024

Choose a reason for hiding this comment

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

How about

 	case JSONMap:
		if vv == nil {
			return "nil"
		}

Since most nil cases change to ""? should we change this too?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think so.

Copy link
Contributor Author

@yiraeChristineKim yiraeChristineKim Feb 13, 2024

Choose a reason for hiding this comment

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

jsonByte, err := json.MarshalIndent(vv, "", " ") output like this:

"{
  ""test"": true
}"

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 in Mac spreadsheet and slack spreadsheet looks fine

{
  "severity": "low",
  "test": "one"
}

return vv.String()
case pq.StringArray:
// nil will be []
return fmt.Sprintf("%v", vv)
Copy link
Member

Choose a reason for hiding this comment

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

Could you do a strings.Join on this so that you get val1, val2. This is more friendly than an array like syntax.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Join with a comma is confusing because CSV is comma-based. Is there any other way??

Copy link
Member

Choose a reason for hiding this comment

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

Does the CSV writer not escape the commas for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

strings.join output is like this:
"cat-3, cat-4"
which looks good to me

return fmt.Sprintf("%v", vv)
default:
// case nil:
return "nil"
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be a programming error if we encounter a type we do not know how to convert?

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 at least, you could return this:

Suggested change
return "nil"
return fmt.Sprintf("%v", vv)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Error looks like this:
,configmaps [common] found in namespace default,

Copy link
Member

@mprahl mprahl left a comment

Choose a reason for hiding this comment

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

Very close!

Copy link

openshift-ci bot commented Feb 13, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mprahl, 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 [mprahl,yiraeChristineKim]

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

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.

4 participants