This commit is contained in:
Shuxian 2025-05-24 22:51:04 +02:00 committed by GitHub
commit f6b84e7501
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 3 deletions

View File

@ -122,9 +122,9 @@ type Reference struct {
Policy *Policy `json:"policy,omitempty"`
}
// A TypedReference refers to an object by Name, Kind, and APIVersion. It is
// commonly used to reference cluster-scoped objects or objects where the
// namespace is already known.
// A TypedReference refers to an object by Name, Namespace, Kind, and
// APIVersion. It is commonly used to reference cluster-scoped objects
// and can also be used for namespace-scoped objects.
type TypedReference struct {
// APIVersion of the referenced object.
APIVersion string `json:"apiVersion"`
@ -135,6 +135,10 @@ type TypedReference struct {
// Name of the referenced object.
Name string `json:"name"`
// Namespace of the referenced object.
// +optional
Namespace string `json:"namespace,omitempty"`
// UID of the referenced object.
// +optional
UID types.UID `json:"uid,omitempty"`

View File

@ -87,6 +87,7 @@ func TypedReferenceTo(o metav1.Object, of schema.GroupVersionKind) *xpv1.TypedRe
APIVersion: v,
Kind: k,
Name: o.GetName(),
Namespace: o.GetNamespace(),
UID: o.GetUID(),
}
}

View File

@ -112,6 +112,7 @@ func TestTypedReferenceTo(t *testing.T) {
want: &xpv1.TypedReference{
APIVersion: groupVersion,
Kind: kind,
Namespace: namespace,
Name: name,
UID: uid,
},