Add temporary redirect to go-github fork
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
09d2f1b061
commit
591641a8a3
5 changed files with 27 additions and 11 deletions
|
|
@ -39,6 +39,7 @@ const (
|
|||
instanceEntityKey contextFlags = "entity"
|
||||
instanceRunnerStatus contextFlags = "status"
|
||||
instanceTokenFetched contextFlags = "tokenFetched"
|
||||
instanceHasJITConfig contextFlags = "hasJITConfig"
|
||||
instanceParams contextFlags = "instanceParams"
|
||||
)
|
||||
|
||||
|
|
@ -66,6 +67,18 @@ func InstanceTokenFetched(ctx context.Context) bool {
|
|||
return elem.(bool)
|
||||
}
|
||||
|
||||
func SetInstanceHasJITConfig(ctx context.Context, cfg map[string]string) context.Context {
|
||||
return context.WithValue(ctx, instanceHasJITConfig, len(cfg) > 0)
|
||||
}
|
||||
|
||||
func InstanceHasJITConfig(ctx context.Context) bool {
|
||||
elem := ctx.Value(instanceHasJITConfig)
|
||||
if elem == nil {
|
||||
return false
|
||||
}
|
||||
return elem.(bool)
|
||||
}
|
||||
|
||||
func SetInstanceParams(ctx context.Context, instance params.Instance) context.Context {
|
||||
return context.WithValue(ctx, instanceParams, instance)
|
||||
}
|
||||
|
|
@ -149,6 +162,7 @@ func PopulateInstanceContext(ctx context.Context, instance params.Instance) cont
|
|||
ctx = SetInstancePoolID(ctx, instance.PoolID)
|
||||
ctx = SetInstanceRunnerStatus(ctx, instance.RunnerStatus)
|
||||
ctx = SetInstanceTokenFetched(ctx, instance.TokenFetched)
|
||||
ctx = SetInstanceHasJITConfig(ctx, instance.JitConfiguration)
|
||||
ctx = SetInstanceParams(ctx, instance)
|
||||
return ctx
|
||||
}
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -36,6 +36,8 @@ 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
|
||||
|
||||
require (
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
|
|
|
|||
|
|
@ -67,4 +67,6 @@ 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(ctx context.Context, enterprise string, request *github.GenerateJITConfigRequest) (*github.JITRunnerConfig, *github.Response, error)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -859,15 +859,11 @@ func (r *Runner) AddInstanceStatusMessage(ctx context.Context, param params.Inst
|
|||
}
|
||||
|
||||
func (r *Runner) GetInstanceGithubRegistrationToken(ctx context.Context) (string, error) {
|
||||
instanceName := auth.InstanceName(ctx)
|
||||
if instanceName == "" {
|
||||
return "", runnerErrors.ErrUnauthorized
|
||||
}
|
||||
|
||||
// Check if this instance already fetched a registration token. We only allow an instance to
|
||||
// fetch one token. If the instance fails to bootstrap after a token is fetched, we reset the
|
||||
// token fetched field when re-queueing the instance.
|
||||
if auth.InstanceTokenFetched(ctx) {
|
||||
// Check if this instance already fetched a registration token or if it was configured using
|
||||
// the new Just In Time runner feature. If we're still using the old way of configuring a runner,
|
||||
// we only allow an instance to fetch one token. If the instance fails to bootstrap after a token
|
||||
// is fetched, we reset the token fetched field when re-queueing the instance.
|
||||
if auth.InstanceTokenFetched(ctx) || auth.InstanceHasJITConfig(ctx) {
|
||||
return "", runnerErrors.ErrUnauthorized
|
||||
}
|
||||
|
||||
|
|
@ -876,9 +872,10 @@ func (r *Runner) GetInstanceGithubRegistrationToken(ctx context.Context) (string
|
|||
return "", runnerErrors.ErrUnauthorized
|
||||
}
|
||||
|
||||
instance, err := r.store.GetInstanceByName(ctx, instanceName)
|
||||
instance, err := auth.InstanceParams(ctx)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "fetching instance")
|
||||
log.Printf("failed to get instance params: %s", err)
|
||||
return "", runnerErrors.ErrUnauthorized
|
||||
}
|
||||
|
||||
poolMgr, err := r.getPoolManagerFromInstance(ctx, instance)
|
||||
|
|
|
|||
1
vendor/modules.txt
vendored
1
vendor/modules.txt
vendored
|
|
@ -439,3 +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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue