@@ -232,42 +232,46 @@ func PreferredSerializationOrder(client discovery.DiscoveryInterface) []schema.G
232
232
return ret
233
233
}
234
234
235
- func NewPrintNameOrErrorAfterIndent (mapper meta. RESTMapper , short bool , operation string , out , errs io.Writer , dryRun bool , indent string , prefixForError PrefixForError ) AfterFunc {
235
+ func NewPrintNameOrErrorAfterIndent (short bool , operation string , out , errs io.Writer , dryRun bool , indent string , prefixForError PrefixForError ) AfterFunc {
236
236
return func (info * resource.Info , err error ) bool {
237
237
if err == nil {
238
238
fmt .Fprintf (out , indent )
239
- printSuccess (mapper , short , out , info .Mapping .Resource , info .Name , dryRun , operation )
239
+ printSuccess (short , out , info .Mapping .GroupVersionKind , info .Name , dryRun , operation )
240
240
} else {
241
241
fmt .Fprintf (errs , "%s%s: %v\n " , indent , prefixForError (err ), err )
242
242
}
243
243
return false
244
244
}
245
245
}
246
246
247
- func printSuccess (mapper meta.RESTMapper , shortOutput bool , out io.Writer , resource , name string , dryRun bool , operation string ) {
248
- resource , _ = mapper .ResourceSingularizer (resource )
247
+ func printSuccess (shortOutput bool , out io.Writer , gvk schema.GroupVersionKind , name string , dryRun bool , operation string ) {
248
+ kindString := gvk .Kind
249
+ if len (gvk .Group ) > 0 {
250
+ kindString = gvk .Kind + "." + gvk .Group
251
+ }
252
+
249
253
dryRunMsg := ""
250
254
if dryRun {
251
255
dryRunMsg = " (dry run)"
252
256
}
253
257
if shortOutput {
254
258
// -o name: prints resource/name
255
- if len (resource ) > 0 {
256
- fmt .Fprintf (out , "%s/%s\n " , resource , name )
259
+ if len (kindString ) > 0 {
260
+ fmt .Fprintf (out , "%s/%s\n " , kindString , name )
257
261
} else {
258
262
fmt .Fprintf (out , "%s\n " , name )
259
263
}
260
264
} else {
261
265
// understandable output by default
262
- if len (resource ) > 0 {
263
- fmt .Fprintf (out , "%s \" %s\" %s%s\n " , resource , name , operation , dryRunMsg )
266
+ if len (kindString ) > 0 {
267
+ fmt .Fprintf (out , "%s \" %s\" %s%s\n " , kindString , name , operation , dryRunMsg )
264
268
} else {
265
269
fmt .Fprintf (out , "\" %s\" %s%s\n " , name , operation , dryRunMsg )
266
270
}
267
271
}
268
272
}
269
273
270
- func NewPrintErrorAfter (mapper meta. RESTMapper , errs io.Writer , prefixForError PrefixForError ) func (* resource.Info , error ) bool {
274
+ func NewPrintErrorAfter (errs io.Writer , prefixForError PrefixForError ) func (* resource.Info , error ) bool {
271
275
return func (info * resource.Info , err error ) bool {
272
276
if err != nil {
273
277
fmt .Fprintf (errs , "%s: %v\n " , prefixForError (err ), err )
@@ -390,12 +394,12 @@ func (b BulkAction) WithMessageAndPrefix(action, individual string, prefixForErr
390
394
switch {
391
395
// TODO: this should be b printer
392
396
case b .Output == "" :
393
- b .Bulk .After = NewPrintNameOrErrorAfterIndent (b . Bulk . Mapper , false , individual , b .Out , b .ErrOut , b .DryRun , b .DefaultIndent (), prefixForError )
397
+ b .Bulk .After = NewPrintNameOrErrorAfterIndent (false , individual , b .Out , b .ErrOut , b .DryRun , b .DefaultIndent (), prefixForError )
394
398
// TODO: needs to be unified with the name printer (incremental vs exact execution), possibly by creating b synthetic printer?
395
399
case b .Output == "name" :
396
- b .Bulk .After = NewPrintNameOrErrorAfterIndent (b . Bulk . Mapper , true , individual , b .Out , b .ErrOut , b .DryRun , b .DefaultIndent (), prefixForError )
400
+ b .Bulk .After = NewPrintNameOrErrorAfterIndent (true , individual , b .Out , b .ErrOut , b .DryRun , b .DefaultIndent (), prefixForError )
397
401
default :
398
- b .Bulk .After = NewPrintErrorAfter (b .Bulk . Mapper , b . ErrOut , prefixForError )
402
+ b .Bulk .After = NewPrintErrorAfter (b .ErrOut , prefixForError )
399
403
if b .StopOnError {
400
404
b .Bulk .After = HaltOnError (b .Bulk .After )
401
405
}
0 commit comments