本文整理汇总了Golang中k8s/io/kubernetes/pkg/client/testing/core.NewObjectTracker函数的典型用法代码示例。如果您正苦于以下问题:Golang NewObjectTracker函数的具体用法?Golang NewObjectTracker怎么用?Golang NewObjectTracker使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewObjectTracker函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewSimpleClientset
// NewSimpleClientset returns a clientset that will respond with the provided objects.
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
// without applying any validations and/or defaults. It shouldn't be considered a replacement
// for a real clientset and is mostly useful in simple unit tests.
func NewSimpleClientset(objects ...runtime.Object) *Clientset {
o := core.NewObjectTracker(api.Scheme, api.Codecs.UniversalDecoder())
for _, obj := range objects {
if err := o.Add(obj); err != nil {
panic(err)
}
}
fakePtr := core.Fake{}
fakePtr.AddReactor("*", "*", core.ObjectReaction(o, api.Registry.RESTMapper()))
fakePtr.AddWatchReactor("*", core.DefaultWatchReactor(watch.NewFake(), nil))
return &Clientset{fakePtr}
}
示例2: NewSimpleFake
// NewSimpleFake returns a client that will respond with the provided objects
func NewSimpleFake(objects ...runtime.Object) *Fake {
o := core.NewObjectTracker(kapi.Scheme, kapi.Codecs.UniversalDecoder())
for _, obj := range objects {
if err := o.Add(obj); err != nil {
panic(err)
}
}
fakeClient := &Fake{}
fakeClient.AddReactor("*", "*", core.ObjectReaction(o, registered.RESTMapper()))
fakeClient.AddWatchReactor("*", core.DefaultWatchReactor(watch.NewFake(), nil))
return fakeClient
}