Add cmd line arg for enterprise url. Fix enterprise bug. (#1)
* Add cmd line arg for enterprise url. Fix enterprise bug. * Fix package import order * Fix comment
This commit is contained in:
parent
623c84fa52
commit
921daff61b
|
|
@ -198,9 +198,8 @@ func (c *MultiGitHubClient) initClientForSecret(secret *corev1.Secret, dependent
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Check if EnterpriseURL is set.
|
||||
if conf.EnterpriseURL == "" {
|
||||
// fallback to the controller-wide setting
|
||||
// Fallback to the controller-wide setting if EnterpriseURL is not set and the original client is an enterprise client.
|
||||
if conf.EnterpriseURL == "" && c.githubClient.IsEnterprise {
|
||||
conf.EnterpriseURL = c.githubClient.GithubBaseURL
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package github
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/actions-runner-controller/actions-runner-controller/build"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
|
|
@ -11,6 +10,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/actions-runner-controller/actions-runner-controller/build"
|
||||
"github.com/actions-runner-controller/actions-runner-controller/github/metrics"
|
||||
"github.com/actions-runner-controller/actions-runner-controller/logging"
|
||||
"github.com/bradleyfalzon/ghinstallation/v2"
|
||||
|
|
@ -43,6 +43,7 @@ type Client struct {
|
|||
mu sync.Mutex
|
||||
// GithubBaseURL to Github without API suffix.
|
||||
GithubBaseURL string
|
||||
IsEnterprise bool
|
||||
}
|
||||
|
||||
type BasicAuthTransport struct {
|
||||
|
|
@ -95,8 +96,10 @@ func (c *Config) NewClient() (*Client, error) {
|
|||
|
||||
var client *github.Client
|
||||
var githubBaseURL string
|
||||
var isEnterprise bool
|
||||
if len(c.EnterpriseURL) > 0 {
|
||||
var err error
|
||||
isEnterprise = true
|
||||
client, err = github.NewEnterpriseClient(c.EnterpriseURL, c.EnterpriseURL, httpClient)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("enterprise client creation failed: %v", err)
|
||||
|
|
@ -136,12 +139,12 @@ func (c *Config) NewClient() (*Client, error) {
|
|||
}
|
||||
}
|
||||
client.UserAgent = "actions-runner-controller/" + build.Version
|
||||
|
||||
return &Client{
|
||||
Client: client,
|
||||
regTokens: map[string]*github.RegistrationToken{},
|
||||
mu: sync.Mutex{},
|
||||
GithubBaseURL: githubBaseURL,
|
||||
IsEnterprise: isEnterprise,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
3
main.go
3
main.go
|
|
@ -19,12 +19,12 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/actions-runner-controller/actions-runner-controller/build"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
actionsv1alpha1 "github.com/actions-runner-controller/actions-runner-controller/api/v1alpha1"
|
||||
"github.com/actions-runner-controller/actions-runner-controller/build"
|
||||
"github.com/actions-runner-controller/actions-runner-controller/controllers"
|
||||
"github.com/actions-runner-controller/actions-runner-controller/github"
|
||||
"github.com/actions-runner-controller/actions-runner-controller/logging"
|
||||
|
|
@ -103,6 +103,7 @@ func main() {
|
|||
flag.Var(&runnerImagePullSecrets, "runner-image-pull-secret", "The default image-pull secret name for self-hosted runner container.")
|
||||
flag.StringVar(&dockerRegistryMirror, "docker-registry-mirror", "", "The default Docker Registry Mirror used by runners.")
|
||||
flag.StringVar(&c.Token, "github-token", c.Token, "The personal access token of GitHub.")
|
||||
flag.StringVar(&c.EnterpriseURL, "github-enterprise-url", c.EnterpriseURL, "Enterprise URL to be used for your GitHub API calls")
|
||||
flag.Int64Var(&c.AppID, "github-app-id", c.AppID, "The application ID of GitHub App.")
|
||||
flag.Int64Var(&c.AppInstallationID, "github-app-installation-id", c.AppInstallationID, "The installation ID of GitHub App.")
|
||||
flag.StringVar(&c.AppPrivateKey, "github-app-private-key", c.AppPrivateKey, "The path of a private key file to authenticate as a GitHub App")
|
||||
|
|
|
|||
Loading…
Reference in New Issue