|
| 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 | +} |
0 commit comments