Use Kubernetes API instead of API group

This commit is contained in:
Murat Kabilov
2017-05-12 11:41:36 +02:00
parent ec3f24c3ee
commit fd449342e5
6 changed files with 46 additions and 53 deletions
+15 -16
View File
@@ -20,13 +20,13 @@ import (
func (c *Controller) clusterListFunc(options api.ListOptions) (runtime.Object, error) {
c.logger.Info("Getting list of currently running clusters")
object, err := c.RestClient.Get().
Namespace(c.opConfig.Namespace).
Resource(constants.ResourceName).
req := c.RestClient.Get().
RequestURI(fmt.Sprintf(constants.ListClustersURITemplate, c.opConfig.Namespace)).
VersionedParams(&options, api.ParameterCodec).
FieldsSelectorParam(fields.Everything()).
Do().
Get()
FieldsSelectorParam(fields.Everything())
object, err := req.Do().Get()
if err != nil {
return nil, fmt.Errorf("Can't get list of postgresql objects: %s", err)
@@ -55,6 +55,15 @@ func (c *Controller) clusterListFunc(options api.ListOptions) (runtime.Object, e
return object, err
}
func (c *Controller) clusterWatchFunc(options api.ListOptions) (watch.Interface, error) {
req := c.RestClient.Get().
RequestURI(fmt.Sprintf(constants.WatchClustersURITemplate, c.opConfig.Namespace)).
VersionedParams(&options, api.ParameterCodec).
FieldsSelectorParam(fields.Everything())
return req.Watch()
}
func (c *Controller) processEvent(obj interface{}) error {
var clusterName spec.NamespacedName
@@ -184,16 +193,6 @@ func (c *Controller) queueClusterEvent(old, new *spec.Postgresql, eventType spec
c.logger.WithField("worker", workerId).Infof("%s of the '%s' cluster has been queued for", eventType, clusterName)
}
func (c *Controller) clusterWatchFunc(options api.ListOptions) (watch.Interface, error) {
return c.RestClient.Get().
Prefix("watch").
Namespace(c.opConfig.Namespace).
Resource(constants.ResourceName).
VersionedParams(&options, api.ParameterCodec).
FieldsSelectorParam(fields.Everything()).
Watch()
}
func (c *Controller) postgresqlAdd(obj interface{}) {
pg, ok := obj.(*spec.Postgresql)
if !ok {
+1 -3
View File
@@ -81,9 +81,7 @@ func (c *Controller) createTPR() error {
c.logger.Infof("ThirdPartyResource '%s' has been registered", TPRName)
}
restClient := c.RestClient
return k8sutil.WaitTPRReady(restClient, c.opConfig.TPR.ReadyWaitInterval, c.opConfig.TPR.ReadyWaitTimeout, c.opConfig.Namespace)
return k8sutil.WaitTPRReady(c.RestClient, c.opConfig.TPR.ReadyWaitInterval, c.opConfig.TPR.ReadyWaitTimeout, c.opConfig.Namespace)
}
func (c *Controller) getInfrastructureRoles() (result map[string]spec.PgUser, err error) {