Skip to content

Commit

Permalink
add ability to include double-underscore topics in bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
dtjm committed May 10, 2024
1 parent 20f0774 commit 5ad2279
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
9 changes: 9 additions & 0 deletions cmd/topicctl/subcmd/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type bootstrapCmdConfig struct {
outputDir string
overwrite bool

allowDoubleUnderscoreTopics bool

shared sharedOptions
}

Expand Down Expand Up @@ -52,6 +54,12 @@ func init() {
false,
"Overwrite existing configs in output directory",
)
// allow topics containing double underscores
bootstrapCmd.Flags().BoolVar(
&bootstrapConfig.allowDoubleUnderscoreTopics,
"allow-double-underscore-topics",
false,
"Include topics that start with __ (typically these are internal topics)")

addSharedConfigOnlyFlags(bootstrapCmd, &bootstrapConfig.shared)
bootstrapCmd.MarkFlagRequired("cluster-config")
Expand Down Expand Up @@ -92,5 +100,6 @@ func bootstrapRun(cmd *cobra.Command, args []string) error {
bootstrapConfig.excludeRegexp,
bootstrapConfig.outputDir,
bootstrapConfig.overwrite,
bootstrapConfig.allowDoubleUnderscoreTopics,
)
}
12 changes: 2 additions & 10 deletions pkg/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,7 @@ func (c *CLIRunner) DeleteACL(

// BootstrapTopics creates configs for one or more topics based on their current state in the
// cluster.
func (c *CLIRunner) BootstrapTopics(
ctx context.Context,
topics []string,
clusterConfig config.ClusterConfig,
matchRegexpStr string,
excludeRegexpStr string,
outputDir string,
overwrite bool,
) error {
func (c *CLIRunner) BootstrapTopics(ctx context.Context, topics []string, clusterConfig config.ClusterConfig, matchRegexpStr string, excludeRegexpStr string, outputDir string, overwrite bool, allowUnderscoreTopics bool) error {
topicInfoObjs, err := c.adminClient.GetTopics(ctx, topics, false)
if err != nil {
return err
Expand All @@ -226,7 +218,7 @@ func (c *CLIRunner) BootstrapTopics(
topicConfigs := []config.TopicConfig{}

for _, topicInfo := range topicInfoObjs {
if strings.HasPrefix(topicInfo.Name, "__") {
if !allowUnderscoreTopics && strings.HasPrefix(topicInfo.Name, "__") {
// Never include underscore topics
continue
} else if !matchRegexp.MatchString(topicInfo.Name) {
Expand Down

0 comments on commit 5ad2279

Please sign in to comment.