-
Notifications
You must be signed in to change notification settings - Fork 21
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
🐛 Check GitHub RequiredPullRequestReviews before access #845
Conversation
Fixes #mondoohq/cnspec#289 Signed-off-by: Christian Zunker <[email protected]>
Users: []string{}, | ||
Teams: []string{}, | ||
} | ||
rprr, err := core.JsonToDict(githubRequiredPullRequestReviews{}) |
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.
why do you not initialize this as nil
? It's making the code shorter and it won't do unnecessary work of serializing stuff.
rprr, err := core.JsonToDict(githubRequiredPullRequestReviews{}) | |
var rprr map[string]interface{} |
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.
Good point. Thanks.
ghDismissalRestrictions.Users = append(ghDismissalRestrictions.Users, branchProtection.RequiredPullRequestReviews.DismissalRestrictions.Users[i].GetLogin()) | ||
if branchProtection.RequiredPullRequestReviews.DismissalRestrictions != nil { | ||
ghDismissalRestrictions = &githubDismissalRestrictions{ | ||
Users: []string{}, |
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.
nit: when possible I try to initialize slices with the correct size beforehand. This makes memory allocation a bit more efficient since the underlying array doesn't need to be extended and copied in memory.
Users: []string{}, | |
Users: make([]string{}, 0, len(branchProtection.RequiredPullRequestReviews.DismissalRestrictions.Users)), |
This means create a slice with length 0 with an underlying array of size len(branchProtection...)
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.
Changed.
Signed-off-by: Christian Zunker <[email protected]>
Fixes mondoohq/cnspec#289
Signed-off-by: Christian Zunker [email protected]