Count an item's text as a placement of a config value, so a key only an item says is not refused (issue 1658)
mesh/merge-gate waits for its group's composed check
mesh/repo-check head c8e35097e861 merged into trunk d4deecdb380b beside mesh-controller#420@858b06a9 +1 more — pass: its merge-check.sh passed, each part i…
mesh/delivery-group group fix/1656-xterm-config rejected: a member's own check failed
mesh/delivery superseded: a newer head of the same pull request
mesh/merge-gate waits for its group's composed check
mesh/repo-check head c8e35097e861 merged into trunk d4deecdb380b beside mesh-controller#420@858b06a9 +1 more — pass: its merge-check.sh passed, each part i…
mesh/delivery-group group fix/1656-xterm-config rejected: a member's own check failed
mesh/delivery superseded: a newer head of the same pull request
This commit is contained in:
@@ -482,3 +482,29 @@ func TestAnOperatorNamedValueAFileFallsBackOnMayHaveADefault(t *testing.T) {
|
|||||||
"default": "", "runtime": true}
|
"default": "", "runtime": true}
|
||||||
refused(t, runtime, `"url"`, `a key naming "url" is the operator's value`)
|
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")
|
||||||
|
}
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ func settingKeysUsedBy(m Manifest) map[string]bool {
|
|||||||
return used
|
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).
|
// ask for: what a directory's owner may follow (OwnerSettingProblems).
|
||||||
func settingKeysAskedOutsideOwners(m Manifest) map[string]bool {
|
func settingKeysAskedOutsideOwners(m Manifest) map[string]bool {
|
||||||
used := 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) {
|
inValues := func(values map[string]any) {
|
||||||
for _, v := range values {
|
for _, v := range values {
|
||||||
if s, ok := v.(string); ok {
|
if s, ok := v.(string); ok {
|
||||||
|
|||||||
Reference in New Issue
Block a user