Exemplo n.º 1
0
// UpdateApp takes an App and updates it in Consul
func (consul *Consul) UpdateApp(app *apps.App) error {
	var err error = nil

	local := app.KV()
	local.Key = WithPrefix(consul.AppsPrefix, local.Key)

	remote, _, err := consul.kv.Get(local.Key)
	if err != nil {
		return err
	}

	if remote == nil || len(remote.Value) == 0 || !bytes.Equal(local.Value, remote.Value) {
		_, err = consul.kv.Put(local)
	}

	return err
}
Exemplo n.º 2
0
// DeleteApp takes an App and deletes it from Consul
func (consul *Consul) DeleteApp(app *apps.App) error {
	_, err := consul.kv.Delete(WithPrefix(consul.AppsPrefix, app.Key()))
	return err
}