Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/cenkalti/backoff/v4 v4.3.0
github.com/charmbracelet/glamour v0.7.0
github.com/charmbracelet/lipgloss v0.10.1-0.20240413172830-d0be07ea6b9c
github.com/cli/go-gh/v2 v2.9.0
github.com/cli/go-gh/v2 v2.10.0
github.com/cli/oauth v1.0.1
github.com/cli/safeexec v1.0.1
github.com/cpuguy83/go-md2man/v2 v2.0.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ github.com/charmbracelet/x/exp/term v0.0.0-20240425164147-ba2a9512b05f/go.mod h1
github.com/cli/browser v1.0.0/go.mod h1:IEWkHYbLjkhtjwwWlwTHW2lGxeS5gezEQBMLTwDHf5Q=
github.com/cli/browser v1.3.0 h1:LejqCrpWr+1pRqmEPDGnTZOjsMe7sehifLynZJuqJpo=
github.com/cli/browser v1.3.0/go.mod h1:HH8s+fOAxjhQoBUAsKuPCbqUuxZDhQ2/aD+SzsEfBTk=
github.com/cli/go-gh/v2 v2.9.0 h1:D3lTjEneMYl54M+WjZ+kRPrR5CEJ5BHS05isBPOV3LI=
github.com/cli/go-gh/v2 v2.9.0/go.mod h1:MeRoKzXff3ygHu7zP+NVTT+imcHW6p3tpuxHAzRM2xE=
github.com/cli/go-gh/v2 v2.10.0 h1:GMflBKoErBXlLvN2euxzL+p7JaM8erlSmw0cT7uZr7M=
github.com/cli/go-gh/v2 v2.10.0/go.mod h1:MeRoKzXff3ygHu7zP+NVTT+imcHW6p3tpuxHAzRM2xE=
github.com/cli/oauth v1.0.1 h1:pXnTFl/qUegXHK531Dv0LNjW4mLx626eS42gnzfXJPA=
github.com/cli/oauth v1.0.1/go.mod h1:qd/FX8ZBD6n1sVNQO3aIdRxeu5LGw9WhKnYhIIoC2A4=
github.com/cli/safeexec v1.0.0/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5zx3Q=
Expand Down
14 changes: 14 additions & 0 deletions internal/ghinstance/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ func GraphQLEndpoint(hostname string) string {
if isGarage(hostname) {
return fmt.Sprintf("https://%s/api/graphql", hostname)
}
// Once we change Tenancy to no longer be treated as Enterprise, this
// conditional can be removed as the flow will fall through to the bottom.
// However, we can't do that until we've investigated all places in which
// Tenancy is currently treated as Enterprise.
if IsTenancy(hostname) {
return fmt.Sprintf("https://api.%s/graphql", hostname)
}
if IsEnterprise(hostname) {
return fmt.Sprintf("https://%s/api/graphql", hostname)
}
Expand All @@ -86,6 +93,13 @@ func RESTPrefix(hostname string) string {
if isGarage(hostname) {
return fmt.Sprintf("https://%s/api/v3/", hostname)
}
// Once we change Tenancy to no longer be treated as Enterprise, this
// conditional can be removed as the flow will fall through to the bottom.
// However, we can't do that until we've investigated all places in which
// Tenancy is currently treated as Enterprise.
if IsTenancy(hostname) {
return fmt.Sprintf("https://api.%s/", hostname)
}
if IsEnterprise(hostname) {
return fmt.Sprintf("https://%s/api/v3/", hostname)
}
Expand Down
8 changes: 8 additions & 0 deletions internal/ghinstance/host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ func TestGraphQLEndpoint(t *testing.T) {
host: "ghe.io",
want: "https://ghe.io/api/graphql",
},
{
host: "tenant.ghe.com",
want: "https://api.tenant.ghe.com/graphql",
},
}
for _, tt := range tests {
t.Run(tt.host, func(t *testing.T) {
Expand Down Expand Up @@ -285,6 +289,10 @@ func TestRESTPrefix(t *testing.T) {
host: "ghe.io",
want: "https://ghe.io/api/v3/",
},
{
host: "tenant.ghe.com",
want: "https://api.tenant.ghe.com/",
},
}
for _, tt := range tests {
t.Run(tt.host, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/attestation/verify/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestNewVerifyCmd(t *testing.T) {
},
},
}
testReg.Register(httpmock.REST(http.MethodGet, "api/v3/meta"),
testReg.Register(httpmock.REST(http.MethodGet, "meta"),
httpmock.StatusJSONResponse(200, &metaResp))

f := &cmdutil.Factory{
Expand Down