operator-framework / operator-sdk

SDK for building Kubernetes applications. Provides high level APIs, useful abstractions, and project scaffolding.
https://sdk.operatorframework.io
Apache License 2.0
7.21k stars 1.74k forks source link

MultiNamespacedCacheBuilder is deprecated and can't be used to define the operator scope #6715

Closed snorwin closed 5 months ago

snorwin commented 6 months ago

What is the URL of the document?

https://sdk.operatorframework.io/docs/building-operators/golang/operator-scope/#watching-resources-in-a-set-of-namespaces

Which section(s) is the issue in?

Watching resources in a set of Namespaces

What needs fixing?

MultiNamespacedCacheBuilder is deprecated and removed since controller-runtiime v0.16.0 . It would be great if the example is updated using cache.Options.Namespace instead.

NewCache: func(config *rest.Config, opts cache.Options) (cache.Cache, error) {
    opts.DefaultNamespaces = map[string]cache.Config{
        "my-ns": cache.Config{},
    }
    return cache.New(config, opts)
},

Additional context

https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.15.3/pkg/cache#MultiNamespacedCacheBuilder

snorwin commented 5 months ago

6719