Skip to content

Commit

Permalink
Change the default broker class config
Browse files Browse the repository at this point in the history
Signed-off-by: Leo Li <leoli@redhat.com>
  • Loading branch information
Leo6Leo committed Jan 29, 2024
1 parent 66dfc36 commit 662c214
Show file tree
Hide file tree
Showing 3 changed files with 567 additions and 376 deletions.
29 changes: 28 additions & 1 deletion pkg/apis/config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,33 @@ func (d *Defaults) GetBrokerConfig(ns string, brokerClassName string) (*BrokerCo
return nil, errors.New("Defaults are nil")
}

// Check if the brokerClassName is empty
if brokerClassName == "" {
// We don't have the brokerClassName, check if we have the namespace default config
if d.NamespaceDefaultsConfig != nil {
// We have the namespace default config, check if we have the default broker class config for this namespace
value, present := d.NamespaceDefaultsConfig.NameSpaces[ns]
if present && value != nil {
// We have the default broker class config for this namespace, return the config
brokerClassName = value.DefaultBrokerClass
} else {
// We don't have the default broker class config for this namespace, check if we have the cluster default config
if d.ClusterDefaultConfig != nil && d.ClusterDefaultConfig.DefaultBrokerClassConfig != nil {
brokerClassName = d.ClusterDefaultConfig.DefaultBrokerClass
} else {
return nil, errors.New("Broker class name is empty and Defaults for Broker Configurations have not been set up. Cannot proceed further.")
}
}
} else {
// We don't have the namespace default config, check if we have the cluster default config
if d.ClusterDefaultConfig != nil && d.ClusterDefaultConfig.DefaultBrokerClassConfig != nil {
return d.ClusterDefaultConfig.DefaultBrokerClassConfig, nil
} else {
return nil, errors.New("Defaults for Broker Configurations have not been set up.")
}
}
}

value, present := d.NamespaceDefaultsConfig.NameSpaces[ns]
if present && value != nil {
// We have the namespace specific config
Expand Down Expand Up @@ -167,7 +194,7 @@ func (d *Defaults) GetBrokerConfig(ns string, brokerClassName string) (*BrokerCo
if d.ClusterDefaultConfig != nil && d.ClusterDefaultConfig.DefaultBrokerClassConfig != nil {
return d.ClusterDefaultConfig.DefaultBrokerClassConfig, nil
}
return nil, errors.New("Defaults for Broker Configurations have not been set up.")
return nil, errors.New("The given broker class name cannout be found in the namespace defaults config or cluster default config.")

}

Expand Down
Loading

0 comments on commit 662c214

Please sign in to comment.