-
Notifications
You must be signed in to change notification settings - Fork 26
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add github_code_owner table from .CODEOWNERS file in a repository #200
feat: add github_code_owner table from .CODEOWNERS file in a repository #200
Conversation
Hey @aminvielledebatAtBedrock , thanks for working on this PR! I think adding a way to get information from a repo's CODEOWNERS makes sense. GitHub treats the CODEOWNERS file as a key file, so I'm thinking maybe this could be a new table entirely, instead of being hidden among the other columns in a repo. If it were a table, it'd also be easier to query, with one line in the file per row instead of in a large JSON value. I think a suitable table name would be
If you have any questions, please let me know, thanks! |
Good point for the new table @cbruno10 . I will add it ! About comments, what's the difference between head_coment and pre_comment for you ? IMO, it's the same thing 馃槩
Do you think Last point about Thanks for your support ! |
@aminvielledebatAtBedrock - I agree with your comments about the Also, for the example you pasted, I believe yes, the values for the |
fbd4f3b
to
d6003a8
Compare
馃檹 thank you so much for your responses @cbruno10 ! func gitHubCodeOwnerColumns() []*plugin.Column {
return []*plugin.Column{
// Top columns
{Name: "full_name", Type: proto.ColumnType_STRING, Description: "The full name of the repository, including the owner and repo name."},
// Other columns
{Name: "pattern", Type: proto.ColumnType_STRING, Description: "The pattern used to identify what code a team, or an individual is responsible for"},
{Name: "users", Type: proto.ColumnType_JSON, Description: "Users responsible for code in the repo", Transform: transform.FromField("Users")},
{Name: "teams", Type: proto.ColumnType_JSON, Description: "Teams responsible for code in the repo", Transform: transform.FromField("Teams")},
{Name: "comments", Type: proto.ColumnType_JSON, Description: "Specifies the comments added above a key.", Transform: transform.FromField("Comments")},
}
} I also removed line comments because i don't see any example in the documentation, or in If everything looks good to you, I can add the missing documentation. |
@aminvielledebatAtBedrock Thanks for the quick changes! I think it'd still be good to have the Also, can you please rename |
c99f7a3
to
9b37c68
Compare
You're absolutely right @cbruno10 ! I didn't see this blog post and this new feature.
Feel free to ask me other changes 馃憤 |
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.
@aminvielledebatAtBedrock Please see additional suggestions/questions, thanks!
docs/tables/github_code_owner.md
Outdated
### Get All your CodeOwners rules about a specific repository | ||
|
||
```sql | ||
select |
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.
@aminvielledebatAtBedrock Can you please format this query using https://www.freeformatter.com/sql-formatter.html? There's more information about our doc example standards in https://steampipe.io/docs/develop/table-docs-standards#style-conventions-1.
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.
Thanks for the links !
docs/tables/github_code_owner.md
Outdated
,teams | ||
,pre_comments | ||
,line_comment | ||
from github.github_code_owner where repository_full_name = 'my-orga/code-owners' |
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.
from github.github_code_owner where repository_full_name = 'my-orga/code-owners' | |
from github_code_owner where repository_full_name = 'my-orga/code-owners' |
For examples, we usually don't include the connection name, just the table name is sufficient (you can run queries like this too).
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.
Sorry about that, you're right. Fixed
github/table_github_code_owner.go
Outdated
client := connect(ctx, d) | ||
opt := &github.RepositoryContentGetOptions{} | ||
// stop on the first found CODEOWNERS file | ||
var paths = []string{"CODEOWNERS", ".github/CODEOWNERS", "docs/CODEOWNERS"} |
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 a repo have multiple CODEOWNERS files (even in GitHub throws up warnings in the UI)? If so, which one is used by the table (looks like it's the order defined in the array)? Is there a precedence that GitHub has on which CODEOWNERS file it will use?
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 did some tests on a repo : there is no composition between files (some rules from a file, and others from another) and there is a precedence :
.github/CODEOWNERS
CODEOWNERS
docs/CODEOWNERS
I changed my code to respect this order.
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.
Thanks for checking @aminvielledebatAtBedrock , can you please also include a comment that has a link where it specifies this for future reference?
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.
Comment added !
Thanks for the review !
1d9d1fd
to
790c7c2
Compare
790c7c2
to
1464037
Compare
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.
@aminvielledebatAtBedrock Thanks again for the quick updates! I left one more round of suggestions, but I believe after these are addressed, the PR will be ready for merge. Thanks!
docs/tables/github_code_owner.md
Outdated
pre_comments, | ||
line_comment | ||
from | ||
github.github_code_owner |
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.
github.github_code_owner | |
github_code_owner |
docs/tables/github_code_owner.md
Outdated
from | ||
github.github_code_owner | ||
where | ||
repository_full_name = 'my-orga/code-owners' |
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.
repository_full_name = 'my-orga/code-owners' | |
repository_full_name = 'github/docs' |
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 think linking to a real example instead of having users search out repos with a CODEOWNERS file will make it easier for users to use this table and understand's returned
github/table_github_code_owner.go
Outdated
|
||
//// TABLE DEFINITION | ||
|
||
func tableGithubCodeOwner() *plugin.Table { |
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.
func tableGithubCodeOwner() *plugin.Table { | |
func tableGitHubCodeOwner() *plugin.Table { |
1464037
to
d2bd67f
Compare
d2bd67f
to
b4aa1fd
Compare
@aminvielledebatAtBedrock Thanks again so much for submitting this PR and putting up with all of my reviews 馃槄 We're doing another GitHub plugin release later this week, so this table will be included in it. |
@cbruno10 Thanks again for your support and your patience 馃槅 For the github release : i'm working on another table if you're interested : |
Description
Capture the content of .CODEOWNERS file (in root, or in .github or docs directories), and expose it in a new table
How
Use the Github API
client.Repositories.GetContents
Example query results
Results
Dod
Unit tests are written and everything is fine(don't find any test in this repo 馃槩)