feat(scum): add bounded vehicle spawn adapter
This commit is contained in:
@@ -25,6 +25,12 @@ var requiredCapabilities = []string{
|
||||
"game-client.bridge",
|
||||
"logs.stream",
|
||||
}
|
||||
var optionalCapabilities = map[string]struct{}{
|
||||
"handler.vehicle.spawn": {},
|
||||
}
|
||||
var requiredCapabilitySet = map[string]struct{}{
|
||||
"component.register": {}, "component.heartbeat": {}, "component.health": {}, "component.control": {}, "game-client.bridge": {}, "logs.stream": {},
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
SchemaVersion int `json:"schemaVersion" yaml:"schemaVersion"`
|
||||
@@ -147,7 +153,7 @@ func canonicalPlatformOrigin(value string) (string, error) {
|
||||
}
|
||||
|
||||
func validateCapabilities(capabilities []string) error {
|
||||
if len(capabilities) != len(requiredCapabilities) {
|
||||
if len(capabilities) < len(requiredCapabilities) || len(capabilities) > len(requiredCapabilities)+len(optionalCapabilities) {
|
||||
return fmt.Errorf("component capabilities do not match the SCUM companion profile")
|
||||
}
|
||||
actual := make(map[string]struct{}, len(capabilities))
|
||||
@@ -162,5 +168,12 @@ func validateCapabilities(capabilities []string) error {
|
||||
return fmt.Errorf("component capabilities do not match the SCUM companion profile")
|
||||
}
|
||||
}
|
||||
for capability := range actual {
|
||||
if _, required := requiredCapabilitySet[capability]; !required {
|
||||
if _, optional := optionalCapabilities[capability]; !optional {
|
||||
return fmt.Errorf("component capabilities do not match the SCUM companion profile")
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user