本文整理匯總了Golang中k8s/io/kubernetes/pkg/tools.FakeEtcdClient.NewError方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeEtcdClient.NewError方法的具體用法?Golang FakeEtcdClient.NewError怎麽用?Golang FakeEtcdClient.NewError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/kubernetes/pkg/tools.FakeEtcdClient
的用法示例。
在下文中一共展示了FakeEtcdClient.NewError方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SetObjectsForKey
func SetObjectsForKey(fakeClient *tools.FakeEtcdClient, key string, objects []runtime.Object) []runtime.Object {
result := make([]runtime.Object, len(objects))
if len(objects) > 0 {
nodes := make([]*etcd.Node, len(objects))
for i, obj := range objects {
encoded := runtime.EncodeOrDie(testapi.Codec(), obj)
decoded, _ := testapi.Codec().Decode([]byte(encoded))
nodes[i] = &etcd.Node{Value: encoded}
result[i] = decoded
}
fakeClient.Data[key] = tools.EtcdResponseWithError{
R: &etcd.Response{
Node: &etcd.Node{
Nodes: nodes,
},
},
E: nil,
}
} else {
fakeClient.Data[key] = tools.EtcdResponseWithError{
R: &etcd.Response{},
E: fakeClient.NewError(tools.EtcdErrorCodeNotFound),
}
}
return result
}