metropolis/pkg/(event|pki): remove dependency to consensus/client
We are currently depending on the consensus client, even when we just
need a plain etcd client. This change removes the dependency by adding
a ThinClient interface that wraps KV amd Watcher from clientv3.
Change-Id: I33994ab35ebb3a63c9dda4b588b7f529535e3083
Reviewed-on: https://review.monogon.dev/c/monogon/+/3082
Tested-by: Jenkins CI
Reviewed-by: Serge Bazanski <serge@monogon.tech>
diff --git a/metropolis/pkg/pki/BUILD.bazel b/metropolis/pkg/pki/BUILD.bazel
index 97e7fb1..d122ef4 100644
--- a/metropolis/pkg/pki/BUILD.bazel
+++ b/metropolis/pkg/pki/BUILD.bazel
@@ -11,7 +11,6 @@
importpath = "source.monogon.dev/metropolis/pkg/pki",
visibility = ["//visibility:public"],
deps = [
- "//metropolis/node/core/consensus/client",
"//metropolis/pkg/event",
"//metropolis/pkg/event/etcd",
"//metropolis/pkg/fileargs",
@@ -27,7 +26,6 @@
],
embed = [":pki"],
deps = [
- "//metropolis/node/core/consensus/client",
"//metropolis/pkg/logtree",
"@io_etcd_go_etcd_client_pkg_v3//testutil",
"@io_etcd_go_etcd_tests_v3//integration",
diff --git a/metropolis/pkg/pki/crl.go b/metropolis/pkg/pki/crl.go
index 23838a1..f72fb2d 100644
--- a/metropolis/pkg/pki/crl.go
+++ b/metropolis/pkg/pki/crl.go
@@ -11,7 +11,6 @@
clientv3 "go.etcd.io/etcd/client/v3"
- "source.monogon.dev/metropolis/node/core/consensus/client"
"source.monogon.dev/metropolis/pkg/event"
"source.monogon.dev/metropolis/pkg/event/etcd"
)
@@ -145,7 +144,7 @@
// WatchCRL returns and Event Value compatible CRLWatcher which can be used to
// retrieve and watch for the newest CRL available from this CA certificate.
-func (c *Certificate) WatchCRL(cl client.Namespaced) event.Watcher[*CRL] {
+func (c *Certificate) WatchCRL(cl etcd.ThinClient) event.Watcher[*CRL] {
value := etcd.NewValue(cl, c.crlPath(), func(_, data []byte) (*CRL, error) {
crl, err := x509.ParseCRL(data)
if err != nil {
diff --git a/metropolis/pkg/pki/crl_test.go b/metropolis/pkg/pki/crl_test.go
index 8f9cf5d..e47eab9 100644
--- a/metropolis/pkg/pki/crl_test.go
+++ b/metropolis/pkg/pki/crl_test.go
@@ -7,8 +7,6 @@
"go.etcd.io/etcd/client/pkg/v3/testutil"
"go.etcd.io/etcd/tests/v3/integration"
-
- "source.monogon.dev/metropolis/node/core/consensus/client"
)
// TestRevoke exercises the CRL revocation and watching functionality of a CA
@@ -19,7 +17,7 @@
cluster := integration.NewClusterV3(tb, &integration.ClusterConfig{
Size: 1,
})
- cl := client.NewLocal(cluster.Client(0))
+ cl := cluster.Client(0)
defer cluster.Terminate(tb)
ctx, ctxC := context.WithCancel(context.Background())
defer ctxC()