Skip to main content

Module init

Module init 

Source
Expand description

choir init — from nothing to a node you can push to.

The four things a new instance needs are a repository root, a credential, an actor key the node will trust, and a .choir/config so the other commands stop asking which node you mean. Each was already possible by hand — openssl rand, choir key, a printf into a file at the right mode — and every one of them is a step where a first-time reader gets a permission bit wrong and finds out much later.

§What it will not do

It refuses when anything it would write already exists, and names what. Overwriting an auth file locks you out of your own node with no undo: the token in it is the only copy, the node was started reading it, and nothing anywhere else can reissue it. --force is the deliberate reset, and says what it destroyed.

§Examples

use choir_cli::init::Plan;

// The default plan is loopback, because a node that binds anything
// else refuses to start without TLS (invariant 9) — and a first run
// that fails on a certificate teaches nothing about choir.
let plan = Plan::new(std::path::Path::new("/tmp/choir-example"), 8417);
assert!(plan.node_url().starts_with("http://127.0.0.1:"));

Structs§

Created
What choir init did, so the caller can print it and the tests can assert on it.
Plan
Where everything choir init writes is going.

Functions§

mint_token
Mints a bearer token.
run
Runs the plan.