Endpoint returns the Docker Desktop API socket endpoint advertised via the engine info labels, or "" when the active engine is not Docker Desktop.
(ctx context.Context, apiClient client.APIClient)
| 41 | // Endpoint returns the Docker Desktop API socket endpoint advertised via the |
| 42 | // engine info labels, or "" when the active engine is not Docker Desktop. |
| 43 | func Endpoint(ctx context.Context, apiClient client.APIClient) (string, error) { |
| 44 | res, err := apiClient.Info(ctx, client.InfoOptions{}) |
| 45 | if err != nil { |
| 46 | return "", err |
| 47 | } |
| 48 | for _, l := range res.Info.Labels { |
| 49 | if k, v, ok := strings.Cut(l, "="); ok && k == EngineLabel { |
| 50 | return v, nil |
| 51 | } |
| 52 | } |
| 53 | return "", nil |
| 54 | } |
| 55 | |
| 56 | // httpProxySocketEndpoint derives Docker Desktop's HTTP proxy socket endpoint |
| 57 | // from a Docker Desktop socket endpoint in the same directory. Returns "" |
no test coverage detected