Slightly simplify code
Change instance DB functions from querying by ID to querying by name. Names are unique in GARM, so we might as well use the name instead of the ID and spare ourselves the extra query to get the ID when a qorkflow comes in. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
9cbb2f867e
commit
36288c65e6
7 changed files with 42 additions and 146 deletions
|
|
@ -870,12 +870,12 @@ func (r *Runner) ListAllInstances(ctx context.Context) ([]params.Instance, error
|
|||
}
|
||||
|
||||
func (r *Runner) AddInstanceStatusMessage(ctx context.Context, param params.InstanceUpdateMessage) error {
|
||||
instanceID := auth.InstanceID(ctx)
|
||||
if instanceID == "" {
|
||||
instanceName := auth.InstanceName(ctx)
|
||||
if instanceName == "" {
|
||||
return runnerErrors.ErrUnauthorized
|
||||
}
|
||||
|
||||
if err := r.store.AddInstanceEvent(ctx, instanceID, params.StatusEvent, params.EventInfo, param.Message); err != nil {
|
||||
if err := r.store.AddInstanceEvent(ctx, instanceName, params.StatusEvent, params.EventInfo, param.Message); err != nil {
|
||||
return errors.Wrap(err, "adding status update")
|
||||
}
|
||||
|
||||
|
|
@ -887,7 +887,7 @@ func (r *Runner) AddInstanceStatusMessage(ctx context.Context, param params.Inst
|
|||
updateParams.AgentID = *param.AgentID
|
||||
}
|
||||
|
||||
if _, err := r.store.UpdateInstance(r.ctx, instanceID, updateParams); err != nil {
|
||||
if _, err := r.store.UpdateInstance(r.ctx, instanceName, updateParams); err != nil {
|
||||
return errors.Wrap(err, "updating runner agent ID")
|
||||
}
|
||||
|
||||
|
|
@ -895,9 +895,9 @@ func (r *Runner) AddInstanceStatusMessage(ctx context.Context, param params.Inst
|
|||
}
|
||||
|
||||
func (r *Runner) UpdateSystemInfo(ctx context.Context, param params.UpdateSystemInfoParams) error {
|
||||
instanceID := auth.InstanceID(ctx)
|
||||
if instanceID == "" {
|
||||
slog.ErrorContext(ctx, "missing instance ID")
|
||||
instanceName := auth.InstanceName(ctx)
|
||||
if instanceName == "" {
|
||||
slog.ErrorContext(ctx, "missing instance name")
|
||||
return runnerErrors.ErrUnauthorized
|
||||
}
|
||||
|
||||
|
|
@ -915,7 +915,7 @@ func (r *Runner) UpdateSystemInfo(ctx context.Context, param params.UpdateSystem
|
|||
updateParams.AgentID = *param.AgentID
|
||||
}
|
||||
|
||||
if _, err := r.store.UpdateInstance(r.ctx, instanceID, updateParams); err != nil {
|
||||
if _, err := r.store.UpdateInstance(r.ctx, instanceName, updateParams); err != nil {
|
||||
return errors.Wrap(err, "updating runner system info")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue