Bootstrap secrets for shared configuration acquisition
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package appconfig
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
@@ -48,7 +49,7 @@ party:
|
||||
`)
|
||||
write("shared/extra.yml", "lore:\n entries:\n - id: hero\n name: Ancient\n category: lore\n")
|
||||
write("glossary/nested/spells.yaml", "spells:\n entries:\n - id: bolt\n name: Bolt\n category: spell\n aliases: [Spark]\n plural: Bolts\n extra: {rank: 2}\n")
|
||||
result, err := Load(ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
result, _, err := Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
if err != nil {
|
||||
t.Fatalf("%v: %+v", err, err.(*ck.LoadError).Diagnostics())
|
||||
}
|
||||
@@ -62,7 +63,7 @@ party:
|
||||
if got := result.Config.Application.GlossaryCollections["lore"].Entries; len(got) != 1 || got[0].ID != "hero" {
|
||||
t.Fatalf("lore=%+v", got)
|
||||
}
|
||||
discovered, err := Load(ck.Input{Source: ck.SearchConfig("audita", ck.SearchDirectory(dir))}, "")
|
||||
discovered, _, err := Load(context.Background(), ck.Input{Source: ck.SearchConfig("audita", ck.SearchDirectory(dir))}, "")
|
||||
if err != nil || len(discovered.Config.Application.GlossaryCollections["party"].Entries) != 2 {
|
||||
t.Fatalf("discovered glossary: %+v %v", discovered, err)
|
||||
}
|
||||
@@ -97,7 +98,7 @@ func TestGlossaryValidationAndPeerConflicts(t *testing.T) {
|
||||
"glossary_collections:\n x:\n entries:\n - {id: 'id with spaces', name: N, category: C}\n",
|
||||
} {
|
||||
write(main, data)
|
||||
if _, err := Load(ck.Input{Source: ck.File(main)}, ""); err != nil {
|
||||
if _, _, err := Load(context.Background(), ck.Input{Source: ck.File(main)}, ""); err != nil {
|
||||
t.Fatalf("valid %q: %v", data, err)
|
||||
}
|
||||
}
|
||||
@@ -108,7 +109,7 @@ func TestGlossaryValidationAndPeerConflicts(t *testing.T) {
|
||||
"glossary_collections:\n x:\n entries:\n - {id: x, name: N, category: C, plural: ''}\n",
|
||||
} {
|
||||
write(main, data)
|
||||
if _, err := Load(ck.Input{Source: ck.File(main)}, ""); err == nil {
|
||||
if _, _, err := Load(context.Background(), ck.Input{Source: ck.File(main)}, ""); err == nil {
|
||||
t.Fatalf("accepted %q", data)
|
||||
}
|
||||
}
|
||||
@@ -118,7 +119,7 @@ func TestGlossaryValidationAndPeerConflicts(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
write(filepath.Join(dir, "glossary", "other.yml"), "x:\n entries:\n - {id: same, name: Two, category: C}\n")
|
||||
if _, err := Load(ck.Input{Source: ck.File(main)}, ""); err == nil {
|
||||
if _, _, err := Load(context.Background(), ck.Input{Source: ck.File(main)}, ""); err == nil {
|
||||
t.Fatal("peer conflict accepted")
|
||||
}
|
||||
}
|
||||
@@ -129,7 +130,7 @@ func TestGlossaryUnderlaySkipsAbsentMain(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Chdir(dir)
|
||||
result, err := Load(ck.Input{Source: ck.NoSource()}, "")
|
||||
result, _, err := Load(context.Background(), ck.Input{Source: ck.NoSource()}, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user