IsFeatureActiveStandalone is the convenience form of IsFeatureActive for callers without an existing engine API client (e.g. the compose plugin hook subprocess). It builds a Docker CLI using the ambient environment to resolve the active context, then delegates to IsFeatureActive.
(ctx context.Context, feature string)
| 200 | // subprocess). It builds a Docker CLI using the ambient environment to |
| 201 | // resolve the active context, then delegates to IsFeatureActive. |
| 202 | func IsFeatureActiveStandalone(ctx context.Context, feature string) bool { |
| 203 | dockerCli, err := command.NewDockerCli(command.WithCombinedStreams(io.Discard)) |
| 204 | if err != nil { |
| 205 | return false |
| 206 | } |
| 207 | if err := dockerCli.Initialize(cliflags.NewClientOptions()); err != nil { |
| 208 | return false |
| 209 | } |
| 210 | defer dockerCli.Client().Close() //nolint:errcheck |
| 211 | |
| 212 | return IsFeatureActive(ctx, dockerCli.Client(), feature) |
| 213 | } |
| 214 | |
| 215 | func (c *Client) newRequest(ctx context.Context, method, path string, body io.Reader) (*http.Request, error) { |
| 216 | req, err := http.NewRequestWithContext(ctx, method, backendURL(path), body) |
no test coverage detected