IsFeatureActive reports whether Docker Desktop is the active engine and the given feature flag is enabled. Returns false silently on any failure — the engine being unreachable, Desktop not being the active engine, or the flag being off — so callers can use this as a single gating check.
(ctx context.Context, apiClient client.APIClient, feature string)
| 180 | // engine being unreachable, Desktop not being the active engine, or the flag |
| 181 | // being off — so callers can use this as a single gating check. |
| 182 | func IsFeatureActive(ctx context.Context, apiClient client.APIClient, feature string) bool { |
| 183 | endpoint, err := Endpoint(ctx, apiClient) |
| 184 | if err != nil || endpoint == "" { |
| 185 | return false |
| 186 | } |
| 187 | |
| 188 | c := NewClient(endpoint) |
| 189 | defer c.Close() //nolint:errcheck |
| 190 | |
| 191 | enabled, err := c.IsFeatureEnabled(ctx, feature) |
| 192 | if err != nil { |
| 193 | return false |
| 194 | } |
| 195 | return enabled |
| 196 | } |
| 197 | |
| 198 | // IsFeatureActiveStandalone is the convenience form of IsFeatureActive for |
| 199 | // callers without an existing engine API client (e.g. the compose plugin hook |
no test coverage detected