From 07d0b4a8bcbb0ebd942ed485376e3f08cdf3b43e Mon Sep 17 00:00:00 2001 From: Yashvardhan Kukreja Date: Sat, 19 Sep 2020 07:19:20 +0530 Subject: [PATCH] Cleaned up and fixed: the potentially misleading comments around Event struct --- api/openapi-spec/swagger.json | 8 +++++--- pkg/apis/core/types.go | 4 ++-- staging/src/k8s.io/api/events/v1/generated.proto | 11 +++-------- staging/src/k8s.io/api/events/v1/types.go | 14 +++++--------- .../api/events/v1/types_swagger_doc_generated.go | 6 +++--- .../src/k8s.io/api/events/v1beta1/generated.proto | 1 - staging/src/k8s.io/api/events/v1beta1/types.go | 4 ++-- 7 files changed, 20 insertions(+), 28 deletions(-) diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index f8ab26b920b9..d667ae498ee4 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -10898,7 +10898,7 @@ "description": "Event is a report of an event somewhere in the cluster. It generally denotes some state change in the system.", "properties": { "action": { - "description": "action is what action was taken/failed regarding to the regarding object. It is machine-readable. This field can have at most 128 characters.", + "description": "action is what action was taken/failed regarding to the regarding object. It is machine-readable. This field cannot be empty for new Events and it can have at most 128 characters.", "type": "string" }, "apiVersion": { @@ -10938,7 +10938,7 @@ "type": "string" }, "reason": { - "description": "reason is why the action was taken. It is human-readable. This field can have at most 128 characters.", + "description": "reason is why the action was taken. It is human-readable. This field cannot be empty for new Events and it can have at most 128 characters.", "type": "string" }, "regarding": { @@ -10962,11 +10962,12 @@ "description": "series is data about the Event series this event represents or nil if it's a singleton Event." }, "type": { - "description": "type is the type of this event (Normal, Warning), new types could be added in the future. It is machine-readable.", + "description": "type is the type of this event (Normal, Warning), new types could be added in the future. It is machine-readable. This field cannot be empty for new Events.", "type": "string" } }, "required": [ + "metadata", "eventTime" ], "type": "object", @@ -11105,6 +11106,7 @@ } }, "required": [ + "metadata", "eventTime" ], "type": "object", diff --git a/pkg/apis/core/types.go b/pkg/apis/core/types.go index 0f777c799320..87805bfecf55 100644 --- a/pkg/apis/core/types.go +++ b/pkg/apis/core/types.go @@ -4568,10 +4568,10 @@ const ( // TODO: Decide whether to store these separately or with the object they apply to. type Event struct { metav1.TypeMeta - // +optional + metav1.ObjectMeta - // Required. The object that this event is about. Mapped to events.Event.regarding + // The object that this event is about. Mapped to events.Event.regarding // +optional InvolvedObject ObjectReference diff --git a/staging/src/k8s.io/api/events/v1/generated.proto b/staging/src/k8s.io/api/events/v1/generated.proto index 33bcc7ff0607..c9404c90aada 100644 --- a/staging/src/k8s.io/api/events/v1/generated.proto +++ b/staging/src/k8s.io/api/events/v1/generated.proto @@ -31,7 +31,6 @@ option go_package = "v1"; // Event is a report of an event somewhere in the cluster. It generally denotes some state change in the system. message Event { - // +optional optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1; // eventTime is the time when this Event was first observed. It is required. @@ -43,22 +42,18 @@ message Event { // reportingController is the name of the controller that emitted this Event, e.g. `kubernetes.io/kubelet`. // This field cannot be empty for new Events. - // +optional optional string reportingController = 4; // reportingInstance is the ID of the controller instance, e.g. `kubelet-xyzf`. // This field cannot be empty for new Events and it can have at most 128 characters. - // +optional optional string reportingInstance = 5; // action is what action was taken/failed regarding to the regarding object. It is machine-readable. - // This field can have at most 128 characters. - // +optional + // This field cannot be empty for new Events and it can have at most 128 characters. optional string action = 6; // reason is why the action was taken. It is human-readable. - // This field can have at most 128 characters. - // +optional + // This field cannot be empty for new Events and it can have at most 128 characters. optional string reason = 7; // regarding contains the object this Event is about. In most cases it's an Object reporting controller @@ -80,7 +75,7 @@ message Event { // type is the type of this event (Normal, Warning), new types could be added in the future. // It is machine-readable. - // +optional + // This field cannot be empty for new Events. optional string type = 11; // deprecatedSource is the deprecated field assuring backward compatibility with core.v1 Event type. diff --git a/staging/src/k8s.io/api/events/v1/types.go b/staging/src/k8s.io/api/events/v1/types.go index 07ede554224a..f11c2799803d 100644 --- a/staging/src/k8s.io/api/events/v1/types.go +++ b/staging/src/k8s.io/api/events/v1/types.go @@ -27,8 +27,8 @@ import ( // Event is a report of an event somewhere in the cluster. It generally denotes some state change in the system. type Event struct { metav1.TypeMeta `json:",inline"` - // +optional - metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + metav1.ObjectMeta `json:"metadata" protobuf:"bytes,1,opt,name=metadata"` // eventTime is the time when this Event was first observed. It is required. EventTime metav1.MicroTime `json:"eventTime" protobuf:"bytes,2,opt,name=eventTime"` @@ -39,22 +39,18 @@ type Event struct { // reportingController is the name of the controller that emitted this Event, e.g. `kubernetes.io/kubelet`. // This field cannot be empty for new Events. - // +optional ReportingController string `json:"reportingController,omitempty" protobuf:"bytes,4,opt,name=reportingController"` // reportingInstance is the ID of the controller instance, e.g. `kubelet-xyzf`. // This field cannot be empty for new Events and it can have at most 128 characters. - // +optional ReportingInstance string `json:"reportingInstance,omitempty" protobuf:"bytes,5,opt,name=reportingInstance"` // action is what action was taken/failed regarding to the regarding object. It is machine-readable. - // This field can have at most 128 characters. - // +optional + // This field cannot be empty for new Events and it can have at most 128 characters. Action string `json:"action,omitempty" protobuf:"bytes,6,name=action"` // reason is why the action was taken. It is human-readable. - // This field can have at most 128 characters. - // +optional + // This field cannot be empty for new Events and it can have at most 128 characters. Reason string `json:"reason,omitempty" protobuf:"bytes,7,name=reason"` // regarding contains the object this Event is about. In most cases it's an Object reporting controller @@ -76,7 +72,7 @@ type Event struct { // type is the type of this event (Normal, Warning), new types could be added in the future. // It is machine-readable. - // +optional + // This field cannot be empty for new Events. Type string `json:"type,omitempty" protobuf:"bytes,11,opt,name=type"` // deprecatedSource is the deprecated field assuring backward compatibility with core.v1 Event type. diff --git a/staging/src/k8s.io/api/events/v1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/events/v1/types_swagger_doc_generated.go index e0467436ed02..67105272a8df 100644 --- a/staging/src/k8s.io/api/events/v1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/events/v1/types_swagger_doc_generated.go @@ -33,12 +33,12 @@ var map_Event = map[string]string{ "series": "series is data about the Event series this event represents or nil if it's a singleton Event.", "reportingController": "reportingController is the name of the controller that emitted this Event, e.g. `kubernetes.io/kubelet`. This field cannot be empty for new Events.", "reportingInstance": "reportingInstance is the ID of the controller instance, e.g. `kubelet-xyzf`. This field cannot be empty for new Events and it can have at most 128 characters.", - "action": "action is what action was taken/failed regarding to the regarding object. It is machine-readable. This field can have at most 128 characters.", - "reason": "reason is why the action was taken. It is human-readable. This field can have at most 128 characters.", + "action": "action is what action was taken/failed regarding to the regarding object. It is machine-readable. This field cannot be empty for new Events and it can have at most 128 characters.", + "reason": "reason is why the action was taken. It is human-readable. This field cannot be empty for new Events and it can have at most 128 characters.", "regarding": "regarding contains the object this Event is about. In most cases it's an Object reporting controller implements, e.g. ReplicaSetController implements ReplicaSets and this event is emitted because it acts on some changes in a ReplicaSet object.", "related": "related is the optional secondary object for more complex actions. E.g. when regarding object triggers a creation or deletion of related object.", "note": "note is a human-readable description of the status of this operation. Maximal length of the note is 1kB, but libraries should be prepared to handle values up to 64kB.", - "type": "type is the type of this event (Normal, Warning), new types could be added in the future. It is machine-readable.", + "type": "type is the type of this event (Normal, Warning), new types could be added in the future. It is machine-readable. This field cannot be empty for new Events.", "deprecatedSource": "deprecatedSource is the deprecated field assuring backward compatibility with core.v1 Event type.", "deprecatedFirstTimestamp": "deprecatedFirstTimestamp is the deprecated field assuring backward compatibility with core.v1 Event type.", "deprecatedLastTimestamp": "deprecatedLastTimestamp is the deprecated field assuring backward compatibility with core.v1 Event type.", diff --git a/staging/src/k8s.io/api/events/v1beta1/generated.proto b/staging/src/k8s.io/api/events/v1beta1/generated.proto index 74389a79b066..465b8f3c4699 100644 --- a/staging/src/k8s.io/api/events/v1beta1/generated.proto +++ b/staging/src/k8s.io/api/events/v1beta1/generated.proto @@ -31,7 +31,6 @@ option go_package = "v1beta1"; // Event is a report of an event somewhere in the cluster. It generally denotes some state change in the system. message Event { - // +optional optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1; // eventTime is the time when this Event was first observed. It is required. diff --git a/staging/src/k8s.io/api/events/v1beta1/types.go b/staging/src/k8s.io/api/events/v1beta1/types.go index e2ed214b0639..dce4e21dfd05 100644 --- a/staging/src/k8s.io/api/events/v1beta1/types.go +++ b/staging/src/k8s.io/api/events/v1beta1/types.go @@ -29,8 +29,8 @@ import ( // Event is a report of an event somewhere in the cluster. It generally denotes some state change in the system. type Event struct { metav1.TypeMeta `json:",inline"` - // +optional - metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + metav1.ObjectMeta `json:"metadata" protobuf:"bytes,1,opt,name=metadata"` // eventTime is the time when this Event was first observed. It is required. EventTime metav1.MicroTime `json:"eventTime" protobuf:"bytes,2,opt,name=eventTime"`