m/n/core/{curator,cluster}: refactor against new Consensus API

This updates the Curator and the Cluster Manager to use the new
Consensus API, notably to use JoinParameters and ServiceHandle.Watch.

Using JoinParameters end-to-end requires piping them through a node's
roles. For this we create a new ConsensusMember role and replicate all
the data from JoinParameters there.

We also move a whole bunch of logic that used to live in the Cluster
Manager's Status object away from it. Instead, now the Consensus
ServiceHandle is exposed directly to downstream users, providing the
same functionality.

Change-Id: I8cfa247011554553836019f60ea172dd6069f49c
Reviewed-on: https://review.monogon.dev/c/monogon/+/522
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/metropolis/node/core/consensus/testhelpers.go b/metropolis/node/core/consensus/testhelpers.go
new file mode 100644
index 0000000..627a278
--- /dev/null
+++ b/metropolis/node/core/consensus/testhelpers.go
@@ -0,0 +1,48 @@
+package consensus
+
+import (
+	"context"
+	"testing"
+
+	"go.etcd.io/etcd/clientv3"
+
+	"source.monogon.dev/metropolis/pkg/event/memory"
+)
+
+type testServiceHandle struct {
+	s memory.Value
+}
+
+// TestServiceHandle builds a somewhat functioning ServiceHandle from a bare
+// etcd connection, effectively creating a fake Consensus service. This must
+// only be used in test code to perform dependency injection of a etcd client
+// into code which expects a Consensus service instance, eg. for testing the
+// Curator.
+//
+// The 'somewhat functioning' description above should serve as a hint to the
+// API stability and backwards/forwards compatibility of this function: there is
+// none.
+func TestServiceHandle(t *testing.T, cl *clientv3.Client) ServiceHandle {
+	ca := pkiCA()
+
+	tsh := testServiceHandle{}
+	st := &Status{
+		cl: cl,
+		ca: ca,
+	}
+	etcdPKI, err := st.pkiClient()
+	if err != nil {
+		t.Fatalf("failed to get PKI etcd client: %v", err)
+	}
+	ctx, ctxC := context.WithCancel(context.Background())
+	defer ctxC()
+	if _, err := ca.Ensure(ctx, etcdPKI); err != nil {
+		t.Fatalf("failed to ensure PKI CA: %v", err)
+	}
+	tsh.s.Set(st)
+	return &tsh
+}
+
+func (h *testServiceHandle) Watch() Watcher {
+	return Watcher{h.s.Watch()}
+}