Files
narratio/internal/config/reference_catalog.go

25 lines
750 B
Go

package config
import "fmt"
// SelectSetting returns the source for a selected setting, or no source for an omitted selection.
func (catalog ReferenceCatalogConfig) SelectSetting(id string) (string, error) {
return selectReference("setting", id, catalog.Settings)
}
// SelectSystem returns the source for a selected system, or no source for an omitted selection.
func (catalog ReferenceCatalogConfig) SelectSystem(id string) (string, error) {
return selectReference("system", id, catalog.Systems)
}
func selectReference(kind, id string, entries map[string]string) (string, error) {
if id == "" {
return "", nil
}
path, ok := entries[id]
if !ok {
return "", fmt.Errorf("unknown reference catalog %s %q", kind, id)
}
return path, nil
}