refactor component status

Signed-off-by: jeff <jeffzhang@yunify.com>
This commit is contained in:
jeff
2018-12-02 19:56:50 +08:00
parent 0dd78409e8
commit 7f688317f3
2 changed files with 62 additions and 26 deletions

View File

@@ -17,6 +17,8 @@ limitations under the License.
package controllers
import (
"errors"
"fmt"
"time"
"github.com/golang/glog"
@@ -143,3 +145,12 @@ func Run(stopChan chan struct{}, wg *sync.WaitGroup) {
}
}
}
func GetLister(controller string) (interface{}, error) {
if ctl, ok := ResourceControllers.Controllers[controller]; ok {
if ctl.Lister() != nil {
return ctl.Lister(), nil
}
}
return nil, errors.New(fmt.Sprintf("lister of %s not alive", controller))
}