code: func NewControllerRevision(parent metav1.Object,
  	parentKind schema.GroupVersionKind,
  	templateLabels map[string]string,
  	data runtime.RawExtension,
  	revision int64,
  	collisionCount *int32) (*apps.ControllerRevision, error) {
  	labelMap := make(map[string]string)
  	for k, v := range templateLabels {
  		labelMap[k] = v
  	}
  	cr := &apps.ControllerRevision{
  		ObjectMeta: metav1.ObjectMeta{
  			Labels:          labelMap,
  			OwnerReferences: []metav1.OwnerReference{*metav1.NewControllerRef(parent, parentKind)},
  		},
  		Data:     data,
  		Revision: revision,
  	}
  	hash := HashControllerRevision(cr, collisionCount)
  	cr.Name = ControllerRevisionName(parent.GetName(), hash)
  	cr.Labels[ControllerRevisionHashLabel] = hash
  	return cr, nil
  }
docs: // NewControllerRevision returns a ControllerRevision with a ControllerRef pointing to parent and indicating that
  // parent is of parentKind. The ControllerRevision has labels matching template labels, contains Data equal to data, and
  // has a Revision equal to revision. The collisionCount is used when creating the name of the ControllerRevision
  // so the name is likely unique. If the returned error is nil, the returned ControllerRevision is valid. If the
  // returned error is not nil, the returned ControllerRevision is invalid for use.