當前位置: 首頁>>代碼示例>>Golang>>正文


Golang tools.FakeEtcdClient類代碼示例

本文整理匯總了Golang中k8s/io/kubernetes/pkg/tools.FakeEtcdClient的典型用法代碼示例。如果您正苦於以下問題:Golang FakeEtcdClient類的具體用法?Golang FakeEtcdClient怎麽用?Golang FakeEtcdClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了FakeEtcdClient類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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
}
開發者ID:rimey,項目名稱:kubernetes,代碼行數:26,代碼來源:etcd.go

示例2: storeToEtcd

func storeToEtcd(fakeClient *tools.FakeEtcdClient, path, name string, obj interface{}) error {
	data, err := encodeToThirdParty(name, obj)
	if err != nil {
		return err
	}
	_, err = fakeClient.Set(etcdtest.PathPrefix()+path, string(data), 0)
	return err
}
開發者ID:Rafflecopter,項目名稱:kubernetes,代碼行數:8,代碼來源:master_test.go

示例3: SetObject

func SetObject(fakeClient *tools.FakeEtcdClient, keyFn keyFunc, ctx api.Context, obj runtime.Object) error {
	meta, err := api.ObjectMetaFor(obj)
	if err != nil {
		return err
	}
	key, err := keyFn(ctx, meta.Name)
	if err != nil {
		return err
	}
	key = etcdtest.AddPrefix(key)
	_, err = fakeClient.Set(key, runtime.EncodeOrDie(testapi.Codec(), obj), 0)
	return err
}
開發者ID:rimey,項目名稱:kubernetes,代碼行數:13,代碼來源:etcd.go

示例4: GetObject

func GetObject(fakeClient *tools.FakeEtcdClient, keyFn keyFunc, newFn newFunc, ctx api.Context, obj runtime.Object) (runtime.Object, error) {
	meta, err := api.ObjectMetaFor(obj)
	if err != nil {
		return nil, err
	}
	key, err := keyFn(ctx, meta.Name)
	if err != nil {
		return nil, err
	}
	key = etcdtest.AddPrefix(key)
	resp, err := fakeClient.Get(key, false, false)
	if err != nil {
		return nil, err
	}
	result := newFn()
	if err := testapi.Codec().DecodeInto([]byte(resp.Node.Value), result); err != nil {
		return nil, err
	}
	return result, nil
}
開發者ID:rimey,項目名稱:kubernetes,代碼行數:20,代碼來源:etcd.go

示例5: SetResourceVersion

func SetResourceVersion(fakeClient *tools.FakeEtcdClient, resourceVersion uint64) {
	fakeClient.ChangeIndex = resourceVersion
}
開發者ID:rimey,項目名稱:kubernetes,代碼行數:3,代碼來源:etcd.go


注:本文中的k8s/io/kubernetes/pkg/tools.FakeEtcdClient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。