Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 74f4e55

Browse files
committed
feat(plugins/plugin-kubectl): Add Summary impl for Events
Fixes #6839
1 parent ea90a34 commit 74f4e55

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2021 IBM Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* Last seen: 30s
19+
* Type: Warning
20+
* Reason: BackOff
21+
* Object: pod/kui-crashy
22+
* Subobject: 'spec.containers{crashy}'
23+
* Source: 'kubelet, 10.73.230.194'
24+
* Message: Back-off restarting failed container
25+
* First seen: 14d
26+
* Count: '91353'
27+
* Name: kui-crashy.165a76930800415d
28+
*
29+
*/
30+
31+
import prettyPrintMillis from 'pretty-ms'
32+
import { Event } from '../../../../model/resource'
33+
34+
export default function EventSummary(event: Event) {
35+
const {
36+
metadata,
37+
involvedObject,
38+
source,
39+
reason: Reason,
40+
type: Type,
41+
message: Message,
42+
firstTimestamp,
43+
lastTimestamp,
44+
count: Count
45+
} = event
46+
47+
return {
48+
'Last seen': prettyPrintMillis(Date.now() - new Date(lastTimestamp).getTime()),
49+
Object: `${involvedObject.kind}/${involvedObject.name}`,
50+
Type,
51+
Reason,
52+
Subobject: involvedObject.fieldPath,
53+
Source: `${source.component || ''}${source.host ? (source.component ? ', ' : '') + source.host : ''}`,
54+
Message,
55+
'First seen': prettyPrintMillis(Date.now() - new Date(firstTimestamp).getTime()),
56+
Count,
57+
Name: metadata.name
58+
}
59+
}

plugins/plugin-kubectl/src/lib/view/modes/Summary/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
isSummarizableKubeResource,
2222
isKubeResourceWithItsOwnSummary,
2323
isDeployment,
24+
isEvent,
2425
isJob,
2526
isNamespace,
2627
isNode,
@@ -29,6 +30,7 @@ import {
2930
} from '../../../model/resource'
3031

3132
import DeploymentSummary from './impl/Deployment'
33+
import EventSummary from './impl/Event'
3234
import GenericSummary from './impl/Generic'
3335
import JobSummary from './impl/Job'
3436
import NamespaceSummary from './impl/Namespace'
@@ -53,6 +55,8 @@ async function renderSummary({ REPL }: Tab, resource: KubeResource) {
5355
? PodSummary(resource)
5456
: isDeployment(resource)
5557
? DeploymentSummary(resource)
58+
: isEvent(resource)
59+
? EventSummary(resource)
5660
: isReplicaSet(resource)
5761
? ReplicaSetSummary(resource)
5862
: isNamespace(resource)

0 commit comments

Comments
 (0)