mirror of
https://github.com/go-gitea/gitea
synced 2024-07-07 10:35:48 +00:00
* Dropped unused codekit config * Integrated dynamic and static bindata for public * Ignore public bindata * Add a general generate make task * Integrated flexible public assets into web command * Updated vendoring, added all missiong govendor deps * Made the linter happy with the bindata and dynamic code * Moved public bindata definition to modules directory * Ignoring the new bindata path now * Updated to the new public modules import path * Updated public bindata command and drop the new prefix
37 lines
791 B
Go
37 lines
791 B
Go
package etcd
|
|
|
|
import "fmt"
|
|
|
|
func (c *Client) CompareAndSwap(key string, value string, ttl uint64,
|
|
prevValue string, prevIndex uint64) (*Response, error) {
|
|
raw, err := c.RawCompareAndSwap(key, value, ttl, prevValue, prevIndex)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return raw.Unmarshal()
|
|
}
|
|
|
|
func (c *Client) RawCompareAndSwap(key string, value string, ttl uint64,
|
|
prevValue string, prevIndex uint64) (*RawResponse, error) {
|
|
if prevValue == "" && prevIndex == 0 {
|
|
return nil, fmt.Errorf("You must give either prevValue or prevIndex.")
|
|
}
|
|
|
|
options := Options{}
|
|
if prevValue != "" {
|
|
options["prevValue"] = prevValue
|
|
}
|
|
if prevIndex != 0 {
|
|
options["prevIndex"] = prevIndex
|
|
}
|
|
|
|
raw, err := c.put(key, value, ttl, options)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return raw, err
|
|
}
|