diff --git a/go/catalogue/config_test.go b/go/catalogue/config_test.go index fd7f55e..1168074 100644 --- a/go/catalogue/config_test.go +++ b/go/catalogue/config_test.go @@ -482,3 +482,29 @@ func TestAnOperatorNamedValueAFileFallsBackOnMayHaveADefault(t *testing.T) { "default": "", "runtime": true} refused(t, runtime, `"url"`, `a key naming "url" is the operator's value`) } + +// 1658/AC1: a value whose only placement is ${config:key} in an item's text is placed. +func TestConfigCountsAnItemsTextAsAPlacement(t *testing.T) { + m := map[string]any{ + "module": "m", "version": "1", + "config": map[string]any{ + "k": map[string]any{"type": "string", "description": "a word the item says", "default": "x"}, + }, + "items": []any{map[string]any{"collection": "a", "content": "k = ${config:k}\n"}}, + } + if _, err := parseRaw(t, m); err != nil { + t.Fatalf("a value placed only in an item's text is refused: %v", err) + } +} + +// 1658/AC2: a declared value placed nowhere, with an item that does not say it, is still refused. +func TestConfigStillRefusesAValueNoItemPlaces(t *testing.T) { + m := map[string]any{ + "module": "m", "version": "1", + "config": map[string]any{ + "k": map[string]any{"type": "string", "description": "a word nothing says", "default": "x"}, + }, + "items": []any{map[string]any{"collection": "a", "content": "k = fixed\n"}}, + } + refused(t, m, `"k"`, "placed nowhere") +} diff --git a/go/catalogue/setting_into.go b/go/catalogue/setting_into.go index fbb966f..3c38bb7 100644 --- a/go/catalogue/setting_into.go +++ b/go/catalogue/setting_into.go @@ -324,7 +324,7 @@ func settingKeysUsedBy(m Manifest) map[string]bool { return used } -// settingKeysAskedOutsideOwners is every key a module's files, units, contributions and served facts +// settingKeysAskedOutsideOwners is every key a module's files, units, items, contributions and served facts // ask for: what a directory's owner may follow (OwnerSettingProblems). func settingKeysAskedOutsideOwners(m Manifest) map[string]bool { used := map[string]bool{} @@ -345,6 +345,10 @@ func settingKeysAskedOutsideOwners(m Manifest) map[string]bool { } } } + // An item's text, filled from its template (WithTemplatesFrom), places a key as a file's does (issue 1658). + for _, it := range m.Items { + note(it.Content) + } inValues := func(values map[string]any) { for _, v := range values { if s, ok := v.(string); ok {