Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap isSecure config in config map for kafka topic #5474

Merged
merged 5 commits into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions common/config/kafkaConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ type (
// TopicConfig describes the mapping from topic to Kafka cluster
TopicConfig struct {
Cluster string `yaml:"cluster"`
// IsSecure describes whether the topic is secure, by default it is false
// If it is set to true, it allows to pass in the token to initialize secure producer for this topic
IsSecure bool `yaml:"isSecure,omitempty"`
// Properties map describes whether the topic properties, such as whether it is secure
Properties map[string]any `yaml:"properties,omitempty"`
}

// TopicList describes the topic names for each cluster
Expand Down Expand Up @@ -103,7 +102,20 @@ func (k *KafkaConfig) GetTopicsForApplication(app string) TopicList {
return k.Applications[app]
}

// GetKafkaClusterSecureConfigForTopic gets isSecure status from topic
func (k *KafkaConfig) GetKafkaSecureConfigForTopic(topic string) bool {
return k.Topics[topic].IsSecure
// GetKafkaPropertiesForTopic gets properties from topic
func (k *KafkaConfig) GetKafkaPropertyForTopic(topic string, property string) any {
topicConfig, ok := k.Topics[topic]
if !ok || topicConfig.Properties == nil {
// No properties for the specified topic in the config
return nil
neil-xie marked this conversation as resolved.
Show resolved Hide resolved
}

// retrieve the property from the topic properties
propertyValue, ok := topicConfig.Properties[property]
if !ok {
// Property not found
return nil
}

return propertyValue
}