fix #1131 : complain when validating unknown machine (#1146)

This commit is contained in:
Thibault "bui" Koechlin 2022-01-05 13:50:04 +01:00 committed by GitHub
parent ba71c55492
commit 6c676c4869
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -77,10 +77,13 @@ func (c *Client) ListMachines() ([]*ent.Machine, error) {
}
func (c *Client) ValidateMachine(machineID string) error {
_, err := c.Ent.Machine.Update().Where(machine.MachineIdEQ(machineID)).SetIsValidated(true).Save(c.CTX)
rets, err := c.Ent.Machine.Update().Where(machine.MachineIdEQ(machineID)).SetIsValidated(true).Save(c.CTX)
if err != nil {
return errors.Wrapf(UpdateFail, "validating machine: %s", err)
}
if rets == 0 {
return fmt.Errorf("machine not found")
}
return nil
}