MCPcopy Create free account
hub / github.com/docker/secrets-engine / New

Function New

plugin/stub.go:65–86  ·  view source on GitHub ↗

New creates a stub with the given plugin and options. ManualLaunchOption only apply when the plugin is launched manually. If launched by the secrets runtime, they are ignored. If logger is nil, a default logger will be created and used.

(p ExternalPlugin, config Config, opts ...ManualLaunchOption)

Source from the content-addressed store, hash-verified

63// If launched by the secrets runtime, they are ignored.
64// If logger is nil, a default logger will be created and used.
65func New(p ExternalPlugin, config Config, opts ...ManualLaunchOption) (Stub, error) {
66 if err := config.Valid(); err != nil {
67 return nil, err
68 }
69 if config.Logger == nil {
70 config.Logger = logging.NewDefaultLogger("plugin")
71 }
72 cfg, err := newCfg(p, opts...)
73 if err != nil {
74 return nil, err
75 }
76 cfg.Config = config
77 stub := &stub{
78 name: cfg.name,
79 factory: func(ctx context.Context, onClose func(error)) (io.Closer, error) {
80 return setup(ctx, *cfg, onClose)
81 },
82 }
83 config.Logger.Printf("Created plugin %s", cfg.name)
84
85 return stub, nil
86}
87
88// Run the plugin. Start event processing then wait for an error or getting stopped.
89func (stub *stub) Run(ctx context.Context) error {

Callers

nothing calls this directly

Calls 4

newCfgFunction · 0.85
setupFunction · 0.85
ValidMethod · 0.80
PrintfMethod · 0.65

Tested by

no test coverage detected