diff --git a/go.mod b/go.mod index 14b5cd4..4acfbe0 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.12 require ( github.com/caddyserver/caddy/v2 v2.0.0-beta6 github.com/docker/distribution v2.7.1+incompatible // indirect - github.com/mholt/certmagic v0.8.3 + github.com/mholt/certmagic v0.7.5 github.com/opencontainers/go-digest v1.0.0-rc1 // indirect github.com/pkg/errors v0.8.1 github.com/prometheus/client_golang v1.1.0 diff --git a/go.sum b/go.sum index 509f094..83cac98 100644 --- a/go.sum +++ b/go.sum @@ -244,6 +244,7 @@ github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzp github.com/mattn/go-tty v0.0.0-20180219170247-931426f7535a/go.mod h1:XPvLUNfbS4fJH25nqRHfWLMa1ONC8Amw+mIA639KxkE= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mholt/certmagic v0.7.5 h1:1ZGHwUI4+zg1S17tPUj5Xxb9Q1ghTjLcUZE5G4yV5SM= github.com/mholt/certmagic v0.7.5/go.mod h1:91uJzK5K8IWtYQqTi5R2tsxV1pCde+wdGfaRaOZi6aQ= github.com/mholt/certmagic v0.8.3 h1:JOUiX9IAZbbgyjNP2GY6v/6lorH+9GkZsc7ktMpGCSo= github.com/mholt/certmagic v0.8.3/go.mod h1:91uJzK5K8IWtYQqTi5R2tsxV1pCde+wdGfaRaOZi6aQ= diff --git a/internal/controller/controller.go b/internal/controller/controller.go index dec4a30..4dae6ea 100644 --- a/internal/controller/controller.go +++ b/internal/controller/controller.go @@ -110,15 +110,7 @@ func NewCaddyController(kubeClient *kubernetes.Clientset, restClient rest.Interf controller.dispatchSync() // register kubernetes specific cert-magic storage module - caddy.RegisterModule(caddy.Module{ - Name: "caddy.storage.secret_store", - New: func() interface{} { - return &storage.SecretStorage{ - Namespace: podInfo.Namespace, - KubeClient: kubeClient, - } - }, - }) + caddy.RegisterModule(storage.SecretStorage{}) return controller } diff --git a/pkg/storage/storage.go b/pkg/storage/storage.go index 6ddecae..ca635f9 100644 --- a/pkg/storage/storage.go +++ b/pkg/storage/storage.go @@ -5,6 +5,7 @@ import ( "regexp" "strings" + "github.com/caddyserver/caddy/v2" "github.com/mholt/certmagic" "github.com/sirupsen/logrus" corev1 "k8s.io/api/core/v1" @@ -34,6 +35,13 @@ type SecretStorage struct { KubeClient *kubernetes.Clientset } +func (SecretStorage) CaddyModule() caddy.ModuleInfo { + return caddy.ModuleInfo{ + Name: "caddy.storage.secret_store", + New: func() caddy.Module { return new(SecretStorage) }, + } +} + // CertMagicStorage returns a certmagic storage type to be used by caddy. func (s *SecretStorage) CertMagicStorage() (certmagic.Storage, error) { return s, nil