src-d / ghsync

GitHub API v3 > PostgreSQL
https://sourced.tech
GNU General Public License v3.0
9 stars 8 forks source link

ghsync fails when running `sourced init local` #54

Closed dpordomingo closed 5 years ago

dpordomingo commented 5 years ago

https://github.com/src-d/gitcollector/issues/64

When source{d} CE is inited with a local workdir, shsync is started and then it fails fast because it was not passed an org.

$ export GHSYNC_POSTGRES_DB=metadata
$ export GHSYNC_POSTGRES_USER=metadata
$ export GHSYNC_POSTGRES_PASSWORD=metadata
$ export GHSYNC_POSTGRES_HOST=127.0.0.1
$ export GHSYNC_POSTGRES_PORT=5433
$ export GHSYNC_TOKEN=
$ export GHSYNC_ORGS=
$ ghsync shallow
INFO connection with the DB established
INFO status table 'status' created
GET https://api.github.com/orgs/: 401 Bad credentials []

It should have the same behavior than gitcollector, and imo it should be the following: if an empty org is passed, it should exit 0 (as gitcollector does), and log a warning, e.g. no organizations to scrape

carlosms commented 5 years ago

This is tricky, because what you describe is more convenient from the sourced-ce point of view. But from the point of view of ghsync, it's correct to fail when a mandatory argument is not given.

smacker commented 5 years ago

+1 for failing without argument

dpordomingo commented 5 years ago

There is no expected external use case for ghsync, and the proposed one https://github.com/src-d/ghsync/pull/56 follows the same approach as implemented in gitcollector.

Also it might be reasonable that if you ask ghsync to collect data from a list of orgs, and the list is empty, then it will return: ok, I collected data for the list of orgs that you passed me, same as when it returns nothing to update.

On the other hand, forcing source{d} CE to handle this use case can be not that trivial.