From f25b5e325eae1279a437219a0cbfc2635cbe0612 Mon Sep 17 00:00:00 2001 From: Simon de Vlieger Date: Fri, 28 Mar 2025 16:10:35 +0100 Subject: [PATCH] Revert "blueprintload: enable strict checking for toml" This reverts commit d41bd9aa5b5534c4f95e9838b546ec36224f24ab. Signed-off-by: Simon de Vlieger --- internal/blueprintload/blueprintload.go | 6 ++---- internal/blueprintload/blueprintload_test.go | 17 ++--------------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/internal/blueprintload/blueprintload.go b/internal/blueprintload/blueprintload.go index 068fec9..84de3db 100644 --- a/internal/blueprintload/blueprintload.go +++ b/internal/blueprintload/blueprintload.go @@ -21,13 +21,11 @@ func decodeToml(r io.Reader, what string) (*externalBlueprint.Blueprint, error) dec := toml.NewDecoder(r) var conf externalBlueprint.Blueprint - metadata, err := dec.Decode(&conf) + _, err := dec.Decode(&conf) + if err != nil { return nil, fmt.Errorf("cannot decode %q: %w", what, err) } - if len(metadata.Undecoded()) > 0 { - return nil, fmt.Errorf("cannot decode %q: unknown keys found: %v", what, metadata.Undecoded()) - } return &conf, nil } diff --git a/internal/blueprintload/blueprintload_test.go b/internal/blueprintload/blueprintload_test.go index f3878cc..de7ad84 100644 --- a/internal/blueprintload/blueprintload_test.go +++ b/internal/blueprintload/blueprintload_test.go @@ -27,17 +27,6 @@ var testBlueprintTOML = ` name = "alice" ` -var testBlueprintJSONunknownKeys = ` -{ - "birds": {"name": "robin"} -} -` - -var testBlueprintTOMLunknownKeys = ` -[[birds]] -name = "robin" -` - var expectedBlueprint = &blueprint.Blueprint{ Customizations: &blueprint.Customizations{ User: []blueprint.UserCustomization{ @@ -66,11 +55,9 @@ func TestBlueprintLoadJSON(t *testing.T) { }{ {"bp.json", testBlueprintJSON, expectedBlueprint, ""}, {"bp.toml", testBlueprintTOML, expectedBlueprint, ""}, - {"bp.toml", "wrong-content", nil, `cannot decode ".*/bp.toml": toml: `}, - {"bp.json", "wrong-content", nil, `cannot decode ".*/bp.json": invalid `}, + {"bp.toml", "wrong-content", nil, `cannot decode .*/bp.toml": toml: `}, + {"bp.json", "wrong-content", nil, `cannot decode .*/bp.json": invalid `}, {"bp", "wrong-content", nil, `unsupported file extension for "/.*/bp"`}, - {"bp.toml", testBlueprintTOMLunknownKeys, nil, `cannot decode ".*/bp.toml": unknown keys found: \[birds birds.name\]`}, - {"bp.json", testBlueprintJSONunknownKeys, nil, `cannot decode ".*/bp.json": json: unknown field "birds"`}, } { blueprintPath := makeTestBlueprint(t, tc.fname, tc.content) bp, err := blueprintload.Load(blueprintPath)