MCPcopy
hub / github.com/redpanda-data/console / NewTopicConfigEntry

Function NewTopicConfigEntry

backend/pkg/console/topic_config.go:51–100  ·  view source on GitHub ↗

NewTopicConfigEntry creates a new instance for a TopicConfigEntry. The function is in charge of computing additional properties based on existing other properties, as well as enriching the giving describe configs response with properties from our own config extensions.

(
	cfg kmsg.DescribeConfigsResponseResourceConfig,
	extension ConfigEntryExtension,
)

Source from the content-addressed store, hash-verified

49// properties, as well as enriching the giving describe configs response with
50// properties from our own config extensions.
51func NewTopicConfigEntry(
52 cfg kmsg.DescribeConfigsResponseResourceConfig,
53 extension ConfigEntryExtension,
54) *TopicConfigEntry {
55 isDefaultValue := false
56 innerEntries := make([]TopicConfigSynonym, len(cfg.ConfigSynonyms))
57 for j, innerCfg := range cfg.ConfigSynonyms {
58 innerEntries[j] = TopicConfigSynonym{
59 Name: innerCfg.Name,
60 Value: innerCfg.Value,
61 Source: innerCfg.Source.String(),
62 }
63 if innerCfg.Source == kmsg.ConfigSourceDefaultConfig {
64 isDefaultValue = derefString(cfg.Value) == derefString(innerCfg.Value)
65 }
66 }
67
68 var isExplicitlySet bool
69 if cfg.Source == kmsg.ConfigSourceUnknown {
70 // Kafka <v1.1 uses the IsDefault property. Since then, it's been replaced by ConfigSource and defaults
71 // to false. Thus, we only consider it if cfg.Source is not set / unknown.
72 isExplicitlySet = !cfg.IsDefault
73 } else {
74 isExplicitlySet = cfg.Source == kmsg.ConfigSourceDynamicTopicConfig
75 }
76
77 documentation := cfg.Documentation
78 if documentation == nil {
79 documentation = extension.Documentation
80 }
81 configType := cfg.ConfigType
82 if configType == kmsg.ConfigTypeUnknown {
83 configType = extension.Type
84 }
85 extension.FrontendFormat = FrontendFormatFromValueType(configType, extension.FrontendFormat)
86
87 return &TopicConfigEntry{
88 Name: cfg.Name,
89 Value: cfg.Value,
90 Source: cfg.Source.String(),
91 Type: configType.String(),
92 IsExplicitlySet: isExplicitlySet,
93 IsDefaultValue: isDefaultValue,
94 IsSensitive: cfg.IsSensitive,
95 IsReadOnly: cfg.ReadOnly,
96 Documentation: documentation,
97 Synonyms: innerEntries,
98 ConfigEntryExtension: extension,
99 }
100}
101
102// TopicConfigSynonym is a synonym for a topic configuration.
103type TopicConfigSynonym struct {

Callers 1

GetTopicsConfigsMethod · 0.85

Calls 3

derefStringFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…