( //nolint: gocyclo,gocognit ctx context.Context, instance *postgres.Instance, pprofServer bool, skipNameValidation bool, )
| 155 | } |
| 156 | |
| 157 | func runSubCommand( //nolint: gocyclo,gocognit |
| 158 | ctx context.Context, |
| 159 | instance *postgres.Instance, |
| 160 | pprofServer bool, |
| 161 | skipNameValidation bool, |
| 162 | ) error { |
| 163 | var err error |
| 164 | |
| 165 | contextLogger := log.FromContext(ctx) |
| 166 | contextLogger.Info("Starting CloudNativePG Instance Manager", |
| 167 | "version", versions.Version, |
| 168 | "build", versions.Info, |
| 169 | "skipNameValidation", skipNameValidation) |
| 170 | |
| 171 | restConfig := config.GetConfigOrDie() |
| 172 | |
| 173 | kubeClientset, err := kubernetes.NewForConfig(restConfig) |
| 174 | if err != nil { |
| 175 | contextLogger.Error(err, "unable to create kubernetes clientset") |
| 176 | return err |
| 177 | } |
| 178 | |
| 179 | mgr, err := ctrl.NewManager(restConfig, ctrl.Options{ |
| 180 | Scheme: scheme, |
| 181 | Cache: cache.Options{ |
| 182 | ByObject: map[client.Object]cache.ByObject{ |
| 183 | &apiv1.Cluster{}: { |
| 184 | Field: fields.OneTermEqualSelector("metadata.name", instance.GetClusterName()), |
| 185 | Namespaces: map[string]cache.Config{ |
| 186 | instance.GetNamespaceName(): {}, |
| 187 | }, |
| 188 | }, |
| 189 | &apiv1.Database{}: { |
| 190 | Namespaces: map[string]cache.Config{ |
| 191 | instance.GetNamespaceName(): {}, |
| 192 | }, |
| 193 | }, |
| 194 | &apiv1.Publication{}: { |
| 195 | Namespaces: map[string]cache.Config{ |
| 196 | instance.GetNamespaceName(): {}, |
| 197 | }, |
| 198 | }, |
| 199 | &apiv1.Subscription{}: { |
| 200 | Namespaces: map[string]cache.Config{ |
| 201 | instance.GetNamespaceName(): {}, |
| 202 | }, |
| 203 | }, |
| 204 | &apiv1.DatabaseRole{}: { |
| 205 | Namespaces: map[string]cache.Config{ |
| 206 | instance.GetNamespaceName(): {}, |
| 207 | }, |
| 208 | }, |
| 209 | }, |
| 210 | }, |
| 211 | // We don't need a cache for secrets and configmap, as all reloads |
| 212 | // should be driven by changes in the Cluster we are watching |
| 213 | Client: client.Options{ |
| 214 | Cache: &client.CacheOptions{ |
no test coverage detected