Skip to content

Commit

Permalink
rpk: rename message type flags in rpk topic produce
Browse files Browse the repository at this point in the history
We are renaming to a more generic names since in
the near future we want to add support to encode
with schemas stored in files and we will use
this flag too.
  • Loading branch information
r-vasquez committed Nov 21, 2023
1 parent 0b73a4e commit 29d7243
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 9 additions & 6 deletions src/go/rpk/pkg/cli/topic/produce.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func newProduceCommand(fs afero.Fs, p *config.Params) *cobra.Command {

keySchemaID, isKeyTopicName, err := parseSchemaIDFlag(keySchemaIDFLag)
out.MaybeDie(err, "unable to parse '--schema-key-id' flag: %v", err)
schemaID, isValTopicName, err := parseSchemaIDFlag(keySchemaIDFLag)
schemaID, isValTopicName, err := parseSchemaIDFlag(schemaIDFlag)
out.MaybeDie(err, "unable to parse '--schema-id' flag: %v", err)

isSchemaRegistry := isKeyTopicName || isValTopicName || keySchemaID >= 0 || schemaID >= 0
Expand Down Expand Up @@ -256,8 +256,8 @@ func newProduceCommand(fs afero.Fs, p *config.Params) *cobra.Command {
cmd.Flags().BoolVar(&allowAutoTopicCreation, "allow-auto-topic-creation", false, "Auto-create non-existent topics; requires auto_create_topics_enabled on the broker")
cmd.Flags().StringVar(&schemaIDFlag, "schema-id", "", "Schema ID to encode the record value with, use 'topic' for TopicName strategy")
cmd.Flags().StringVar(&keySchemaIDFLag, "schema-key-id", "", "Schema ID to encode the record key with, use 'topic' for TopicName strategy")
cmd.Flags().StringVar(&protoFQN, "proto-msg-type", "", "Name of the protobuf message type to be used to encode the record value using schema registry")
cmd.Flags().StringVar(&protoKeyFQN, "proto-key-msg-type", "", "Name of the protobuf message type to be used to encode the record key using schema registry")
cmd.Flags().StringVar(&protoFQN, "schema-type", "", "Name of the protobuf message type to be used to encode the record value using schema registry")
cmd.Flags().StringVar(&protoKeyFQN, "schema-key-type", "", "Name of the protobuf message type to be used to encode the record key using schema registry")

// Deprecated
cmd.Flags().IntVarP(new(int), "num", "n", 1, "")
Expand Down Expand Up @@ -431,9 +431,12 @@ Produce to 'foo', encode using the latest schema in the subject 'foo-value':
rpk topic produce foo --schema-id=topic
For protobuf schemas, you can specify the fully qualified name of the message
you want the record to be encoded with. Use the 'proto-msg-type' flag or
'proto-key-msg-type'. If the schema contains only one message, specifying the
message name is unnecessary.
you want the record to be encoded with. Use the 'schema-type' flag or
'schema-key-type'. If the schema contains only one message, specifying the
message name is unnecessary. For example:
Produce to 'foo', using schema ID 1, message FQN Person.Name
rpk topic produce foo --schema-id 1 --schema-type Person.Name
EXAMPLES
Expand Down
4 changes: 2 additions & 2 deletions tests/rptest/clients/rpk.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,10 @@ def produce(self,
cmd += ["--schema-key-id", f'{schema_key_id}']
use_schema_registry = True
if proto_msg is not None:
cmd += ["--proto-msg-type", proto_msg]
cmd += ["--schema-type", proto_msg]
use_schema_registry = True
if proto_key_msg is not None:
cmd += ["--proto-key-msg-type", proto_key_msg]
cmd += ["--schema-key-type", proto_key_msg]
use_schema_registry = True

# Run remote process with a slightly higher timeout than the
Expand Down

0 comments on commit 29d7243

Please sign in to comment.