mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-04 04:38:04 +08:00
[ADD] add test code
This commit is contained in:
parent
04de79df61
commit
eafe732fab
32
appruntimesync/clean/clean.go
Normal file
32
appruntimesync/clean/clean.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package clean
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/client-go/kubernetes"
|
||||||
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"fmt"
|
||||||
|
"github.com/Sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CheanManager struct {
|
||||||
|
kubeclient *kubernetes.Clientset
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCheanManager(kubeclient *kubernetes.Clientset) *CheanManager {
|
||||||
|
m := &CheanManager{
|
||||||
|
kubeclient: kubeclient,
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *CheanManager) Start() {
|
||||||
|
logrus.Info("clean 开始工作...")
|
||||||
|
go c.Run()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *CheanManager) Run() {
|
||||||
|
Namespaces1, err := c.kubeclient.CoreV1().Namespaces().List(meta_v1.ListOptions{})
|
||||||
|
if err != nil{
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
fmt.Println("namespaces:",Namespaces1)
|
||||||
|
}
|
@ -31,6 +31,7 @@ import (
|
|||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
|
"github.com/goodrain/rainbond/appruntimesync/clean"
|
||||||
)
|
)
|
||||||
|
|
||||||
//AppRuntimeSyncServer AppRuntimeSyncServer
|
//AppRuntimeSyncServer AppRuntimeSyncServer
|
||||||
@ -42,6 +43,7 @@ type AppRuntimeSyncServer struct {
|
|||||||
Cancel context.CancelFunc
|
Cancel context.CancelFunc
|
||||||
ClientSet *kubernetes.Clientset
|
ClientSet *kubernetes.Clientset
|
||||||
podCache *pod.CacheManager
|
podCache *pod.CacheManager
|
||||||
|
clean *clean.CheanManager
|
||||||
}
|
}
|
||||||
|
|
||||||
//NewAppRuntimeSyncServer create app runtime sync server
|
//NewAppRuntimeSyncServer create app runtime sync server
|
||||||
@ -60,6 +62,7 @@ func NewAppRuntimeSyncServer(conf option.Config) *AppRuntimeSyncServer {
|
|||||||
statusManager := status.NewManager(ctx, clientset)
|
statusManager := status.NewManager(ctx, clientset)
|
||||||
stopChan := make(chan struct{})
|
stopChan := make(chan struct{})
|
||||||
podCache := pod.NewCacheManager(clientset)
|
podCache := pod.NewCacheManager(clientset)
|
||||||
|
Clean := clean.NewCheanManager(clientset)
|
||||||
arss := &AppRuntimeSyncServer{
|
arss := &AppRuntimeSyncServer{
|
||||||
c: conf,
|
c: conf,
|
||||||
Ctx: ctx,
|
Ctx: ctx,
|
||||||
@ -67,6 +70,7 @@ func NewAppRuntimeSyncServer(conf option.Config) *AppRuntimeSyncServer {
|
|||||||
Cancel: cancel,
|
Cancel: cancel,
|
||||||
ClientSet: clientset,
|
ClientSet: clientset,
|
||||||
podCache: podCache,
|
podCache: podCache,
|
||||||
|
clean: Clean,
|
||||||
}
|
}
|
||||||
arss.StatusManager = statusManager
|
arss.StatusManager = statusManager
|
||||||
return arss
|
return arss
|
||||||
@ -137,6 +141,7 @@ func (a *AppRuntimeSyncServer) Start() error {
|
|||||||
a.stopChan,
|
a.stopChan,
|
||||||
)
|
)
|
||||||
a.podCache.Start()
|
a.podCache.Start()
|
||||||
|
a.clean.Start()
|
||||||
logrus.Info("app runtime sync server started...")
|
logrus.Info("app runtime sync server started...")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user