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:
parent
b4113048bb
commit
31ad45eeb6
7 changed files with 32 additions and 54 deletions
|
|
@ -100,7 +100,7 @@ func (s *sqlDatabase) paramsJobToWorkflowJob(ctx context.Context, job params.Job
|
|||
}
|
||||
|
||||
if job.RunnerName != "" {
|
||||
instance, err := s.getInstanceByName(s.ctx, job.RunnerName)
|
||||
instance, err := s.getInstance(s.ctx, job.RunnerName)
|
||||
if err != nil {
|
||||
// This usually is very normal as not all jobs run on our runners.
|
||||
slog.DebugContext(ctx, "failed to get instance by name", "instance_name", job.RunnerName)
|
||||
|
|
@ -282,7 +282,7 @@ func (s *sqlDatabase) CreateOrUpdateJob(ctx context.Context, job params.Job) (pa
|
|||
}
|
||||
|
||||
if job.RunnerName != "" {
|
||||
instance, err := s.getInstanceByName(ctx, job.RunnerName)
|
||||
instance, err := s.getInstance(ctx, job.RunnerName)
|
||||
if err == nil {
|
||||
workflowJob.InstanceID = &instance.ID
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue