eget icon indicating copy to clipboard operation
eget copied to clipboard

GitLab support and non-public GitHub/GitLab instances

Open hhromic opened this issue 8 months ago • 3 comments

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 by eget from each provider.
    • For example, to list releases, to find and download assets, etc.
  • A GitHubProvider concrete type that satisfies Provider containing all the existing code for the GitHub API.
  • A GitLabProvider concrete type that satisfies Provider 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 as org/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.
  • Just by allowing domain there is the ambiguity of which provider to use for the requests.
    • For public instances, each Provider can implement a PublicDomains() 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 using domain to detect a public instance.

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.

hhromic avatar Oct 21 '23 12:10 hhromic