Cloud: preserve brand for EU Data Act vehicles (#31429)

This commit is contained in:
andig 2026-07-02 21:13:08 +02:00 • committed by GitHub
parent eea55d282d
commit c898954458
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 1 deletions

View file

@ -35,7 +35,11 @@ func NewFromConfig(ctx context.Context, typ string, other map[string]any) (api.V
}
if cc.Cloud {
cc.Other["brand"] = typ
// keep an explicit brand (e.g. drivesomethinggreater's Audi/Seat/...);
// otherwise the type itself is the brand (legacy per-brand vehicles)
if _, ok := cc.Other["brand"]; !ok {
cc.Other["brand"] = typ
}
typ = "cloud"
}

View file

@ -97,6 +97,12 @@ func TestResolveBrand(t *testing.T) {
_, ok := resolveBrand("nope")
assert.False(t, ok)
// IsBrand drives the cloud server's brand -> drivesomethinggreater routing
for _, name := range []string{"audi", "Volkswagen", "seat", "CUPRA", "skoda"} {
assert.True(t, IsBrand(name), "%q is a VW group brand", name)
}
assert.False(t, IsBrand("tesla"))
}
func TestPending(t *testing.T) {

View file

@ -38,6 +38,12 @@ func resolveBrand(name string) (brand, bool) {
return brand{}, false
}
// IsBrand reports whether name is a known VW group brand (case-insensitive)
func IsBrand(name string) bool {
_, ok := resolveBrand(name)
return ok
}
// Vehicle is a single entry of the portal vehicle list. VIN and name carry
// several alternative field names depending on the response variant.
type Vehicle struct {