Add reference catalog selection to pipeline configuration
This commit is contained in:
24
internal/config/reference_catalog.go
Normal file
24
internal/config/reference_catalog.go
Normal file
@@ -0,0 +1,24 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user