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

Function newCfgForManualLaunch

plugin/config.go:87–117  ·  view source on GitHub ↗
(p ExternalPlugin, opts ...ManualLaunchOption)

Source from the content-addressed store, hash-verified

85}
86
87func newCfgForManualLaunch(p ExternalPlugin, opts ...ManualLaunchOption) (*cfg, error) {
88 cfg := &cfg{
89 plugin: p,
90 registrationTimeout: api.DefaultPluginRegistrationTimeout,
91 }
92 for _, o := range opts {
93 if err := o(cfg); err != nil {
94 return nil, err
95 }
96 }
97 if cfg.conn == nil {
98 socketPath := api.DaemonSocketPath()
99 conn, err := net.Dial("unix", socketPath)
100 if err != nil {
101 return nil, fmt.Errorf("failed to connect to default socket %q: %w", socketPath, err)
102 }
103 hijackedConn, err := ipc.Hijackify(conn, hijackTimeout)
104 if err != nil {
105 return nil, fmt.Errorf("external plugin rejected: %w", err)
106 }
107 cfg.conn = hijackedConn
108 }
109 if cfg.name == "" {
110 if len(os.Args) == 0 {
111 // This should never happen in practice but can happen in tests or when something else empties os.Args for whatever reason.
112 return nil, errors.New("plugin name must be specified (could not derive from os.Args)")
113 }
114 cfg.name = filepath.Base(os.Args[0])
115 }
116 return cfg, nil
117}
118
119var errPluginNotLaunchedByEngine = errors.New("plugin not launched by secrets engine")
120

Callers 2

newCfgFunction · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by 1