File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -257,6 +257,12 @@ func probeVersion(cl *client.Client) {
257
257
fmt .Println ("Kafka " + v .VersionGuess ())
258
258
}
259
259
260
+ type pinReq struct {
261
+ kmsg.Request
262
+ }
263
+
264
+ func (* pinReq ) SetVersion (int16 ) {}
265
+
260
266
func rawCommand (cl * client.Client ) * cobra.Command {
261
267
var key int16
262
268
var b int
@@ -269,9 +275,16 @@ func rawCommand(cl *client.Client) *cobra.Command {
269
275
if req == nil {
270
276
out .Die ("request key %d unknown" , key )
271
277
}
278
+ req .SetVersion (- 1 )
272
279
raw , err := io .ReadAll (os .Stdin )
273
280
out .MaybeDie (err , "unable to read stdin: %v" , err )
274
281
err = json .Unmarshal (raw , req )
282
+ // If the raw json specified a Version field, it
283
+ // overwrote our -1. We want to pin the version to
284
+ // what the user specified.
285
+ if req .GetVersion () != - 1 {
286
+ req = & pinReq {req }
287
+ }
275
288
out .MaybeDie (err , "unable to unmarshal stdin: %v" , err )
276
289
ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Second )
277
290
defer cancel ()
You can’t perform that action at this time.
0 commit comments