Update to use latest Caddy 2 module interface

This commit is contained in:
Matthew Holt 2019-10-26 09:38:12 -06:00
parent c46d8ff2e5
commit c36b7f3536
4 changed files with 11 additions and 10 deletions

2
go.mod
View File

@ -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

1
go.sum
View File

@ -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=

View File

@ -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
}

View File

@ -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