feat(topic): add retention size flag for topic create#563
Merged
rkpattnaik780 merged 4 commits intomainfrom Apr 13, 2021
Merged
feat(topic): add retention size flag for topic create#563rkpattnaik780 merged 4 commits intomainfrom
rkpattnaik780 merged 4 commits intomainfrom
Conversation
craicoverflow
suggested changes
Apr 13, 2021
Contributor
craicoverflow
left a comment
There was a problem hiding this comment.
❯ rhoas kafka topic list
NAME (6) PARTITIONS RETENTION TIME (MS) RETENTION SIZE (BYTES)
---------------- ------------ --------------------- ------------------------
topic-4 100 604800000 -2
topic-5 1 604800000 -2
I should not be able to enter -2 as a value.
This flag will also be needed in the update command.
| // ValidateMessageRetentionPeriod validates the value (bytes) of the retention size | ||
| // the valid values can range from [-1,...] | ||
| func ValidateMessageRetentionSize(v interface{}) error { | ||
| retentionSizeStr := fmt.Sprintf("%v", v) |
Contributor
There was a problem hiding this comment.
nit: fmt.Sprintf is slow in comparison to other string conversions methods.
| })) | ||
| cmd.Flags().Int32Var(&opts.partitions, "partitions", 1, localizer.MustLocalizeFromID("kafka.topic.common.input.partitions.description")) | ||
| cmd.Flags().IntVar(&opts.retentionMs, "retention-ms", defaultRetentionPeriodMS, localizer.MustLocalizeFromID("kafka.topic.common.input.retentionMs.description")) | ||
| cmd.Flags().IntVar(&opts.retentionBytes, "retention-bytes", defaultRetentionSize, localizer.MustLocalizeFromID("kafka.topic.common.input.retentionBytes.description")) |
Contributor
There was a problem hiding this comment.
The flag value is not being validated anywhere, I can submit invalid values
pkg/kafka/topic/validators.go
Outdated
| return nil | ||
| } | ||
|
|
||
| // ValidateMessageRetentionPeriod validates the value (bytes) of the retention size |
Contributor
There was a problem hiding this comment.
Suggested change
| // ValidateMessageRetentionPeriod validates the value (bytes) of the retention size | |
| // ValidateMessageRetentionSize validates the value (bytes) of the retention size |
Contributor
Author
was thinking to add this to update command in a separate PR. |
Contributor
|
Okay. |
craicoverflow
approved these changes
Apr 13, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
topic createshould have a flag for setting the retention size.fixes #523
Verification Steps
--retention-bytesflag.Type of change
Checklist