-
Notifications
You must be signed in to change notification settings - Fork 1k
Add metadata to manifest & warn on unknown fields #528
Add metadata to manifest & warn on unknown fields #528
Conversation
manifest.go
Outdated
} | ||
} | ||
if !isValidMetadata { | ||
internal.Logf("WARNING: metadata should consist of key-value pairs") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're probably going to end up wanting to reuse this func elsewhere, in places where it's not a good idea to log directly. So, instead of directly logging the issues, could we switch to a ([]error, error)
return type, and record all the problems we detect as items in the first slice?
- Use manifest buffer to create a map of TomlTree and find all the unknown fields in the tree. Raise warnings for unknown fields. - For "metadata" field, ensure it's of map type, else raise warning.
64abf1d
to
90656bc
Compare
- Modifies ValidateManifest() to return []error, as a collection of all the errors, instead of logging directly. - Adds tests for ValidateManifest().
90656bc
to
8129217
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a bit more...
manifest_test.go
Outdated
{ | ||
tomlString: ` | ||
[[dependencies]] | ||
name = "github.com/foo/bar" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we also validate that there aren't any extra fields within [[dependencies]]
or [[overrides]]
items?
@sdboyer thanks to that extra bit, I found that the checks can be improved by just using type assertion. Once a property is TOML array of tables ([[some-name]]), TOML ensures that the content has to be map (key-value pair) :) Added checks for invalid fields in |
1bd28e6
to
831aab0
Compare
- Improves property validation by checking for TOML array of tables. - Adds checks for invalid fields in dependencies and overrides.
@darkowlzz hmm - looking at the TOML spec a bit, and poking at the PR, I'm confused - array of tables isn't actually the same thing as just a plain table, because you can specify them multiple times. And we don't want that to be possible - there should be exactly one allowed Related - let's also make sure a the test exercises the possibility of nesting metadata within e.g. a |
831aab0
to
e518855
Compare
- Makes metadata TOML table. - Allows metadata table in "dependencies" and "overrides".
@sdboyer great! now that makes things more clear :)
|
Awesome, this looks great! Thanks so much 😄 🎉 |
It appears that this PR may have triggered a regression. Consuming the latest, I see:
From:
|
@mdelder it did indeed - thanks for responding quickly here. I'm updating things now. |
…known-manifest-fields Add metadata to manifest & warn on unknown fields
unknown fields in the tree. Raise warnings for unknown fields.
Fixes #506