Skip to content

Commit 90b49e8

Browse files
committed
add warning on ObjectReference
1 parent 81acde7 commit 90b49e8

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

staging/src/k8s.io/api/core/v1/generated.proto

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/api/core/v1/types.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4981,6 +4981,20 @@ type ServiceProxyOptions struct {
49814981
}
49824982

49834983
// ObjectReference contains enough information to let you inspect or modify the referred object.
4984+
// ---
4985+
// New uses of this type are discouraged because of difficulty describing its usage when embedded in APIs.
4986+
// 1. Ignored fields. It includes many fields which are not generally honored. For instance, ResourceVersion and FieldPath are both very rarely valid in actual usage.
4987+
// 2. Invalid usage help. It is impossible to add specific help for individual usage. In most embedded usages, there are particular
4988+
// restrictions like, "must refer only to types A and B" or "UID not honored" or "name must be restricted".
4989+
// Those cannot be well described when embedded.
4990+
// 3. Inconsistent validation. Because the usages are different, the validation rules are different by usage, which makes it hard for users to predict what will happen.
4991+
// 4. The fields are both imprecise and overly precise. Kind is not a precise mapping to a URL. This can produce ambiguity
4992+
// during interpretation and require a REST mapping. In most cases, the dependency is on the group,resource tuple
4993+
// and the version of the actual struct is irrelevant.
4994+
// 5. We cannot easily change it. Because this type is embedded in many locations, updates to this type
4995+
// will affect numerous schemas. Don't make new APIs embed an underspecified API type they do not control.
4996+
// Instead of using this type, create a locally provided and used type that is well-focused on your reference.
4997+
// For example, ServiceReferences for admission registration: https://github.com/kubernetes/api/blob/release-1.17/admissionregistration/v1/types.go#L533 .
49844998
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
49854999
type ObjectReference struct {
49865000
// Kind of the referent.

0 commit comments

Comments
 (0)