in pkg/model/plan.go [21:47]
func (p *Plan) CalculateChanges() Changes {
changes := Changes{}
currentMap := make(map[string]*Endpoint)
for _, e := range p.Current {
currentMap[e.Id] = e
}
for _, e := range p.Desired {
existing := currentMap[e.Id]
if existing != nil {
if !existing.Equals(e) {
changes.Update = append(changes.Update, e)
}
delete(currentMap, e.Id)
} else {
changes.Create = append(changes.Create, e)
}
}
// iterate unmatched endpoints from Current to delete them
for _, e := range currentMap {
changes.Delete = append(changes.Delete, e)
}
return changes
}