@@ -236,10 +236,17 @@ func RunPlugin(f cmdutil.Factory, cmd *cobra.Command, args []string) error {
236
236
continue
237
237
}
238
238
tmpl := template .Must (template .
239
- New ("template " ).
239
+ New ("templates " ).
240
240
Funcs (sprig .TxtFuncMap ()).
241
241
Funcs (funcMap ).
242
242
Parse (`
243
+ {{- define "DefaultResource" }}
244
+ {{- template "status_summary_line" . }}
245
+ {{- template "observed_generation_summary" . }}
246
+ {{- template "replicas_status" . }}
247
+ {{- template "conditions_summary" . }}
248
+ {{- end }}
249
+
243
250
{{- define "Pod" }}
244
251
{{- $created := .metadata.creationTimestamp | toDate "2006-01-02T15:04:05Z" }}
245
252
{{- $started := .status.startTime | toDate "2006-01-02T15:04:05Z" }}
@@ -263,26 +270,6 @@ func RunPlugin(f cmdutil.Factory, cmd *cobra.Command, args []string) error {
263
270
{{- end }}
264
271
{{- end }}
265
272
266
- {{- define "ReplicaSet" }}
267
- {{- template "status_summary_line" . }}
268
- {{- template "observed_generation_summary" . }}
269
- {{- template "replicas_status" . }}
270
- {{- end -}}
271
-
272
- {{- define "Deployment" }}
273
- {{- template "status_summary_line" . }}
274
- {{- template "observed_generation_summary" . }}
275
- {{- template "replicas_status" . }}
276
- {{- template "conditions_summary" . }}
277
- {{- end -}}
278
-
279
- {{- define "StatefulSet" }}
280
- {{- template "status_summary_line" . }}
281
- {{- template "observed_generation_summary" . }}
282
- {{- template "replicas_status" . }}
283
- {{- template "conditions_summary" . }}
284
- {{- end -}}
285
-
286
273
{{- define "DaemonSet" }}
287
274
{{- template "status_summary_line" . }}
288
275
{{- template "observed_generation_summary" . }}
@@ -412,7 +399,13 @@ func RunPlugin(f cmdutil.Factory, cmd *cobra.Command, args []string) error {
412
399
{{- template "conditions_summary" . }}
413
400
{{- end -}}` ))
414
401
kind := info .ResourceMapping ().GroupVersionKind .Kind
415
- err = tmpl .ExecuteTemplate (os .Stderr , kind , out )
402
+ var kindTemplateName string
403
+ if t := tmpl .Lookup (kind ); t != nil {
404
+ kindTemplateName = kind
405
+ } else {
406
+ kindTemplateName = "DefaultResource"
407
+ }
408
+ err = tmpl .ExecuteTemplate (os .Stderr , kindTemplateName , out )
416
409
if err != nil {
417
410
if errs .Has (err .Error ()) {
418
411
continue
0 commit comments