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

Fix: Initialise default namespaces map config #5424

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 3 additions & 1 deletion component/loki/source/kubernetes_events/event_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ func (ctrl *eventController) runError(ctx context.Context) error {
}

defaultNamespaces := map[string]cache.Config{}
defaultNamespaces[ctrl.task.Namespace] = cache.Config{}
if ctrl.task.Namespace != "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not initialise the map if the string is empty (and move the initialization inside this if clause?

defaultNamespaces[ctrl.task.Namespace] = cache.Config{}
}
opts := cache.Options{
Scheme: scheme,
DefaultNamespaces: defaultNamespaces,
Expand Down
5 changes: 4 additions & 1 deletion pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ func (c *Config) registerFlags(f *flag.FlagSet) error {

c.Controller.WebhookServer = webhook.NewServer(webhookServerOptions)

c.Controller.Cache.DefaultNamespaces[namespace] = cache.Config{}
if namespace != "" {
c.Controller.Cache.DefaultNamespaces = map[string]cache.Config{}
c.Controller.Cache.DefaultNamespaces[namespace] = cache.Config{}
}

// Custom initial values for the endpoint names.
c.Controller.ReadinessEndpointName = "/-/ready"
Expand Down