Add networks, subscribers, and watchers to github input (#6161)
This commit is contained in:
parent
eb0f493998
commit
4e59d51844
|
@ -28,10 +28,13 @@ alternative method for collecting repository information.
|
||||||
- language - The primary language of the repository
|
- language - The primary language of the repository
|
||||||
- license - The license set for the repository
|
- license - The license set for the repository
|
||||||
- fields:
|
- fields:
|
||||||
- stars (int)
|
|
||||||
- forks (int)
|
- forks (int)
|
||||||
- open_issues (int)
|
- open_issues (int)
|
||||||
|
- networks (int)
|
||||||
- size (int)
|
- size (int)
|
||||||
|
- subscribers (int)
|
||||||
|
- stars (int)
|
||||||
|
- watchers (int)
|
||||||
|
|
||||||
When the [internal][] input is enabled:
|
When the [internal][] input is enabled:
|
||||||
|
|
||||||
|
@ -46,7 +49,7 @@ When the [internal][] input is enabled:
|
||||||
### Example Output
|
### Example Output
|
||||||
|
|
||||||
```
|
```
|
||||||
github,full_name=influxdata/telegraf,name=telegraf,owner=influxdata,language=Go,license=MIT\ License stars=6401i,forks=2421i,open_issues=722i,size=22611i 1552651811000000000
|
github_repository,language=Go,license=MIT\ License,name=telegraf,owner=influxdata forks=2679i,networks=2679i,open_issues=794i,size=23263i,stars=7091i,subscribers=316i,watchers=7091i 1563901372000000000
|
||||||
internal_github,access_token=Unauthenticated rate_limit_remaining=59i,rate_limit_limit=60i,rate_limit_blocks=0i 1552653551000000000
|
internal_github,access_token=Unauthenticated rate_limit_remaining=59i,rate_limit_limit=60i,rate_limit_blocks=0i 1552653551000000000
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -168,6 +168,9 @@ func getTags(repositoryInfo *github.Repository) map[string]string {
|
||||||
func getFields(repositoryInfo *github.Repository) map[string]interface{} {
|
func getFields(repositoryInfo *github.Repository) map[string]interface{} {
|
||||||
return map[string]interface{}{
|
return map[string]interface{}{
|
||||||
"stars": repositoryInfo.GetStargazersCount(),
|
"stars": repositoryInfo.GetStargazersCount(),
|
||||||
|
"subscribers": repositoryInfo.GetSubscribersCount(),
|
||||||
|
"watchers": repositoryInfo.GetWatchersCount(),
|
||||||
|
"networks": repositoryInfo.GetNetworkCount(),
|
||||||
"forks": repositoryInfo.GetForksCount(),
|
"forks": repositoryInfo.GetForksCount(),
|
||||||
"open_issues": repositoryInfo.GetOpenIssuesCount(),
|
"open_issues": repositoryInfo.GetOpenIssuesCount(),
|
||||||
"size": repositoryInfo.GetSize(),
|
"size": repositoryInfo.GetSize(),
|
||||||
|
|
|
@ -98,12 +98,17 @@ func TestGetFields(t *testing.T) {
|
||||||
forks := 2
|
forks := 2
|
||||||
openIssues := 3
|
openIssues := 3
|
||||||
size := 4
|
size := 4
|
||||||
|
subscribers := 5
|
||||||
|
watchers := 6
|
||||||
|
|
||||||
repository := gh.Repository{
|
repository := gh.Repository{
|
||||||
StargazersCount: &stars,
|
StargazersCount: &stars,
|
||||||
ForksCount: &forks,
|
ForksCount: &forks,
|
||||||
OpenIssuesCount: &openIssues,
|
OpenIssuesCount: &openIssues,
|
||||||
Size: &size,
|
Size: &size,
|
||||||
|
NetworkCount: &forks,
|
||||||
|
SubscribersCount: &subscribers,
|
||||||
|
WatchersCount: &watchers,
|
||||||
}
|
}
|
||||||
|
|
||||||
getFieldsReturn := getFields(&repository)
|
getFieldsReturn := getFields(&repository)
|
||||||
|
@ -112,8 +117,11 @@ func TestGetFields(t *testing.T) {
|
||||||
|
|
||||||
correctFieldReturn["stars"] = 1
|
correctFieldReturn["stars"] = 1
|
||||||
correctFieldReturn["forks"] = 2
|
correctFieldReturn["forks"] = 2
|
||||||
|
correctFieldReturn["networks"] = 2
|
||||||
correctFieldReturn["open_issues"] = 3
|
correctFieldReturn["open_issues"] = 3
|
||||||
correctFieldReturn["size"] = 4
|
correctFieldReturn["size"] = 4
|
||||||
|
correctFieldReturn["subscribers"] = 5
|
||||||
|
correctFieldReturn["watchers"] = 6
|
||||||
|
|
||||||
require.Equal(t, true, reflect.DeepEqual(getFieldsReturn, correctFieldReturn))
|
require.Equal(t, true, reflect.DeepEqual(getFieldsReturn, correctFieldReturn))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue