more fixes on clientSet vs getters
This commit is contained in:
		
							parent
							
								
									37bc33d176
								
							
						
					
					
						commit
						ec0d8f8aec
					
				| 
						 | 
					@ -398,6 +398,11 @@ func (c *Cluster) syncStatefulSet() error {
 | 
				
			||||||
// AnnotationsToPropagate get the annotations to update if required
 | 
					// AnnotationsToPropagate get the annotations to update if required
 | 
				
			||||||
// based on the annotations in postgres CRD
 | 
					// based on the annotations in postgres CRD
 | 
				
			||||||
func (c *Cluster) AnnotationsToPropagate(annotations map[string]string) map[string]string {
 | 
					func (c *Cluster) AnnotationsToPropagate(annotations map[string]string) map[string]string {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if annotations == nil {
 | 
				
			||||||
 | 
							annotations = make(map[string]string)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	toPropagateAnnotations := c.OpConfig.DownscalerAnnotations
 | 
						toPropagateAnnotations := c.OpConfig.DownscalerAnnotations
 | 
				
			||||||
	pgCRDAnnotations := c.Postgresql.ObjectMeta.GetAnnotations()
 | 
						pgCRDAnnotations := c.Postgresql.ObjectMeta.GetAnnotations()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,7 +15,7 @@ import (
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *Controller) readOperatorConfigurationFromCRD(configObjectNamespace, configObjectName string) (*acidv1.OperatorConfiguration, error) {
 | 
					func (c *Controller) readOperatorConfigurationFromCRD(configObjectNamespace, configObjectName string) (*acidv1.OperatorConfiguration, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	config, err := c.KubeClient.AcidV1ClientSet.AcidV1().OperatorConfigurations(configObjectNamespace).Get(
 | 
						config, err := c.KubeClient.OperatorConfigurationsGetter.OperatorConfigurations(configObjectNamespace).Get(
 | 
				
			||||||
		context.TODO(), configObjectName, metav1.GetOptions{})
 | 
							context.TODO(), configObjectName, metav1.GetOptions{})
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("could not get operator configuration object %q: %v", configObjectName, err)
 | 
							return nil, fmt.Errorf("could not get operator configuration object %q: %v", configObjectName, err)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -46,7 +46,7 @@ func (c *Controller) listClusters(options metav1.ListOptions) (*acidv1.Postgresq
 | 
				
			||||||
	var pgList acidv1.PostgresqlList
 | 
						var pgList acidv1.PostgresqlList
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// TODO: use the SharedInformer cache instead of quering Kubernetes API directly.
 | 
						// TODO: use the SharedInformer cache instead of quering Kubernetes API directly.
 | 
				
			||||||
	list, err := c.KubeClient.AcidV1ClientSet.AcidV1().Postgresqls(c.opConfig.WatchedNamespace).List(context.TODO(), options)
 | 
						list, err := c.KubeClient.PostgresqlsGetter.Postgresqls(c.opConfig.WatchedNamespace).List(context.TODO(), options)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.logger.Errorf("could not list postgresql objects: %v", err)
 | 
							c.logger.Errorf("could not list postgresql objects: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -398,7 +398,7 @@ func (c *Controller) loadPostgresTeams() {
 | 
				
			||||||
	// reset team map
 | 
						// reset team map
 | 
				
			||||||
	c.pgTeamMap = teams.PostgresTeamMap{}
 | 
						c.pgTeamMap = teams.PostgresTeamMap{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pgTeams, err := c.KubeClient.AcidV1ClientSet.AcidV1().PostgresTeams(c.opConfig.WatchedNamespace).List(context.TODO(), metav1.ListOptions{})
 | 
						pgTeams, err := c.KubeClient.PostgresTeamsGetter.PostgresTeams(c.opConfig.WatchedNamespace).List(context.TODO(), metav1.ListOptions{})
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.logger.Errorf("could not list postgres team objects: %v", err)
 | 
							c.logger.Errorf("could not list postgres team objects: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -59,7 +59,8 @@ type KubernetesClient struct {
 | 
				
			||||||
	acidv1.PostgresTeamsGetter
 | 
						acidv1.PostgresTeamsGetter
 | 
				
			||||||
	acidv1.PostgresqlsGetter
 | 
						acidv1.PostgresqlsGetter
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	RESTClient rest.Interface
 | 
						RESTClient      rest.Interface
 | 
				
			||||||
 | 
						AcidV1ClientSet *acidv1client.Clientset
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type mockSecret struct {
 | 
					type mockSecret struct {
 | 
				
			||||||
| 
						 | 
					@ -157,14 +158,14 @@ func NewFromConfig(cfg *rest.Config) (KubernetesClient, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kubeClient.CustomResourceDefinitionsGetter = apiextClient.ApiextensionsV1()
 | 
						kubeClient.CustomResourceDefinitionsGetter = apiextClient.ApiextensionsV1()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	acidClient, err := acidv1client.NewForConfig(cfg)
 | 
						kubeClient.AcidV1ClientSet = acidv1client.NewForConfigOrDie(cfg)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return kubeClient, fmt.Errorf("could not create acid.zalan.do clientset: %v", err)
 | 
							return kubeClient, fmt.Errorf("could not create acid.zalan.do clientset: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kubeClient.OperatorConfigurationsGetter = acidClient.AcidV1()
 | 
						kubeClient.OperatorConfigurationsGetter = kubeClient.AcidV1ClientSet.AcidV1()
 | 
				
			||||||
	kubeClient.PostgresTeamsGetter = acidClient.AcidV1()
 | 
						kubeClient.PostgresTeamsGetter = kubeClient.AcidV1ClientSet.AcidV1()
 | 
				
			||||||
	kubeClient.PostgresqlsGetter = acidClient.AcidV1()
 | 
						kubeClient.PostgresqlsGetter = kubeClient.AcidV1ClientSet.AcidV1()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return kubeClient, nil
 | 
						return kubeClient, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue