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

Function New

client/client.go:193–232  ·  view source on GitHub ↗
(options ...Option)

Source from the content-addressed store, hash-verified

191}
192
193func New(options ...Option) (Client, error) {
194 cfg := &config{
195 requestTimeout: api.DefaultClientRequestTimeout,
196 responseTimeout: api.DefaultClientResponseHeaderTimeout,
197 }
198 for _, opt := range options {
199 if err := opt(cfg); err != nil {
200 return nil, err
201 }
202 }
203 if cfg.dialContext == nil {
204 cfg.dialContext = dialFromPath(api.DaemonSocketPath())
205 }
206 c := &http.Client{
207 Transport: &http.Transport{
208 // re-use the same connection to the runtime, this speeds up subsequent
209 // calls.
210 MaxConnsPerHost: api.DefaultClientMaxConnsPerHost,
211 MaxIdleConnsPerHost: api.DefaultClientMaxIdleConnsPerHost,
212 // keep the connection alive (good for long-lived clients)
213 IdleConnTimeout: api.DefaultClientIdleConnTimeout,
214 // By default it is 1 second, but can be overridden with [WithResponseTimeout]
215 ResponseHeaderTimeout: cfg.responseTimeout,
216 TLSHandshakeTimeout: api.DefaultClientTLSHandshakeTimeout,
217
218 DialContext: cfg.dialContext,
219 DisableKeepAlives: false,
220 DisableCompression: false,
221 ForceAttemptHTTP2: true,
222 },
223 // by default Timeout will be 0 (meaning no timeout)
224 // it can be overwritten with [WithTimeout]
225 Timeout: cfg.requestTimeout,
226 }
227 return &client{
228 resolverClient: resolver.NewResolverClient(c),
229 engineClient: pluginsv1connect.NewPluginManagementServiceClient(c, "http://unix"),
230 versionClient: healthv1connect.NewVersionServiceClient(c, "http://unix"),
231 }, nil
232}
233
234func (c client) ListPlugins(ctx context.Context) ([]PluginInfo, error) {
235 req := connect.NewRequest(pluginsv1.ListPluginsRequest_builder{}.Build())

Callers 3

Test_ListPluginsFunction · 0.70
Test_VersionFunction · 0.70

Calls 1

dialFromPathFunction · 0.85

Tested by 3

Test_ListPluginsFunction · 0.56
Test_VersionFunction · 0.56