feat: reimplement pathAlias for yaml fields
All checks were successful
Build and Push Server / build-and-push (push) Successful in 7m4s

This commit is contained in:
Max Richter
2025-10-24 11:12:35 +02:00
parent fcbce7b443
commit 75d6dab008
10 changed files with 51 additions and 20 deletions

View File

@@ -18,11 +18,11 @@ type yamlBlock struct {
}
type yamlField struct {
Path string `yaml:"path"`
Value any `yaml:"value,omitempty"`
Codec string `yaml:"codec"`
Hidden bool `yaml:"hidden,omitempty"`
PathAlias string `yaml:"pathAlias,omitempty"`
Path string `yaml:"path"`
Value any `yaml:"value,omitempty"`
Codec string `yaml:"codec"`
Hidden bool `yaml:"hidden,omitempty"`
PathAlias []string `yaml:"pathAlias,omitempty"`
}
func parseYamlTemplate(input Slice) (block Block, err error) {
@@ -53,6 +53,7 @@ func parseYamlTemplate(input Slice) (block Block, err error) {
var fields []BlockField
for _, field := range blk.Fields {
if field.Path == "" {
return block, fmt.Errorf("failed to parse field: %v", field)
}
@@ -66,18 +67,22 @@ func parseYamlTemplate(input Slice) (block Block, err error) {
return block, fmt.Errorf("failed to parse codec -> %w", err)
}
fields = append(fields, BlockField{
Path: field.Path,
CodecType: fieldCodec,
Value: field.Value,
Hidden: field.Hidden,
})
block := BlockField{
Path: field.Path,
PathAliases: field.PathAlias,
CodecType: fieldCodec,
Value: field.Value,
Hidden: field.Hidden,
}
fields = append(fields, block)
}
return Block{
Type: DataBlock,
Path: blk.Path,
PathAliases: blk.PathAlias,
Codec: codec,
Fields: fields,
ListTemplate: blk.ListTemplate,

View File

@@ -1,6 +1,8 @@
package template
import "strings"
import (
"strings"
)
// CompileTemplate scans once, emitting:
// - data blocks: inner content between a line that's exactly "{" and a line that's exactly "}"

View File

@@ -8,15 +8,17 @@ const (
)
type BlockField struct {
Path string
CodecType CodecType
Value any
Hidden bool
Path string
PathAliases []string
CodecType CodecType
Value any
Hidden bool
}
type Block struct {
Type BlockType
Path string
PathAliases []string
Codec CodecType
ListTemplate string
Fields []BlockField