in pkg/cloud/rgraph/rnode/forwardingrule/node.go [150:195]
func (n *forwardingRuleNode) updateActions(ngot rnode.Node) ([]exec.Action, error) {
details := n.Plan().Details()
if details == nil {
return nil, nodeErr("updateActions: node %s has not been planned", n.ID())
}
got, ok := ngot.(*forwardingRuleNode)
if !ok {
return nil, nodeErr("updateActions: node %s has invalid type %T", n.ID(), ngot)
}
act := &forwardingRuleUpdateAction{id: n.ID()}
var changed changedFields
for _, item := range details.Diff.Items {
if !changed.process(item) {
return nil, nodeErr("updateActions %s: field %s cannot be updated in place", n.ID(), item.Path)
}
}
if changed.target {
oldTarget, err := parseTarget(fmt.Sprintf("updateActions %s", n.ID()), got)
if err != nil {
return nil, err
}
target, err := parseTarget(fmt.Sprintf("updateActions %s", n.ID()), n)
if err != nil {
return nil, err
}
act.Want = append(act.Want, exec.NewExistsEvent(target))
act.oldTarget = oldTarget
act.target = target
}
if changed.labels {
gotRes, _ := got.resource.ToGA()
wantRes, _ := n.resource.ToGA()
act.labelFingerprint = gotRes.LabelFingerprint
act.labels = wantRes.Labels
}
return []exec.Action{
// Action: Signal resource exists.
exec.NewExistsAction(n.ID()),
// Action: Do the updates.
act,
}, nil
}