VFX Category Label Generation

This commit is contained in:
2026-05-31 13:47:14 +02:00
parent 67c03fa6bd
commit aa47532ef1
7 changed files with 587 additions and 56 deletions
+52 -1
View File
@@ -388,9 +388,15 @@ type AutogenConsumerConfig struct {
type HeadVisualeffectsConfig struct {
Groups map[string]HeadVisualeffectGroupConfig `json:"groups,omitempty" yaml:"groups"`
GroupTokenSource string `json:"group_token_source,omitempty" yaml:"group_token_source"`
CategoryFrom string `json:"category_from,omitempty" yaml:"category_from"`
Delimiter string `json:"delimiter,omitempty" yaml:"delimiter"`
Case string `json:"case,omitempty" yaml:"case"`
StripModelPrefixes []string `json:"strip_model_prefixes,omitempty" yaml:"strip_model_prefixes"`
KeyFormat string `json:"key_format,omitempty" yaml:"key_format"`
LabelFormat string `json:"label_format,omitempty" yaml:"label_format"`
LegacyGroups map[string]string `json:"legacy_groups,omitempty" yaml:"legacy_groups"`
LegacyKeyFormat string `json:"legacy_key_format,omitempty" yaml:"legacy_key_format"`
ModelColumn string `json:"model_column,omitempty" yaml:"model_column"`
RowDefaults map[string]string `json:"row_defaults,omitempty" yaml:"row_defaults"`
}
@@ -1807,15 +1813,45 @@ func validateGeneratedConfig(cfg GeneratedConfig) []error {
func headVisualeffectsConfigConfigured(cfg HeadVisualeffectsConfig) bool {
return len(cfg.Groups) > 0 ||
strings.TrimSpace(cfg.GroupTokenSource) != "" ||
strings.TrimSpace(cfg.CategoryFrom) != "" ||
strings.TrimSpace(cfg.Delimiter) != "" ||
strings.TrimSpace(cfg.Case) != "" ||
len(cfg.StripModelPrefixes) > 0 ||
strings.TrimSpace(cfg.KeyFormat) != "" ||
strings.TrimSpace(cfg.LabelFormat) != "" ||
len(cfg.LegacyGroups) > 0 ||
strings.TrimSpace(cfg.LegacyKeyFormat) != "" ||
strings.TrimSpace(cfg.ModelColumn) != "" ||
len(cfg.RowDefaults) > 0
}
func validateHeadVisualeffectsConfig(fieldPrefix string, cfg HeadVisualeffectsConfig) []error {
var failures []error
groupTokenSource := strings.TrimSpace(cfg.GroupTokenSource)
switch groupTokenSource {
case "", "prefix", "folder_name":
default:
failures = append(failures, fmt.Errorf("%s.group_token_source %q is not supported", fieldPrefix, cfg.GroupTokenSource))
}
categoryFrom := strings.TrimSpace(cfg.CategoryFrom)
switch categoryFrom {
case "", "none", "immediate_parent", "full_subgroup":
default:
failures = append(failures, fmt.Errorf("%s.category_from %q is not supported", fieldPrefix, cfg.CategoryFrom))
}
if strings.TrimSpace(cfg.Delimiter) == "" && cfg.Delimiter != "" {
failures = append(failures, fmt.Errorf("%s.delimiter must not be only whitespace", fieldPrefix))
}
if strings.ContainsAny(cfg.Delimiter, " \t\r\n\x00") {
failures = append(failures, fmt.Errorf("%s.delimiter must not contain whitespace or NUL bytes", fieldPrefix))
}
caseMode := strings.TrimSpace(cfg.Case)
switch caseMode {
case "", "preserve", "lower", "upper":
default:
failures = append(failures, fmt.Errorf("%s.case %q is not supported", fieldPrefix, cfg.Case))
}
for group, groupCfg := range cfg.Groups {
group = strings.TrimSpace(group)
if group == "" {
@@ -1824,7 +1860,7 @@ func validateHeadVisualeffectsConfig(fieldPrefix string, cfg HeadVisualeffectsCo
}
failures = append(failures, validateTreeRootPath(fieldPrefix+".groups["+group+"]", group)...)
prefix := strings.TrimSpace(groupCfg.Prefix)
if prefix == "" {
if prefix == "" && groupTokenSource != "folder_name" {
failures = append(failures, fmt.Errorf("%s.groups[%s].prefix is required", fieldPrefix, group))
}
if strings.ContainsAny(prefix, " \t\r\n\x00") {
@@ -1852,6 +1888,21 @@ func validateHeadVisualeffectsConfig(fieldPrefix string, cfg HeadVisualeffectsCo
}
}
}
for legacyGroup, group := range cfg.LegacyGroups {
legacyGroup = strings.TrimSpace(legacyGroup)
group = strings.TrimSpace(group)
if legacyGroup == "" {
failures = append(failures, fmt.Errorf("%s.legacy_groups contains an empty legacy group key", fieldPrefix))
continue
}
if group == "" {
failures = append(failures, fmt.Errorf("%s.legacy_groups[%s] must not be empty", fieldPrefix, legacyGroup))
}
failures = append(failures, validateTreeRootPath(fieldPrefix+".legacy_groups["+legacyGroup+"]", legacyGroup)...)
if group != "" {
failures = append(failures, validateTreeRootPath(fieldPrefix+".legacy_groups["+legacyGroup+"]", group)...)
}
}
for index, prefix := range cfg.StripModelPrefixes {
if strings.TrimSpace(prefix) == "" {
failures = append(failures, fmt.Errorf("%s.strip_model_prefixes[%d] must not be empty", fieldPrefix, index))