@@ -18,22 +18,26 @@ import (
18
18
)
19
19
20
20
var applyCmd = & cobra.Command {
21
- Use : "apply [topic configs]" ,
22
- Short : "apply one or more topic configs" ,
23
- Args : cobra .MinimumNArgs (1 ),
24
- RunE : applyRun ,
21
+ Use : "apply [topic configs]" ,
22
+ Short : "apply one or more topic configs" ,
23
+ Args : cobra .MinimumNArgs (1 ),
24
+ PreRunE : applyPreRun ,
25
+ RunE : applyRun ,
25
26
}
26
27
27
28
type applyCmdConfig struct {
28
- brokersToRemove []int
29
- brokerThrottleMBsOverride int
30
- clusterConfig string
31
- dryRun bool
32
- partitionBatchSizeOverride int
33
- pathPrefix string
34
- rebalance bool
35
- skipConfirm bool
36
- sleepLoopTime time.Duration
29
+ brokersToRemove []int
30
+ brokerThrottleMBsOverride int
31
+ clusterConfig string
32
+ dryRun bool
33
+ partitionBatchSizeOverride int
34
+ pathPrefix string
35
+ rebalance bool
36
+ retentionDropStepDurationStr string
37
+ skipConfirm bool
38
+ sleepLoopDuration time.Duration
39
+
40
+ retentionDropStepDuration time.Duration
37
41
}
38
42
39
43
var applyConfig applyCmdConfig
@@ -69,17 +73,23 @@ func init() {
69
73
0 ,
70
74
"Partition batch size override" ,
71
75
)
76
+ applyCmd .Flags ().StringVar (
77
+ & applyConfig .pathPrefix ,
78
+ "path-prefix" ,
79
+ os .Getenv ("TOPICCTL_APPLY_PATH_PREFIX" ),
80
+ "Prefix for topic config paths" ,
81
+ )
72
82
applyCmd .Flags ().BoolVar (
73
83
& applyConfig .rebalance ,
74
84
"rebalance" ,
75
85
false ,
76
86
"Explicitly rebalance broker partition assignments" ,
77
87
)
78
88
applyCmd .Flags ().StringVar (
79
- & applyConfig .pathPrefix ,
80
- "path-prefix " ,
81
- os . Getenv ( "TOPICCTL_APPLY_PATH_PREFIX" ) ,
82
- "Prefix for topic config paths " ,
89
+ & applyConfig .retentionDropStepDurationStr ,
90
+ "retention-drop-step-duration " ,
91
+ "" ,
92
+ "Amount of time to use for retention drop steps " ,
83
93
)
84
94
applyCmd .Flags ().BoolVar (
85
95
& applyConfig .skipConfirm ,
@@ -88,15 +98,30 @@ func init() {
88
98
"Skip confirmation prompts during apply process" ,
89
99
)
90
100
applyCmd .Flags ().DurationVar (
91
- & applyConfig .sleepLoopTime ,
92
- "sleep-loop-time " ,
101
+ & applyConfig .sleepLoopDuration ,
102
+ "sleep-loop-duration " ,
93
103
10 * time .Second ,
94
104
"Amount of time to wait between partition checks" ,
95
105
)
96
106
97
107
RootCmd .AddCommand (applyCmd )
98
108
}
99
109
110
+ func applyPreRun (cmd * cobra.Command , args []string ) error {
111
+ if applyConfig .retentionDropStepDurationStr != "" {
112
+ var err error
113
+ applyConfig .retentionDropStepDuration , err = time .ParseDuration (
114
+ applyConfig .retentionDropStepDurationStr ,
115
+ )
116
+
117
+ if err != nil {
118
+ return err
119
+ }
120
+ }
121
+
122
+ return nil
123
+ }
124
+
100
125
func applyRun (cmd * cobra.Command , args []string ) error {
101
126
ctx , cancel := context .WithCancel (context .Background ())
102
127
defer cancel ()
@@ -189,8 +214,9 @@ func applyTopic(
189
214
DryRun : applyConfig .dryRun ,
190
215
PartitionBatchSizeOverride : applyConfig .partitionBatchSizeOverride ,
191
216
Rebalance : applyConfig .rebalance ,
217
+ RetentionDropStepDuration : applyConfig .retentionDropStepDuration ,
192
218
SkipConfirm : applyConfig .skipConfirm ,
193
- SleepLoopTime : applyConfig .sleepLoopTime ,
219
+ SleepLoopDuration : applyConfig .sleepLoopDuration ,
194
220
TopicConfig : topicConfig ,
195
221
}
196
222
0 commit comments