From ff702279088f1d0bfc56a30b93150b4ecd09c8f1 Mon Sep 17 00:00:00 2001 From: Junya Okabe <86868255+Okabe-Junya@users.noreply.github.com> Date: Tue, 22 Sep 2026 19:19:29 +0900 Subject: [PATCH] Remove dead GitHubConfig surface left by scaleset migration (#4676) --- github/actions/actions.go | 55 --------------------------------------- 1 file changed, 55 deletions(-) diff --git a/github/actions/actions.go b/github/actions/actions.go index 7a93c457..8a2ae628 100644 --- a/github/actions/actions.go +++ b/github/actions/actions.go @@ -3,30 +3,17 @@ package actions import ( "fmt" "net/url" - "os" "strings" ) var ErrInvalidGitHubConfigURL = fmt.Errorf("invalid config URL, should point to an enterprise, org, or repository") -type GitHubScope int - -const ( - GitHubScopeUnknown GitHubScope = iota - GitHubScopeEnterprise - GitHubScopeOrganization - GitHubScopeRepository -) - type GitHubConfig struct { ConfigURL *url.URL - Scope GitHubScope Enterprise string Organization string Repository string - - IsHosted bool } func ParseGitHubConfigFromURL(in string) (*GitHubConfig, error) { @@ -35,11 +22,8 @@ func ParseGitHubConfigFromURL(in string) (*GitHubConfig, error) { return nil, err } - isHosted := isHostedGitHubURL(u) - configURL := &GitHubConfig{ ConfigURL: u, - IsHosted: isHosted, } invalidURLError := fmt.Errorf("%q: %w", u.String(), ErrInvalidGitHubConfigURL) @@ -52,17 +36,14 @@ func ParseGitHubConfigFromURL(in string) (*GitHubConfig, error) { return nil, invalidURLError } - configURL.Scope = GitHubScopeOrganization configURL.Organization = pathParts[0] case 2: // Repository or enterprise if strings.ToLower(pathParts[0]) == "enterprises" { - configURL.Scope = GitHubScopeEnterprise configURL.Enterprise = pathParts[1] break } - configURL.Scope = GitHubScopeRepository configURL.Organization = pathParts[0] configURL.Repository = pathParts[1] default: @@ -71,39 +52,3 @@ func ParseGitHubConfigFromURL(in string) (*GitHubConfig, error) { return configURL, nil } - -func (c *GitHubConfig) GitHubAPIURL(path string) *url.URL { - result := &url.URL{ - Scheme: c.ConfigURL.Scheme, - Host: c.ConfigURL.Host, // default for Enterprise mode - Path: "/api/v3", // default for Enterprise mode - } - - isHosted := isHostedGitHubURL(c.ConfigURL) - - if isHosted { - result.Host = fmt.Sprintf("api.%s", c.ConfigURL.Host) - result.Path = "" - - if c.ConfigURL.Host == "www.github.com" { - // re-routing www.github.com to api.github.com - result.Host = "api.github.com" - } - } - - result.Path += path - - return result -} - -func isHostedGitHubURL(u *url.URL) bool { - _, forceGhes := os.LookupEnv("GITHUB_ACTIONS_FORCE_GHES") - if forceGhes { - return false - } - - return u.Host == "github.com" || - u.Host == "www.github.com" || - u.Host == "github.localhost" || - strings.HasSuffix(u.Host, ".ghe.com") -}