mirror of
https://github.com/rancher/dynamiclistener.git
synced 2025-09-08 16:40:03 +00:00
Add static storage and listener opts
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/rancher/dynamiclistener"
|
||||
"github.com/rancher/dynamiclistener/factory"
|
||||
"github.com/rancher/wrangler-api/pkg/generated/controllers/core"
|
||||
v1controller "github.com/rancher/wrangler-api/pkg/generated/controllers/core/v1"
|
||||
"github.com/rancher/wrangler/pkg/start"
|
||||
@@ -19,6 +18,17 @@ import (
|
||||
|
||||
type CoreGetter func() *core.Factory
|
||||
|
||||
func Load(ctx context.Context, secrets v1controller.SecretController, namespace, name string, backing dynamiclistener.TLSStorage) dynamiclistener.TLSStorage {
|
||||
storage := &storage{
|
||||
name: name,
|
||||
namespace: namespace,
|
||||
storage: backing,
|
||||
ctx: ctx,
|
||||
}
|
||||
storage.init(secrets)
|
||||
return storage
|
||||
}
|
||||
|
||||
func New(ctx context.Context, core CoreGetter, namespace, name string, backing dynamiclistener.TLSStorage) dynamiclistener.TLSStorage {
|
||||
storage := &storage{
|
||||
name: name,
|
||||
@@ -55,10 +65,10 @@ type storage struct {
|
||||
storage dynamiclistener.TLSStorage
|
||||
secrets v1controller.SecretClient
|
||||
ctx context.Context
|
||||
tls *factory.TLS
|
||||
tls dynamiclistener.TLSFactory
|
||||
}
|
||||
|
||||
func (s *storage) SetFactory(tls *factory.TLS) {
|
||||
func (s *storage) SetFactory(tls dynamiclistener.TLSFactory) {
|
||||
s.tls = tls
|
||||
}
|
||||
|
||||
|
36
storage/static/static.go
Normal file
36
storage/static/static.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package static
|
||||
|
||||
import (
|
||||
"github.com/rancher/dynamiclistener/factory"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
type Storage struct {
|
||||
Secret *v1.Secret
|
||||
}
|
||||
|
||||
func New(certPem, keyPem []byte) *Storage {
|
||||
return &Storage{
|
||||
Secret: &v1.Secret{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Annotations: map[string]string{
|
||||
factory.Static: "true",
|
||||
},
|
||||
},
|
||||
Data: map[string][]byte{
|
||||
v1.TLSCertKey: certPem,
|
||||
v1.TLSPrivateKeyKey: keyPem,
|
||||
},
|
||||
Type: v1.SecretTypeTLS,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Storage) Get() (*v1.Secret, error) {
|
||||
return s.Secret, nil
|
||||
}
|
||||
|
||||
func (s *Storage) Update(_ *v1.Secret) error {
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user