-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparse.go
More file actions
43 lines (39 loc) · 1.16 KB
/
Copy pathparse.go
File metadata and controls
43 lines (39 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package catalog
import (
"github.com/jeduden/mdsmith/internal/archetype/gensection"
"github.com/jeduden/mdsmith/internal/lint"
)
// makeDiag creates a MDS019 error diagnostic at the given line.
func makeDiag(filePath string, line int, message string) lint.Diagnostic {
return gensection.MakeDiag("MDS019", "catalog", filePath, line, message)
}
// parseColumnConfig converts the raw YAML columns map into the
// catalog-internal columnConfig type by delegating to gensection.
func parseColumnConfig(raw map[string]any) map[string]columnConfig {
gc := gensection.ParseColumnConfig(raw)
if gc == nil {
return nil
}
result := make(map[string]columnConfig, len(gc))
for k, v := range gc {
result[k] = columnConfig{
maxWidth: v.MaxWidth,
wrap: v.Wrap,
}
}
return result
}
// fromGensectionColumns converts gensection ColumnConfig to catalog columnConfig.
func fromGensectionColumns(cols map[string]gensection.ColumnConfig) map[string]columnConfig {
if cols == nil {
return nil
}
result := make(map[string]columnConfig, len(cols))
for k, v := range cols {
result[k] = columnConfig{
maxWidth: v.MaxWidth,
wrap: v.Wrap,
}
}
return result
}