m/pkg/pki: refactor, allow for external certificates

The pki library supported managing certificates in two modes:

 - default, when name != ""
 - volatile/ephemeral, when name == ""

The difference between the two being that default certificates were
fully stored in etcd (key and x509 certificate), while volatile
certificates weren't stored at all. However, both kinds needed private
keys passed to the pki library.

We want to be able to emit certificates without having private keys for
that certificate, so we end up a third mode of operation: 'external
certificates'. These are still stored in etcd, but without any
corresponding private key.

In the future we might actually get rid of ephemeral certificates by
expanding the logic of external certificates to provide a full audit log
and revocation system, instead of matching by Certificate Name. But this
will do for now.

We also use this opportunity to write some simple tests for this
package.

Change-Id: I193f4b147273b0a3981c38d749b43362d3c1b69a
Reviewed-on: https://review.monogon.dev/c/monogon/+/263
Reviewed-by: Mateusz Zalega <mateusz@monogon.tech>
diff --git a/metropolis/pkg/pki/BUILD.bazel b/metropolis/pkg/pki/BUILD.bazel
index 243abf9..c215ce2 100644
--- a/metropolis/pkg/pki/BUILD.bazel
+++ b/metropolis/pkg/pki/BUILD.bazel
@@ -1,11 +1,10 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
 
 go_library(
     name = "go_default_library",
     srcs = [
         "ca.go",
         "certificate.go",
-        "doc.go",
         "x509.go",
     ],
     importpath = "source.monogon.dev/metropolis/pkg/pki",
@@ -15,3 +14,10 @@
         "@io_etcd_go_etcd//clientv3:go_default_library",
     ],
 )
+
+go_test(
+    name = "go_default_test",
+    srcs = ["certificate_test.go"],
+    embed = [":go_default_library"],
+    deps = ["@io_etcd_go_etcd//integration:go_default_library"],
+)