- given an username, say whether the user is an owner in any repo in the kubernetes organizations
- the username should not be marked as an owner if the user shows up only in
kubernetes-sigs/contributot-playground
's OWNERS files
From cs.k8s.io
, it is seen that we can get the OWNER stats for an user from this URL:
https://cs.k8s.io/api/v1/search?stats=fosho&repos=*&rng=%3A20&q=<username>&i=fosho&files=OWNERS
This gives us a response of the format:
{
"Results": {
"Matches": {
...
}
},
"Stats": {
"FilesOpened": <a number>,
"Duration: NN
}
}
We can see if an user is an owner by looking at the value of .Stats.FileOpened
above. For owners, it is non-zero.
But, there is a small caveat, we also want exclude users who are owners in kubernetes-sigs/contributor-playground
.
For counting the number of appearances, we can query https://cs.k8s.io/api/v1/search?stats=fosho&repos=kubernetes-sigs%2Fcontributor-playground&rng=%3A20&q=<username>&i=fosho&files=OWNERS
So, we can safely say that a user can tagged as an OWNER if the number of OWNER files the username appears in ALL
repositories from the first query is more than the number of OWNER files the username appears in kubernetes-sigs/contributor-playground
.
An example is shown below:
GitHub | All Appearances | Playground Apperances | All count | Playground count | Owner |
---|---|---|---|---|---|
mrbobbytables | https://cs.k8s.io/api/v1/search?stats=fosho&repos=*&rng=%3A20&q=mrbobbytables&i=fosho&files=OWNERS | https://cs.k8s.io/api/v1/search?stats=fosho&repos=kubernetes-sigs%2Fcontributor-playground&rng=%3A20&q=mrbobbytables&files=OWNERS&i=fosho | 16 | 0 | Yes |
palnabarun | https://cs.k8s.io/api/v1/search?stats=fosho&repos=*&rng=%3A20&q=palnabarun&i=fosho&files=OWNERS | https://cs.k8s.io/api/v1/search?stats=fosho&repos=kubernetes-sigs%2Fcontributor-playground&rng=%3A20&q=palnabarun&files=OWNERS&i=fosho | 0 | 0 | No |
In order to fetch JSON data from URL's, we use the Google App Script from here
To get the appearance count, the formula used is:
=VALUE(ImportJSON(<all_url>, "/Stats/FileOpened", "noHeaders"))
The final formula to determine if the user is an OWNER becomes:
=IF(VALUE(ImportJSON(<all_url>, "/Stats/FilesOpened", "noHeaders")) > VALUE(ImportJSON(<playground_url>, "/Stats/FilesOpened", "noHeaders")), "Yes", "No")
where:
all_url:
https://cs.k8s.io/api/v1/search?stats=fosho&repos=*&rng=%3A20&q=mrbobbytables&i=fosho&files=OWNERS
playground_url:
https://cs.k8s.io/api/v1/search?stats=fosho&repos=kubernetes-sigs%2Fcontributor-playground&rng=%3A20&q=mrbobbytables&files=OWNERS&i=fosho
The above URL's can be templated with the username's in each row.