Allow referencing runners by ID

Although runner names are unique, we still have an ID on the model
which is used as a primary key. We should allow using that ID to
reference a runner in the API.

This change allows users to specify ID or runner name.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2025-08-16 23:00:55 +00:00
parent b4113048bb
commit 31ad45eeb6
7 changed files with 32 additions and 54 deletions

View file

@ -557,7 +557,7 @@ func (r *basePoolManager) cleanupOrphanedGithubRunners(runners []*github.Runner)
continue
}
dbInstance, err := r.store.GetInstanceByName(r.ctx, *runner.Name)
dbInstance, err := r.store.GetInstance(r.ctx, *runner.Name)
if err != nil {
if !errors.Is(err, runnerErrors.ErrNotFound) {
return fmt.Errorf("error fetching instance from DB: %w", err)

View file

@ -731,7 +731,7 @@ func (r *Runner) GetInstance(ctx context.Context, instanceName string) (params.I
return params.Instance{}, runnerErrors.ErrUnauthorized
}
instance, err := r.store.GetInstanceByName(ctx, instanceName)
instance, err := r.store.GetInstance(ctx, instanceName)
if err != nil {
return params.Instance{}, fmt.Errorf("error fetching instance: %w", err)
}
@ -852,7 +852,7 @@ func (r *Runner) DeleteRunner(ctx context.Context, instanceName string, forceDel
return runnerErrors.ErrUnauthorized
}
instance, err := r.store.GetInstanceByName(ctx, instanceName)
instance, err := r.store.GetInstance(ctx, instanceName)
if err != nil {
return fmt.Errorf("error fetching instance: %w", err)
}