Add temporary replace to fork

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2023-08-21 11:57:52 +00:00
parent d5f8cf079e
commit 6dea1c1937
4 changed files with 24 additions and 10 deletions

2
go.mod
View file

@ -36,7 +36,7 @@ require (
gorm.io/gorm v1.24.6
)
replace github.com/google/go-github/v54 => github.com/gabriel-samfira/go-github/v54 v54.0.0-20230820134006-4b55d56a9b7f
replace github.com/google/go-github/v54 => github.com/gabriel-samfira/go-github/v54 v54.0.0-20230821112832-bbb536ee5a3a
require (
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect

View file

@ -55,6 +55,8 @@ type GithubClient interface {
CreateOrganizationRegistrationToken(ctx context.Context, owner string) (*github.RegistrationToken, *github.Response, error)
// GenerateOrgJITConfig generate a just-in-time configuration for an organization.
GenerateOrgJITConfig(ctx context.Context, owner string, request *github.GenerateJITConfigRequest) (*github.JITRunnerConfig, *github.Response, error)
// ListOrganizationRunnerGroups lists all runner groups within an organization.
ListOrganizationRunnerGroups(ctx context.Context, org string, opts *github.ListOrgRunnerGroupOptions) (*github.RunnerGroups, *github.Response, error)
}
type GithubEnterpriseClient interface {
@ -67,6 +69,8 @@ type GithubEnterpriseClient interface {
// ListRunnerApplicationDownloads returns a list of github runner application downloads for the
// various supported operating systems and architectures.
ListRunnerApplicationDownloads(ctx context.Context, enterprise string) ([]*github.RunnerApplicationDownload, *github.Response, error)
// GenerateEnterpriseJITConfig generate a just-in-time configuration for an enterprise.
GenerateEnterpriseJITConfig(ctx context.Context, enterprise string, request *github.GenerateJITConfigRequest) (*github.JITRunnerConfig, *github.Response, error)
// ListRunnerGroups lists all self-hosted runner groups configured in an enterprise.
ListRunnerGroups(ctx context.Context, enterprise string, opts *github.ListEnterpriseRunnerGroupOptions) (*github.EnterpriseRunnerGroups, *github.Response, error)
}

View file

@ -532,6 +532,8 @@ func (r *basePoolManager) cleanupOrphanedGithubRunners(runners []*github.Runner)
r.log("instance %s is still being created, give it a chance to finish", dbInstance.Name)
continue
case commonParams.InstanceRunning:
// this check is not strictly needed, but can help avoid unnecessary strain on the provider.
// At worst, we will have a runner that is offline in github for 5 minutes before we reap it.
if time.Since(dbInstance.UpdatedAt).Minutes() < 5 {
// instance was updated recently. We give it a chance to register itself in github.
r.log("instance %s was updated recently, skipping check", dbInstance.Name)
@ -716,6 +718,10 @@ func (r *basePoolManager) AddRunner(ctx context.Context, poolID string, aditiona
return errors.Wrap(err, "creating instance")
}
// labels := r.getLabelsForInstance(pool)
// // Attempt to create JIT config
return nil
}
@ -744,6 +750,16 @@ func (r *basePoolManager) setPoolRunningState(isRunning bool, failureReason stri
r.mux.Unlock()
}
func (r *basePoolManager) getLabelsForInstance(pool params.Pool) []string {
labels := []string{}
for _, tag := range pool.Tags {
labels = append(labels, tag.Name)
}
labels = append(labels, r.controllerLabel())
labels = append(labels, r.poolLabel(pool.ID))
return labels
}
func (r *basePoolManager) addInstanceToProvider(instance params.Instance) error {
pool, err := r.helper.GetPoolByID(instance.PoolID)
if err != nil {
@ -755,13 +771,7 @@ func (r *basePoolManager) addInstanceToProvider(instance params.Instance) error
return fmt.Errorf("unknown provider %s for pool %s", pool.ProviderName, pool.ID)
}
labels := []string{}
for _, tag := range pool.Tags {
labels = append(labels, tag.Name)
}
labels = append(labels, r.controllerLabel())
labels = append(labels, r.poolLabel(pool.ID))
labels := r.getLabelsForInstance(pool)
jwtValidity := pool.RunnerTimeout()
entity := r.helper.String()

2
vendor/modules.txt vendored
View file

@ -439,4 +439,4 @@ gorm.io/gorm/logger
gorm.io/gorm/migrator
gorm.io/gorm/schema
gorm.io/gorm/utils
# github.com/google/go-github/v54 => github.com/gabriel-samfira/go-github/v54 v54.0.0-20230820134006-4b55d56a9b7f
# github.com/google/go-github/v54 => github.com/gabriel-samfira/go-github/v54 v54.0.0-20230821112832-bbb536ee5a3a