jo/couchdb-bootstrap

_config.json as configuration object

layanto opened this issue · 6 comments

How do I use configuration object for _config.json? I want to use couchdb-bootstrap to initialise a new installation of couchdb so configuration are always the same.

jo commented

Hi, https://github.com/jo/couchdb-configure can configure CouchDB via HTTP config endpoint. Here you see examples for a config object.

For CouchDB 2 you need to change the endpoint, though. See http://docs.couchdb.org/en/stable/http-api.html#cap-/_node/{node-name}/_config. This has not been tested yet with couchdb-bootstrap and I am not sure whether it works out of the box. Feedback appreciated.

If I do this:

const config = {
    "couchdb-configure": {
        "vendor": {
            "name": "Custom Vendor ABC"
        }
    }
}

bootstrap('http://username:password@localhost:5984', config, function(error, response) {
    if (error) console.log(error)
    else console.log(response)
})

I ended up creating a new db called couchdb-configure
I am using couchDB 2.2.0

How do I change the endpoint?

How does bootstrap know to pass that part of the configuration object to couchdb-configure instead of couchdb-push?

jo commented

Yeah, looks like this is not possible atm. You can use couchdb-configure standalone for the time being.

Had a look through source of couchdb-bootstrap and couchdb-configure.
Configuration object for _config should be:

const config = {
    "_config": {
        "name": "Custom Vendor ABC"
    }
}

Currently couchdb-configure hardcodes the _config path as '_config' via line 35 of https://github.com/jo/couchdb-configure/blob/master/index.js

path: '_config/' + setting.path,

Maybe the fix is for couchdb-configure to GET / to find out the version of couchdb server. If version 1.x, do as is. If version 2.x, change to

path: '_node/_local/_config/' + setting.path,