Initial commit for the keymanager plugin
This commit is contained in:
31
pkg/plugin/implementation/keymanager/cmd/plugin.go
Normal file
31
pkg/plugin/implementation/keymanager/cmd/plugin.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/beckn/beckn-onix/pkg/log"
|
||||
"github.com/beckn/beckn-onix/pkg/plugin/definition"
|
||||
"github.com/beckn/beckn-onix/pkg/plugin/implementation/keymanager"
|
||||
)
|
||||
|
||||
// keyManagerProvider implements the plugin provider for the KeyManager plugin.
|
||||
type keyManagerProvider struct{}
|
||||
|
||||
// New creates and initializes a new KeyManager instance using the provided cache, registry lookup, and configuration.
|
||||
func (k *keyManagerProvider) New(ctx context.Context, cache definition.Cache, registry definition.RegistryLookup, cfg map[string]string) (definition.KeyManager, func() error, error) {
|
||||
config := &keymanager.Config{
|
||||
VaultAddr: cfg["vault_addr"],
|
||||
KVVersion: cfg["kv_version"],
|
||||
}
|
||||
log.Debugf(ctx, "Keymanager config mapped: %+v", cfg)
|
||||
km, cleanup, err := keymanager.New(ctx, cache, registry, config)
|
||||
if err != nil {
|
||||
log.Error(ctx, err, "Failed to initialize KeyManager")
|
||||
return nil, nil, err
|
||||
}
|
||||
log.Debugf(ctx, "KeyManager instance created successfully")
|
||||
return km, cleanup, nil
|
||||
}
|
||||
|
||||
// Provider is the exported instance of keyManagerProvider used for plugin registration.
|
||||
var Provider = keyManagerProvider{}
|
||||
Reference in New Issue
Block a user