Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for garage.github.com #85

Merged
merged 2 commits into from Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/api/gql_client.go
Expand Up @@ -111,6 +111,9 @@ type gqlResponse struct {
}

func gqlEndpoint(host string) string {
if isGarage(host) {
return fmt.Sprintf("https://%s/api/graphql", host)
}
host = normalizeHostname(host)
if isEnterprise(host) {
return fmt.Sprintf("https://%s/api/graphql", host)
Expand Down
4 changes: 4 additions & 0 deletions internal/api/http.go
Expand Up @@ -109,6 +109,10 @@ func isSameDomain(requestHost, domain string) bool {
return (requestHost == domain) || strings.HasSuffix(requestHost, "."+domain)
}

func isGarage(host string) bool {
return strings.EqualFold(host, "garage.github.com")
}

func isEnterprise(host string) bool {
return host != github && host != localhost
}
Expand Down
3 changes: 3 additions & 0 deletions internal/api/rest_client.go
Expand Up @@ -117,6 +117,9 @@ func restURL(hostname string, pathOrURL string) string {
}

func restPrefix(hostname string) string {
if isGarage(hostname) {
return fmt.Sprintf("https://%s/api/v3/", hostname)
}
hostname = normalizeHostname(hostname)
if isEnterprise(hostname) {
return fmt.Sprintf("https://%s/api/v3/", hostname)
Expand Down