Improve documentation, remove dead code plus some minor refactorings

This improves our code-to-comments ratio by a lot.

On the refactorings:

- Simplify the cluster join mode to just a single protobuf message -
  a node can either join an existing cluster or bootstrap a new one.
  All of the node-level setup like hostname and trust backend is done
  using the setup call, since those are identical for both cases.

- We don't need a node name separate from the hostname. Ideally, we would
  get rid of IP addresses for etcd as well.

- Google API design guidelines suggest the `List` term (vs. `Get`).

- Add username to comments for consistency. I think the names provide
  useful context, but git blame is a thing. What do you think?

- Fixed or silenced some ignored error checks in preparation of using
  an errcheck linter. Especially during early boot, many errors are
  obviously not recoverable, but logging them can provide useful debugging info.

- Split up the common package into smaller subpackages.

- Remove the audit package (this will be a separate service that probably
  uses it own database, rather than etcd).

- Move storage constants to storage package.

- Remove the unused KV type.

I also added a bunch of TODO comments with discussion points.
Added both of you as blocking reviewers - please comment if I
misunderstood any of your code.

Test Plan: Everything compiles and scripts:launch works (for whatever that's worth).

X-Origin-Diff: phab/D235
GitOrigin-RevId: 922fec5076e8d683e1138f26d2cb490de64a9777
diff --git a/core/internal/node/setup.go b/core/internal/node/setup.go
index 5d8953d..efc72d3 100644
--- a/core/internal/node/setup.go
+++ b/core/internal/node/setup.go
@@ -19,6 +19,7 @@
 import (
 	"git.monogon.dev/source/nexantic.git/core/generated/api"
 	"git.monogon.dev/source/nexantic.git/core/internal/common"
+	"git.monogon.dev/source/nexantic.git/core/internal/storage"
 
 	"errors"
 
@@ -41,19 +42,18 @@
 	return s.joinToken
 }
 
-func (s *SmalltownNode) SetupNewCluster(name string, externalHost string) error {
+func (s *SmalltownNode) SetupNewCluster() error {
 	if s.state == common.StateConfigured {
 		return ErrAlreadySetup
 	}
-	dataPath, err := s.Storage.GetPathInPlace(common.PlaceData, "etcd")
-	if err == common.ErrNotInitialized {
+	dataPath, err := s.Storage.GetPathInPlace(storage.PlaceData, "etcd")
+	if err == storage.ErrNotInitialized {
 		return ErrStorageNotInitialized
 	} else if err != nil {
 		return err
 	}
 
-	s.logger.Info("Setting up a new cluster", zap.String("name", name), zap.String("external_host", externalHost))
-
+	s.logger.Info("Setting up a new cluster")
 	s.logger.Info("Provisioning consensus")
 
 	// Make sure etcd is not yet provisioned
@@ -64,11 +64,11 @@
 	// Spin up etcd
 	config := s.Consensus.GetConfig()
 	config.NewCluster = true
-	config.Name = name
-	config.ExternalHost = externalHost
+	config.Name = s.hostname
 	config.DataDir = dataPath
 	s.Consensus.SetConfig(config)
 
+	// Generate the cluster CA and store it to local storage.
 	if err := s.Consensus.PrecreateCA(); err != nil {
 		return err
 	}
@@ -78,6 +78,7 @@
 		return err
 	}
 
+	// Now that the cluster is up and running, we can persist the CA to the cluster.
 	if err := s.Consensus.InjectCA(); err != nil {
 		return err
 	}
@@ -101,12 +102,12 @@
 	return nil
 }
 
-func (s *SmalltownNode) JoinCluster(name string, clusterString string, externalHost string, certs *api.ConsensusCertificates) error {
+func (s *SmalltownNode) JoinCluster(clusterString string, certs *api.ConsensusCertificates) error {
 	if s.state != common.StateClusterJoinMode {
 		return ErrNotInJoinMode
 	}
 
-	s.logger.Info("Joining cluster", zap.String("cluster", clusterString), zap.String("name", name))
+	s.logger.Info("Joining cluster", zap.String("cluster", clusterString))
 
 	err := s.SetupBackend()
 	if err != nil {
@@ -114,11 +115,10 @@
 	}
 
 	config := s.Consensus.GetConfig()
-	config.Name = name
+	config.Name = s.hostname
 	config.InitialCluster = clusterString
-	config.ExternalHost = externalHost
 	s.Consensus.SetConfig(config)
-	if err := s.Consensus.SetupCertificates(certs); err != nil {
+	if err := s.Consensus.WriteCertificateFiles(certs); err != nil {
 		return err
 	}