本文整理汇总了Golang中github.com/qingyuancloud/QingYuan/pkg/client.Client.Events方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.Events方法的具体用法?Golang Client.Events怎么用?Golang Client.Events使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/qingyuancloud/QingYuan/pkg/client.Client
的用法示例。
在下文中一共展示了Client.Events方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
By("retrieving the pod")
podWithUid, err := podClient.Get(pod.Name)
if err != nil {
Failf("Failed to get pod: %v", err)
}
fmt.Printf("%+v\n", podWithUid)
var events *api.EventList
// Check for scheduler event about the pod.
By("checking for scheduler event about the pod")
expectNoError(wait.Poll(time.Second*2, time.Second*60, func() (bool, error) {
events, err := c.Events(api.NamespaceDefault).List(
labels.Everything(),
fields.Set{
"involvedObject.kind": "Pod",
"involvedObject.uid": string(podWithUid.UID),
"involvedObject.namespace": api.NamespaceDefault,
"source": "scheduler",
}.AsSelector(),
)
if err != nil {
return false, err
}
if len(events.Items) > 0 {
fmt.Println("Saw scheduler event for our pod.")
return true, nil
}
return false, nil
}))
// Check for qinglet event about the pod.
By("checking for qinglet event about the pod")
示例2:
config := RCConfig{Client: c,
Image: "qingyuan/pause:go",
Name: RCName,
Namespace: ns,
PollInterval: itArg.interval,
PodStatusFile: fileHndl,
Replicas: totalPods,
}
// Create a listener for events.
events := make([](*api.Event), 0)
_, controller := framework.NewInformer(
&cache.ListWatch{
ListFunc: func() (runtime.Object, error) {
return c.Events(ns).List(labels.Everything(), fields.Everything())
},
WatchFunc: func(rv string) (watch.Interface, error) {
return c.Events(ns).Watch(labels.Everything(), fields.Everything(), rv)
},
},
&api.Event{},
0,
framework.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
events = append(events, obj.(*api.Event))
},
},
)
stop := make(chan struct{})
go controller.Run(stop)