code: func sanitizeResource(nodeRes []*api.GenericResource, res *api.GenericResource) (ok bool, nrs []*api.GenericResource) {
  	switch na := res.Resource.(type) {
  	case *api.GenericResource_DiscreteResourceSpec:
  		nrs := GetResource(na.DiscreteResourceSpec.Kind, nodeRes)
  
  		// Type change or removed: reset
  		if len(nrs) != 1 {
  			return false, nrs
  		}
  
  		// Type change: reset
  		nr := nrs[0].GetDiscreteResourceSpec()
  		if nr == nil {
  			return false, nrs
  		}
  
  		// Amount change: reset
  		if na.DiscreteResourceSpec.Value > nr.Value {
  			return false, nrs
  		}
  	case *api.GenericResource_NamedResourceSpec:
  		nrs := GetResource(na.NamedResourceSpec.Kind, nodeRes)
  
  		// Type change
  		if len(nrs) == 0 {
  			return false, nrs
  		}
  
  		for _, nr := range nrs {
  			// Type change: reset
  			if nr.GetDiscreteResourceSpec() != nil {
  				return false, nrs
  			}
  
  			if na.NamedResourceSpec.Value == nr.GetNamedResourceSpec().Value {
  				return true, nil
  			}
  		}
  
  		// Removed
  		return false, nil
  	}
  
  	return true, nil
  }
docs: // Returns true if the element is in nodeRes and "sane"
  // Returns false if the element isn't in nodeRes and "sane" and the element(s) that should be replacing it