code: func (e *Etcd) CreateOrUpdate(snapshot *api.RangeAllocation) error {
  	e.lock.Lock()
  	defer e.lock.Unlock()
  
  	last := ""
  	err := e.storage.GuaranteedUpdate(context.TODO(), e.baseKey, &api.RangeAllocation{}, true, nil,
  		storage.SimpleUpdate(func(input runtime.Object) (output runtime.Object, err error) {
  			existing := input.(*api.RangeAllocation)
  			switch {
  			case len(snapshot.ResourceVersion) != 0 && len(existing.ResourceVersion) != 0:
  				if snapshot.ResourceVersion != existing.ResourceVersion {
  					return nil, k8serr.NewConflict(e.resource, "", fmt.Errorf("the provided resource version does not match"))
  				}
  			case len(existing.ResourceVersion) != 0:
  				return nil, k8serr.NewConflict(e.resource, "", fmt.Errorf("another caller has already initialized the resource"))
  			}
  			last = snapshot.ResourceVersion
  			return snapshot, nil
  		}),
  	)
  	if err != nil {
  		return storeerr.InterpretUpdateError(err, e.resource, "")
  	}
  	err = e.alloc.Restore(snapshot.Range, snapshot.Data)
  	if err == nil {
  		e.last = last
  	}
  	return err
  }
docs: // CreateOrUpdate attempts to update the current etcd state with the provided
  // allocation.