aquaproj / aqua

Declarative CLI Version manager written in Go. Support Lazy Install, Registry, and continuous update with Renovate. CLI version is switched seamlessly
https://aquaproj.github.io
752 stars 32 forks source link

Support GitHub Enterprise Server #2729

Open suzuki-shunsuke opened 3 months ago

suzuki-shunsuke commented 3 months ago

Feature Overview

Support Registries and packages hosted at GitHub Enterprise Servers.

Why is the feature needed?

Some users use GitHub Enterprise Servers and host internal tools. It would be nice that they can host private Registries and distribute their tools with aqua.

Workaround

No response

Example Code

registry.yaml

Add .hosts and .packages[].host.

hosts:
- name: example
  github_enterprise:
    base_url: htttps://example.com
    upload_url: htttps://example.com
packages:
- type: github_release
  host: example
  repo_owner: aquaproj
  repo_name: example

aqua.yaml

Add .hosts and .registries[].host.

hosts:
  - name: example
    github_enterprise:
      base_url: htttps://example.com
      upload_url: htttps://example.com
      token_envs:
        - GH_ENTERPRISE_TOKEN
    hosts:
      - name: example
        token_envs:
          - GH_ENTERPRISE_TOKEN
registries:
  - name: foo
    type: github_content
    host: example
    repo_owner: aquaproj
    repo_name: aqua-registry
    ref: v3.90.0
    path: registry.yaml

Note

This issue is based on the discussion https://github.com/orgs/aquaproj/discussions/2726#discussioncomment-8713641 .

https://pkg.go.dev/github.com/google/go-github/v60/github#Client.WithEnterpriseURLs

WithEnterpriseURLs returns a copy of the client configured to use the provided base and upload URLs. If the base URL does not have the suffix "/api/v3/", it will be added automatically. If the upload URL does not have the suffix "/api/uploads", it will be added automatically.

Note that WithEnterpriseURLs is a convenience helper only; its behavior is equivalent to setting the BaseURL and UploadURL fields.

Another important thing is that by default, the GitHub Enterprise URL format should be http(s)://[hostname]/api/v3/ or you will always receive the 406 status code. The upload URL format should be http(s)://[hostname]/api/uploads/.

bhundven commented 3 months ago

If there is anything I can test, I would be very happy to do so!