Merge targets with upserting

This commit is contained in:
sophia 2022-01-20 12:21:03 -06:00 committed by Paul Hinze
parent 12de22a7db
commit 3dbd9286be
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
2 changed files with 2 additions and 9 deletions

View File

@ -29,15 +29,6 @@ func (m *Machine) Close() (err error) {
// ID implements core.Machine
func (m *Machine) ID() (id string, err error) {
// Sometimes the machine id does not get set, so set it here.
// TODO: This is maybe a symptom of a different problem
if m.target.Uuid != m.machine.Id {
m.machine.Id = m.target.Uuid
err = m.SaveMachine()
if err != nil {
return "", err
}
}
return m.machine.Id, nil
}

View File

@ -194,6 +194,8 @@ func (s *State) targetPut(
return erro
}
if foundTarget != nil {
// Merge found target with provided target
proto.Merge(value, foundTarget)
value.ResourceId = foundTarget.ResourceId
value.Uuid = foundTarget.Uuid
} else {