Skip to content

Update set owner ref to use coreutil #327

@n3wscott

Description

@n3wscott

@grantr grantr • about 21 hours ago
A possible alternative to this and other controller references is https://github.com/kubernetes-sigs/controller-runtime/blob/471f9cde2471949c85c01c3baba2947d9929c908/pkg/controller/controllerutil/controllerutil.go, which can generate a controller ref between any two metav1.Objects, no type case needed.

import "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

func MakeChannel(flow *v1alpha1.Flow) *channelsv1alpha1.Channel {
  channel := &channelsv1alpha1.Channel{}
  controllerutil.SetOwnerReference(flow, channel, scheme.Scheme)
  return channel
}

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.priority/important-longtermImportant over the long term, but may not be staffed and/or may need multiple releases to complete.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions