eget
eget copied to clipboard
GitLab support and non-public GitHub/GitLab instances
It would be really nice if eget
could support GitLab repositories in addition to GitHub.
In addition, it would be nice if support for private GitHub/GitLab instances can be used as well.
My proposal for these features is two fold. First, refactor the code so it uses repository provider modules that contain types which satisfy a generic Provider
interface with differnet functions needed by eget
. The codebase would then consist of:
- A
Provider
interface with well-defined functions for all operations needed byeget
from each provider.- For example, to list releases, to find and download assets, etc.
- A
GitHubProvider
concrete type that satisfiesProvider
containing all the existing code for the GitHub API. - A
GitLabProvider
concrete type that satisfiesProvider
containing new code for the GitLab API. - Any future provider implementation, for example for Gitea as requested in #61.
Second, define a syntax for the target argument in eget
so a provider and private domain can be specified. For this, the syntax proposed in #61 looks like a good start: [domain/]user/repo
. However there are some considerations to address:
- Not all providers are limited to
user/repo
. GitLab for example supports nested groups such asorg/group/repo
.- For this, I would propose to simply generalize the syntax to
[domain/]path
. - If no
domain
is specified, default to public GitHub to preserve current behavior.
- For this, I would propose to simply generalize the syntax to
- Just by allowing
domain
there is the ambiguity of which provider to use for the requests.- For public instances, each
Provider
can implement aPublicDomains()
function and do a simple check. - For private instances, there are some options to specify the provider to use.
-
eget
could implement an optional--provider
flag (and/or environment variable). - The provider can be incorporated in the target syntax:
[provider:[domain/]]path
- If no
provider
is specified, default to usingdomain
to detect a public instance.
-
- For public instances, each
If you are willing to accept a contribution for all the above, I'm happy to work on it. I would just need your thoughts on the points above so the implementation goes the way you prefer.