Revert "blueprintload: enable strict checking for toml"

This reverts commit d41bd9aa5b.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
This commit is contained in:
Simon de Vlieger 2025-03-28 16:10:35 +01:00 committed by Achilleas Koutsou
parent 0d668c112a
commit f25b5e325e
2 changed files with 4 additions and 19 deletions

View file

@ -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
}

View file

@ -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)