diff --git a/go.mod b/go.mod index e4028f64..ca8f31a2 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/openshift-pipelines/catalog-cd go 1.21 require ( - github.com/cli/go-gh/v2 v2.5.0 + github.com/cli/go-gh/v2 v2.6.0 github.com/go-errors/errors v1.5.1 github.com/onsi/gomega v1.31.1 github.com/sigstore/cosign/v2 v2.2.2 diff --git a/go.sum b/go.sum index ff86d24a..235054bf 100644 --- a/go.sum +++ b/go.sum @@ -239,8 +239,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.5.0 h1:uFF4l5mZ5wHAXg97u/9PERKOMrKYcoy2iiZI1OPMCwk= -github.com/cli/go-gh/v2 v2.5.0/go.mod h1:h3salfqqooVpzKmHp6aUdeNx62UmxQRpLbagFSHTJGQ= +github.com/cli/go-gh/v2 v2.6.0 h1:1zXwr7mW6JDCPwXQLLtCdKnp+pNc7ZixyDeLpM1pf9I= +github.com/cli/go-gh/v2 v2.6.0/go.mod h1:h3salfqqooVpzKmHp6aUdeNx62UmxQRpLbagFSHTJGQ= 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/auth/auth.go b/vendor/github.com/cli/go-gh/v2/pkg/auth/auth.go index ce39d58c..88e02c2e 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 @@ -3,6 +3,7 @@ package auth import ( + "fmt" "os" "os/exec" "strconv" @@ -148,8 +149,15 @@ func defaultHost(cfg *config.Config) (string, string) { return github, defaultSource } +// TenancyHost is the domain name of a tenancy GitHub instance. +const tenancyHost = "ghe.com" + func isEnterprise(host string) bool { - return host != github && host != localhost + return host != github && host != localhost && !isTenancy(host) +} + +func isTenancy(host string) bool { + return strings.HasSuffix(host, "."+tenancyHost) } func normalizeHostname(host string) string { @@ -160,5 +168,21 @@ func normalizeHostname(host string) string { if strings.HasSuffix(hostname, "."+localhost) { return localhost } + // This has been copied over from the cli/cli NormalizeHostname function + // to ensure compatible behaviour but we don't fully understand when or + // why it would be useful here. We can't see what harm will come of + // duplicating the logic. + if before, found := cutSuffix(hostname, "."+tenancyHost); found { + idx := strings.LastIndex(before, ".") + return fmt.Sprintf("%s.%s", before[idx+1:], tenancyHost) + } return hostname } + +// Backport strings.CutSuffix from Go 1.20. +func cutSuffix(s, suffix string) (string, bool) { + if !strings.HasSuffix(s, suffix) { + return s, false + } + return s[:len(s)-len(suffix)], true +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 266a34a0..806c67a9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -361,7 +361,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.5.0 +# github.com/cli/go-gh/v2 v2.6.0 ## explicit; go 1.21 github.com/cli/go-gh/v2/internal/set github.com/cli/go-gh/v2/internal/yamlmap