UpdateService updates a service.
(ctx context.Context, id string, opts *database.UpdateServiceOptions)
| 1438 | |
| 1439 | // UpdateService updates a service. |
| 1440 | func (c *connection) UpdateService(ctx context.Context, id string, opts *database.UpdateServiceOptions) (*database.Service, error) { |
| 1441 | if err := database.Validate(opts); err != nil { |
| 1442 | return nil, err |
| 1443 | } |
| 1444 | |
| 1445 | if opts.Attributes == nil { |
| 1446 | opts.Attributes = make(map[string]any) |
| 1447 | } |
| 1448 | |
| 1449 | res := &serviceDTO{} |
| 1450 | err := c.getDB(ctx).QueryRowxContext(ctx, ` |
| 1451 | UPDATE service |
| 1452 | SET name=$1, attributes=$2 |
| 1453 | WHERE id=$3 RETURNING *`, |
| 1454 | opts.Name, opts.Attributes, id, |
| 1455 | ).StructScan(res) |
| 1456 | if err != nil { |
| 1457 | return nil, parseErr("service", err) |
| 1458 | } |
| 1459 | return res.serviceFromDTO() |
| 1460 | } |
| 1461 | |
| 1462 | // UpdateServiceActiceOn updates a service's active_on timestamp. |
| 1463 | func (c *connection) UpdateServiceActiveOn(ctx context.Context, ids []string) error { |
nothing calls this directly
no test coverage detected