diff --git a/go.mod b/go.mod index 7ca80d95..ead43046 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22.0 toolchain go1.22.4 require ( - github.com/cli/go-gh/v2 v2.9.0 + github.com/cli/go-gh/v2 v2.11.0 github.com/go-errors/errors v1.5.1 github.com/onsi/gomega v1.34.2 github.com/sigstore/cosign/v2 v2.2.4 diff --git a/go.sum b/go.sum index 41dfa43e..9f5b7096 100644 --- a/go.sum +++ b/go.sum @@ -245,8 +245,8 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn github.com/clbanning/mxj/v2 v2.5.5/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME= github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= -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.11.0 h1:TERLYMMWderKBO3lBff/JIu2+eSly2oFRgN2WvO+3eA= +github.com/cli/go-gh/v2 v2.11.0/go.mod h1:MeRoKzXff3ygHu7zP+NVTT+imcHW6p3tpuxHAzRM2xE= github.com/cli/safeexec v1.0.0 h1:0VngyaIyqACHdcMNWfo6+KdUYnqEr2Sg+bSP1pdF+dI= github.com/cli/safeexec v1.0.0/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5zx3Q= github.com/cli/shurcooL-graphql v0.0.4 h1:6MogPnQJLjKkaXPyGqPRXOI2qCsQdqNfUY1QSJu2GuY= diff --git a/vendor/github.com/cli/go-gh/v2/pkg/api/graphql_client.go b/vendor/github.com/cli/go-gh/v2/pkg/api/graphql_client.go index 405b10f3..3317eef0 100644 --- a/vendor/github.com/cli/go-gh/v2/pkg/api/graphql_client.go +++ b/vendor/github.com/cli/go-gh/v2/pkg/api/graphql_client.go @@ -10,6 +10,7 @@ import ( "net/http" "strings" + "github.com/cli/go-gh/v2/pkg/auth" graphql "github.com/cli/shurcooL-graphql" ) @@ -171,8 +172,8 @@ func graphQLEndpoint(host string) string { if isGarage(host) { return fmt.Sprintf("https://%s/api/graphql", host) } - host = normalizeHostname(host) - if isEnterprise(host) { + host = auth.NormalizeHostname(host) + if auth.IsEnterprise(host) { return fmt.Sprintf("https://%s/api/graphql", host) } if strings.EqualFold(host, localhost) { diff --git a/vendor/github.com/cli/go-gh/v2/pkg/api/http_client.go b/vendor/github.com/cli/go-gh/v2/pkg/api/http_client.go index 589de91a..1d7c5177 100644 --- a/vendor/github.com/cli/go-gh/v2/pkg/api/http_client.go +++ b/vendor/github.com/cli/go-gh/v2/pkg/api/http_client.go @@ -134,21 +134,6 @@ func isGarage(host string) bool { return strings.EqualFold(host, "garage.github.com") } -func isEnterprise(host string) bool { - return host != github && host != localhost -} - -func normalizeHostname(hostname string) string { - hostname = strings.ToLower(hostname) - if strings.HasSuffix(hostname, "."+github) { - return github - } - if strings.HasSuffix(hostname, "."+localhost) { - return localhost - } - return hostname -} - type headerRoundTripper struct { headers map[string]string host string diff --git a/vendor/github.com/cli/go-gh/v2/pkg/api/rest_client.go b/vendor/github.com/cli/go-gh/v2/pkg/api/rest_client.go index 2d91f707..ccd86cd8 100644 --- a/vendor/github.com/cli/go-gh/v2/pkg/api/rest_client.go +++ b/vendor/github.com/cli/go-gh/v2/pkg/api/rest_client.go @@ -7,6 +7,8 @@ import ( "io" "net/http" "strings" + + "github.com/cli/go-gh/v2/pkg/auth" ) // RESTClient wraps methods for the different types of @@ -159,8 +161,8 @@ func restPrefix(hostname string) string { if isGarage(hostname) { return fmt.Sprintf("https://%s/api/v3/", hostname) } - hostname = normalizeHostname(hostname) - if isEnterprise(hostname) { + hostname = auth.NormalizeHostname(hostname) + if auth.IsEnterprise(hostname) { return fmt.Sprintf("https://%s/api/v3/", hostname) } if strings.EqualFold(hostname, localhost) { diff --git a/vendor/github.com/cli/go-gh/v2/pkg/auth/auth.go b/vendor/github.com/cli/go-gh/v2/pkg/auth/auth.go index 6ab996f8..a903736c 100644 --- a/vendor/github.com/cli/go-gh/v2/pkg/auth/auth.go +++ b/vendor/github.com/cli/go-gh/v2/pkg/auth/auth.go @@ -26,6 +26,7 @@ const ( hostsKey = "hosts" localhost = "github.localhost" oauthToken = "oauth_token" + tenancyHost = "ghe.com" // TenancyHost is the domain suffix of a tenancy GitHub instance. ) // TokenForHost retrieves an authentication token and the source of that token for the specified @@ -61,7 +62,7 @@ func TokenFromEnvOrConfig(host string) (string, string) { } func tokenForHost(cfg *config.Config, host string) (string, string) { - host = normalizeHostname(host) + host = NormalizeHostname(host) if IsEnterprise(host) { if token := os.Getenv(ghEnterpriseToken); token != "" { return token, ghEnterpriseToken @@ -149,24 +150,24 @@ func defaultHost(cfg *config.Config) (string, string) { return github, defaultSource } -// TenancyHost is the domain name of a tenancy GitHub instance. -const tenancyHost = "ghe.com" - // IsEnterprise determines if a provided host is a GitHub Enterprise Server instance, // rather than GitHub.com or a tenancy GitHub instance. func IsEnterprise(host string) bool { - normalizedHost := normalizeHostname(host) + normalizedHost := NormalizeHostname(host) return normalizedHost != github && normalizedHost != localhost && !IsTenancy(normalizedHost) } // IsTenancy determines if a provided host is a tenancy GitHub instance, // rather than GitHub.com or a GitHub Enterprise Server instance. func IsTenancy(host string) bool { - normalizedHost := normalizeHostname(host) + normalizedHost := NormalizeHostname(host) return strings.HasSuffix(normalizedHost, "."+tenancyHost) } -func normalizeHostname(host string) string { +// NormalizeHostname ensures the host matches the values used throughout +// the rest of the codebase with respect to hostnames. These are github, +// localhost, and tenancyHost. +func NormalizeHostname(host string) string { hostname := strings.ToLower(host) if strings.HasSuffix(hostname, "."+github) { return github diff --git a/vendor/modules.txt b/vendor/modules.txt index 09674147..534e5050 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -403,7 +403,7 @@ github.com/chrismellard/docker-credential-acr-env/pkg/token # github.com/clbanning/mxj/v2 v2.7.0 ## explicit; go 1.15 github.com/clbanning/mxj/v2 -# github.com/cli/go-gh/v2 v2.9.0 +# github.com/cli/go-gh/v2 v2.11.0 ## explicit; go 1.21 github.com/cli/go-gh/v2/internal/set github.com/cli/go-gh/v2/internal/yamlmap