func storeThirdPartyObject(s storage.Interface, path, name string, obj interface{}) error { data, err := encodeToThirdParty(name, obj) if err != nil { return err } return s.Set(context.TODO(), etcdtest.AddPrefix(path), data, nil, 0) }
// CreateObj will create a single object using the storage interface func CreateObj(t *testing.T, helper storage.Interface, name string, obj, out runtime.Object, ttl uint64) error { err := helper.Set(context.TODO(), name, obj, out, ttl) if err != nil { t.Errorf("Unexpected error %v", err) } return err }
func updatePod(t *testing.T, s storage.Interface, obj, old *api.Pod) *api.Pod { key := etcdtest.AddPrefix("pods/ns/" + obj.Name) result := &api.Pod{} if old == nil { if err := s.Create(context.TODO(), key, obj, result, 0); err != nil { t.Errorf("unexpected error: %v", err) } } else { // To force "update" behavior of Set() we need to set ResourceVersion of // previous version of object. obj.ResourceVersion = old.ResourceVersion if err := s.Set(context.TODO(), key, obj, result, 0); err != nil { t.Errorf("unexpected error: %v", err) } obj.ResourceVersion = "" } return result }
// CreateObj will create a single object using the storage interface func CreateObj(helper storage.Interface, name string, obj, out runtime.Object, ttl uint64) error { return helper.Set(context.TODO(), name, obj, out, ttl) }